From e1e54570cb9c60b1975d5dab58096e1c448d9e62 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 10 Apr 2003 10:02:24 +0000 Subject: [PATCH] Fixed Viewer and OsgCameraGroup classes so that work properly with the Prodicer::setViewByMatrix calls. --- include/osgProducer/Viewer | 5 ++--- src/osgProducer/OsgCameraGroup.cpp | 2 +- src/osgProducer/Viewer.cpp | 10 ++++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/osgProducer/Viewer b/include/osgProducer/Viewer index cf99f27c5..540b9560d 100644 --- a/include/osgProducer/Viewer +++ b/include/osgProducer/Viewer @@ -73,9 +73,8 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction /** 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); + /** Override the Producer::CameraGroup::setViewByMatrix to catch all changes to view.*/ + virtual void setViewByMatrix( const Producer::Matrix & pm); /** 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 f198a8db0..6422e8997 100644 --- a/src/osgProducer/OsgCameraGroup.cpp +++ b/src/osgProducer/OsgCameraGroup.cpp @@ -390,7 +390,7 @@ const osg::Node* OsgCameraGroup::getTopMostSceneData() const void OsgCameraGroup::setView(const osg::Matrix& matrix) { Producer::Matrix pm(matrix.ptr()); - CameraGroup::setView(pm); + setViewByMatrix(pm); } const osg::Matrix OsgCameraGroup::getViewMatrix() const diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index 4a18f304e..11e9c1cdb 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -177,11 +177,17 @@ bool Viewer::done() const return _done; } -void Viewer::setView(const osg::Matrix& matrix) +void Viewer::setViewByMatrix( const Producer::Matrix & pm) { - OsgCameraGroup::setView(matrix); + CameraGroup::setViewByMatrix(pm); + if (_keyswitchManipulator.valid() && _old_style_osg_camera.valid()) { + // now convert Producer matrix to an osg::Matrix so we can update + // the internal camera... + + osg::Matrix matrix(pm.ptr()); + _old_style_osg_camera->home(); _old_style_osg_camera->transformLookAt(matrix); osg::ref_ptr init_event = _kbmcb->createEventAdapter();