]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
This is an experiment with the advanced visualization in the OCC Viewer (Ray tracing... rnv/rt
authorrnv <rnv@opencascade.com>
Mon, 6 Apr 2015 08:34:03 +0000 (11:34 +0300)
committerrnv <rnv@opencascade.com>
Mon, 6 Apr 2015 08:34:03 +0000 (11:34 +0300)
src/OCCViewer/OCCViewer_VService.cxx
src/OCCViewer/OCCViewer_ViewWindow.cxx

index 94f5862b82a185422eccff79458706098b1c5997..13bfe87dd29c0f2489dbaf13c3baf604c344700e 100755 (executable)
@@ -25,6 +25,7 @@
 #include <V3d_Viewer.hxx>
 #include <V3d_View.hxx>
 
+#include <Aspect_DisplayConnection.hxx>
 #include <Basics_OCCTVersion.hxx>
 #if OCC_VERSION_LARGE > 0x06070200 // for OCC-6.7.3 and higher version
 #include <OpenGl_GraphicDriver.hxx>
@@ -32,7 +33,6 @@
 #include <Graphic3d.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
 #endif
-#include <Aspect_DisplayConnection.hxx>
 
 #ifdef WIN32
 #include <WNT_Window.hxx>
@@ -82,6 +82,7 @@ Handle(V3d_Viewer) OCCViewer_VService::CreateViewer( const Standard_ExtString na
 #endif
 #if OCC_VERSION_LARGE > 0x06070200 // for OCC-6.7.3 and higher version
     aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
+    aGraphicDriver->ChangeOptions().keepArrayData = Standard_True;
 #else
     aGraphicDriver = Graphic3d::InitGraphicDriver( aDisplayConnection );
 #endif
index 98ae2107b3d762f9126aefb8a6cfdf96aaf6061a..96eaa6ceb1b2f4b304a10342a487c5a407734c2c 100755 (executable)
 #include <Graphic3d_MapOfStructure.hxx>
 #include <Graphic3d_Structure.hxx>
 #include <Graphic3d_ExportFormat.hxx>
+#include <Graphic3d_TextureEnv.hxx>
+
+#include <V3d_DirectionalLight.hxx>
+#include <V3d_AmbientLight.hxx>
+
 
 #include <Visual3d_View.hxx>
 #include <V3d_Plane.hxx>
@@ -1660,19 +1665,33 @@ void OCCViewer_ViewWindow::onGraduatedAxes()
 void OCCViewer_ViewWindow::onAmbientToogle()
 {
   Handle(V3d_Viewer) viewer = myViewPort->getViewer();
+  Handle(V3d_View) aView3d = myViewPort->getView();
+
   viewer->InitDefinedLights();
-  while(viewer->MoreDefinedLights())
-    {
-      Handle(V3d_Light) light = viewer->DefinedLight();
-      if(light->Type() != V3d_AMBIENT)
-        {
-          Handle(V3d_View) aView3d = myViewPort->getView();
-          if( aView3d->IsActiveLight(light) ) viewer->SetLightOff(light);
-          else viewer->SetLightOn(light);
-        }
-      viewer->NextDefinedLights();
-    }
+  while(viewer->MoreDefinedLights()) {
+    Handle(V3d_Light) light = viewer->DefinedLight();
+    viewer->SetLightOff(light);
+    viewer->NextDefinedLights();
+  }
+
+  viewer->SetLightOn( new V3d_DirectionalLight( viewer, 0, 0, 0, -50, 50, 100, Quantity_NOC_WHITE, Standard_True ) );
+  viewer->SetLightOn( new V3d_AmbientLight( viewer, Quantity_NOC_GRAY80 ) );
   viewer->Update();
+  
+  Graphic3d_RenderingParams& aParams = aView3d->ChangeRenderingParams();
+  aParams.Method = Graphic3d_RM_RAYTRACING;
+  aParams.IsShadowEnabled = Standard_True;
+  aParams.IsReflectionEnabled = Standard_True;
+  aParams.IsAntialiasingEnabled = Standard_True;
+  aParams.IsTransparentShadowEnabled = Standard_False;
+  aParams.RaytracingDepth = 5;
+  
+  Handle(Graphic3d_TextureEnv) aTexEnv = new Graphic3d_TextureEnv((Graphic3d_NameOfTextureEnv)1);
+  
+  aView3d->SetTextureEnv(aTexEnv);
+  aView3d->SetSurfaceDetail(V3d_TEX_ENVIRONMENT);
+  
+  aView3d->Redraw();  
 }
 
 /*!