diff --git a/src/modules/graphic/osggraph/OsgScreens.cpp b/src/modules/graphic/osggraph/OsgScreens.cpp index 74484f548..7555d962c 100755 --- a/src/modules/graphic/osggraph/OsgScreens.cpp +++ b/src/modules/graphic/osggraph/OsgScreens.cpp @@ -20,16 +20,16 @@ #include -#include -#include #include +#include + #include "OsgScreens.h" SDScreens::SDScreens() { - viewer = new osgViewer::CompositeViewer(); + viewer = new osgViewer::Viewer(); } void SDScreens::Init(int x,int y, int width, int height, osg::ref_ptr m_sceneroot){ @@ -40,22 +40,23 @@ void SDScreens::Init(int x,int y, int width, int height, osg::ref_ptraddView(osgView); - view = new SDViewer(osgView); + + + + + + view = new SDViewer(viewer->getCamera()); viewer->setThreadingModel(osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext); - view->getOsgView()->setUpViewInWindow(0, 0, grWinw, grWinh,0); - osgView->getCamera()->setName("Cam one"); - osgView->getCamera()->setViewport(new osg::Viewport(0, 0, grWinw, grWinh)); - osgView->getCamera()->setGraphicsContext(gw); - osgView->getCamera()->setProjectionMatrixAsPerspective(67.5f, static_cast((float)grWinw / (float)grWinh), 0.1f, 12000.0f); - osgView->setSceneData(m_sceneroot.get()); + osg::ref_ptr gw = viewer->setUpViewerAsEmbeddedInWindow(0, 0, grWinw, grWinh); + //view->getOsgView()->setUpViewInWindow(0, 0, grWinw, grWinh,0); + viewer->getCamera()->setName("Cam one"); + viewer->getCamera()->setViewport(new osg::Viewport(0, 0, grWinw, grWinh)); + viewer->getCamera()->setGraphicsContext(gw); + viewer->getCamera()->setProjectionMatrixAsPerspective(67.5f, static_cast((float)grWinw / (float)grWinh), 0.1f, 12000.0f); + viewer->setSceneData(m_sceneroot.get()); //viewer->realize(); @@ -71,7 +72,7 @@ void SDScreens::InitCars(tSituation *s){ void SDScreens::update(tSituation * s,SDFrameInfo* fi){ view->update(s,fi); - //if (!viewer->done()) + if (!viewer->done()) viewer->frame(); } diff --git a/src/modules/graphic/osggraph/OsgScreens.h b/src/modules/graphic/osggraph/OsgScreens.h index 5d49731a7..4f703585f 100755 --- a/src/modules/graphic/osggraph/OsgScreens.h +++ b/src/modules/graphic/osggraph/OsgScreens.h @@ -23,7 +23,7 @@ - +#include #include //tSituation #include "OsgView.h" @@ -31,7 +31,7 @@ class SDScreens { protected: - osgViewer::CompositeViewer *viewer; + osgViewer::Viewer *viewer; SDViewer * view; // int mirrorFlag; diff --git a/src/modules/graphic/osggraph/OsgView.cpp b/src/modules/graphic/osggraph/OsgView.cpp index 98b01928d..53ada88e0 100644 --- a/src/modules/graphic/osggraph/OsgView.cpp +++ b/src/modules/graphic/osggraph/OsgView.cpp @@ -19,7 +19,7 @@ -#include +#include #include @@ -32,9 +32,9 @@ static char buf[1024]; static char path[1024]; static char path2[1024]; -SDViewer::SDViewer(osgViewer::View * v) +SDViewer::SDViewer(osg::Camera * c) { - view = v; + cam = c; id = 0; curCar = NULL; //curCam = NULL; @@ -82,7 +82,6 @@ void SDViewer::switchMirror(void) void SDViewer::Init(tSituation *s) { - view = new osgViewer::View(); loadParams(s); } @@ -212,9 +211,9 @@ void SDViewer::update(tSituation *s, const SDFrameInfo* frameInfo) //osg::Camera * camera = m_sceneViewer->getCamera(); - //view->getCamera()>setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); + cam->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); - view->getCamera()->setViewMatrixAsLookAt( eye, center, up); + cam->setViewMatrixAsLookAt( eye, center, up); } diff --git a/src/modules/graphic/osggraph/OsgView.h b/src/modules/graphic/osggraph/OsgView.h index bdd127db6..9df429ac5 100644 --- a/src/modules/graphic/osggraph/OsgView.h +++ b/src/modules/graphic/osggraph/OsgView.h @@ -37,7 +37,7 @@ class SDViewer { protected: - osgViewer::View * view; + osg::Camera * cam; int id; @@ -71,7 +71,7 @@ class SDViewer void loadParams(tSituation *s); // Load from parameters files. public: - SDViewer(osgViewer::View * v); + SDViewer(osg::Camera * c); ~SDViewer(); void Init(tSituation *s); @@ -109,7 +109,7 @@ class SDViewer inline int getScrW (void) { return scrw; } inline int getScrH (void) { return scrh; } - inline osgViewer::View * getOsgView(void) { return view; } + inline osg::Camera * getOsgCam(void) { return cam; } //inline int getBoardWidth(void) { return boardWidth; } };