From 8a3d7317392ec75ac0bcaccfe343cac81d360f1b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 8 Apr 2003 15:47:45 +0000 Subject: [PATCH] Added support for Viewer::setViewer::setView so that the internal old style osg::Camera and camera manipulators are updated correctly. --- include/osgProducer/OsgCameraGroup | 2 +- include/osgProducer/Viewer | 7 ++++++- src/osgProducer/OsgCameraGroup.cpp | 4 ++-- src/osgProducer/Viewer.cpp | 25 ++++++++++++++++++++----- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/include/osgProducer/OsgCameraGroup b/include/osgProducer/OsgCameraGroup index ae7d88854..9bb5632ba 100644 --- a/include/osgProducer/OsgCameraGroup +++ b/include/osgProducer/OsgCameraGroup @@ -145,7 +145,7 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup /** Set the model view matrix of the camera group, * by individually set all the camera groups's camera.*/ - void setView(const osg::Matrix& matrix); + virtual void setView(const osg::Matrix& matrix); /** Get the model view martrix of the camera group, * taking its value for camera 0.*/ diff --git a/include/osgProducer/Viewer b/include/osgProducer/Viewer index 0f7d31672..cf99f27c5 100644 --- a/include/osgProducer/Viewer +++ b/include/osgProducer/Viewer @@ -70,7 +70,12 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction void setUpViewer(unsigned int options=STANDARD_SETTINGS); - bool done() const { return _done; } + /** return true if the application is done and should exit.*/ + bool done() const; + + /** Set the model view matrix of the camera group, + * by individually set all the camera groups's camera.*/ + virtual void setView(const osg::Matrix& matrix); /** Set the threading model and then call realize().*/ virtual bool realize(ThreadingModel thread_model); diff --git a/src/osgProducer/OsgCameraGroup.cpp b/src/osgProducer/OsgCameraGroup.cpp index 8a8775d94..e22e64698 100644 --- a/src/osgProducer/OsgCameraGroup.cpp +++ b/src/osgProducer/OsgCameraGroup.cpp @@ -357,8 +357,8 @@ bool OsgCameraGroup::realize() getTopMostSceneData()->accept(sfpn); if (sfpn._foundParticles) { - osg::notify(osg::NOTICE)<<"Warning: disabling multi-threading of cull and draw"<home(); + _old_style_osg_camera->transformLookAt(matrix); + osg::ref_ptr init_event = _kbmcb->createEventAdapter(); + _keyswitchManipulator->init(*init_event,*this); + } +} + bool Viewer::realize( ThreadingModel thread_model ) { if( _realized ) return _realized; @@ -194,7 +211,7 @@ bool Viewer::realize() { osg::ref_ptr init_event = _kbmcb->createEventAdapter(); init_event->adaptFrame(0.0); - + _keyswitchManipulator->setCamera(_old_style_osg_camera.get()); _keyswitchManipulator->setNode(getSceneDecorator()); _keyswitchManipulator->home(*init_event,*this); @@ -256,7 +273,7 @@ void Viewer::update() } // update the main producer camera - if (_old_style_osg_camera.valid()) setView(_old_style_osg_camera->getModelViewMatrix()); + if (_old_style_osg_camera.valid()) OsgCameraGroup::setView(_old_style_osg_camera->getModelViewMatrix()); } void Viewer::frame() @@ -282,15 +299,13 @@ void Viewer::selectCameraManipulator(unsigned int no) void Viewer::requestWarpPointer(float x,float y) { - if (_kbmcb) { EventAdapter::_s_mx = x; EventAdapter::_s_my = y; _kbmcb->getKeyboardMouse()->positionPointer(x,y); return; - } - + } } void Viewer::getUsage(osg::ApplicationUsage& usage) const