From 48c3e2b6c4a7348e9cbd8b30699adf7123ee389b Mon Sep 17 00:00:00 2001 From: rnv Date: Mon, 6 Apr 2015 11:34:03 +0300 Subject: [PATCH] This is an experiment with the advanced visualization in the OCC Viewer (Ray tracing + lights + environment texture) --- src/OCCViewer/OCCViewer_VService.cxx | 3 +- src/OCCViewer/OCCViewer_ViewWindow.cxx | 41 +++++++++++++++++++------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx index 94f5862b8..13bfe87dd 100755 --- a/src/OCCViewer/OCCViewer_VService.cxx +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -25,6 +25,7 @@ #include #include +#include #include #if OCC_VERSION_LARGE > 0x06070200 // for OCC-6.7.3 and higher version #include @@ -32,7 +33,6 @@ #include #include #endif -#include #ifdef WIN32 #include @@ -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 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 98ae2107b..96eaa6ceb 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -73,6 +73,11 @@ #include #include #include +#include + +#include +#include + #include #include @@ -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(); } /*! -- 2.39.2