From 65ab874143e05d4351964b5d68f7d02f0b0cc343 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 9 Jul 2012 17:32:13 +0000 Subject: [PATCH] From Riccardo Corsi, introduced CameraManipulator::updateCamera() method that allows more Camera properties to be controlled by the CameraManipulator. --- include/osgGA/CameraManipulator | 4 ++++ src/osgViewer/CompositeViewer.cpp | 5 +++-- src/osgViewer/Viewer.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/osgGA/CameraManipulator b/include/osgGA/CameraManipulator index 866210d71..9c610a898 100644 --- a/include/osgGA/CameraManipulator +++ b/include/osgGA/CameraManipulator @@ -87,6 +87,10 @@ class OSGGA_EXPORT CameraManipulator : public GUIEventHandler /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/ virtual osg::Matrixd getInverseMatrix() const = 0; + /** update the camera for the current frame, typically called by the viewer classes. + Default implementation simply set the camera view matrix. */ + virtual void updateCamera(osg::Camera* camera) { camera->setViewMatrix(getInverseMatrix()); } + /** Get the FusionDistanceMode. Used by SceneView for setting up stereo convergence.*/ virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE; } diff --git a/src/osgViewer/CompositeViewer.cpp b/src/osgViewer/CompositeViewer.cpp index 43e55b6fa..1ce254414 100644 --- a/src/osgViewer/CompositeViewer.cpp +++ b/src/osgViewer/CompositeViewer.cpp @@ -1158,8 +1158,9 @@ void CompositeViewer::updateTraversal() { view->setFusionDistance( view->getCameraManipulator()->getFusionDistanceMode(), view->getCameraManipulator()->getFusionDistanceValue() ); - - view->getCamera()->setViewMatrix( view->getCameraManipulator()->getInverseMatrix()); + + view->getCameraManipulator()->updateCamera(view->getCamera()); + } view->updateSlaves(); diff --git a/src/osgViewer/Viewer.cpp b/src/osgViewer/Viewer.cpp index 02048c5e7..8430eaa82 100644 --- a/src/osgViewer/Viewer.cpp +++ b/src/osgViewer/Viewer.cpp @@ -1038,7 +1038,7 @@ void Viewer::updateTraversal() setFusionDistance( getCameraManipulator()->getFusionDistanceMode(), getCameraManipulator()->getFusionDistanceValue() ); - _camera->setViewMatrix(_cameraManipulator->getInverseMatrix()); + _cameraManipulator->updateCamera(_camera); } updateSlaves();