From 522ffca03cd1cb54e1b0b9db9523cf5103dc2443 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 29 Apr 2004 22:19:57 +0000 Subject: [PATCH] Added support for tracking a user specified CoordinateSystemNode for the CoordinateFrame to use in the camera manipulation --- include/osgProducer/Viewer | 6 ++++++ src/osgProducer/Viewer.cpp | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/osgProducer/Viewer b/include/osgProducer/Viewer index dc4dce790..37e57d415 100644 --- a/include/osgProducer/Viewer +++ b/include/osgProducer/Viewer @@ -100,6 +100,10 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction const osg::NodeVisitor* getUpdateVisitor() const { return _updateVisitor.get(); } + void setCoordindateSystemNodePath(const osg::NodePath& nodePath) { _coordinateSystemNodePath = nodePath; } + + const osg::NodePath& getCoordindateSystemNodePath() { return _coordinateSystemNodePath; } + /** Dispatch the cull and draw for each of the Camera's for this frame.*/ virtual void frame(); @@ -179,6 +183,8 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction osg::ref_ptr _updateVisitor; + osg::NodePath _coordinateSystemNodePath; + bool _recordingAnimationPath; double _recordingStartTime; osg::ref_ptr _animationPath; diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index 60e39e8d8..6ff70ce23 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -488,6 +488,23 @@ void Viewer::update() osgProducer::KeyboardMouseCallback::EventQueue queue; if (_kbmcb.valid()) _kbmcb->getEventQueue(queue); + if (getKeySwitchMatrixManipulator() && !_coordinateSystemNodePath.empty()) + { + osg::Matrixd coordinateFrame; + + osg::CoordinateSystemNode* csn = dynamic_cast(_coordinateSystemNodePath.back()); + if (csn) + { + coordinateFrame = csn->computeLocalCoordinateFrame(_position[0],_position[1],_position[2])* osg::computeLocalToWorld(_coordinateSystemNodePath); + } + else + { + coordinateFrame = osg::computeLocalToWorld(_coordinateSystemNodePath); + } + + getKeySwitchMatrixManipulator()->setCoordinateFrame(coordinateFrame); + } + // create an event to signal the new frame. osg::ref_ptr frame_event = new osgProducer::EventAdapter; frame_event->adaptFrame(_frameStamp->getReferenceTime()); @@ -513,7 +530,6 @@ void Viewer::update() osgDB::Registry::instance()->getDatabasePager()->updateSceneGraph(_frameStamp->getReferenceTime()); } - if (_updateVisitor.valid()) { _updateVisitor->setTraversalNumber(_frameStamp->getFrameNumber());