Added support for tracking a user specified CoordinateSystemNode for the
CoordinateFrame to use in the camera manipulation
This commit is contained in:
parent
f81447e839
commit
522ffca03c
@ -100,6 +100,10 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
|
|||||||
const osg::NodeVisitor* getUpdateVisitor() const { return _updateVisitor.get(); }
|
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.*/
|
/** Dispatch the cull and draw for each of the Camera's for this frame.*/
|
||||||
virtual void frame();
|
virtual void frame();
|
||||||
|
|
||||||
@ -179,6 +183,8 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
|
|||||||
|
|
||||||
osg::ref_ptr<osg::NodeVisitor> _updateVisitor;
|
osg::ref_ptr<osg::NodeVisitor> _updateVisitor;
|
||||||
|
|
||||||
|
osg::NodePath _coordinateSystemNodePath;
|
||||||
|
|
||||||
bool _recordingAnimationPath;
|
bool _recordingAnimationPath;
|
||||||
double _recordingStartTime;
|
double _recordingStartTime;
|
||||||
osg::ref_ptr<osg::AnimationPath> _animationPath;
|
osg::ref_ptr<osg::AnimationPath> _animationPath;
|
||||||
|
@ -488,6 +488,23 @@ void Viewer::update()
|
|||||||
osgProducer::KeyboardMouseCallback::EventQueue queue;
|
osgProducer::KeyboardMouseCallback::EventQueue queue;
|
||||||
if (_kbmcb.valid()) _kbmcb->getEventQueue(queue);
|
if (_kbmcb.valid()) _kbmcb->getEventQueue(queue);
|
||||||
|
|
||||||
|
if (getKeySwitchMatrixManipulator() && !_coordinateSystemNodePath.empty())
|
||||||
|
{
|
||||||
|
osg::Matrixd coordinateFrame;
|
||||||
|
|
||||||
|
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(_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.
|
// create an event to signal the new frame.
|
||||||
osg::ref_ptr<osgProducer::EventAdapter> frame_event = new osgProducer::EventAdapter;
|
osg::ref_ptr<osgProducer::EventAdapter> frame_event = new osgProducer::EventAdapter;
|
||||||
frame_event->adaptFrame(_frameStamp->getReferenceTime());
|
frame_event->adaptFrame(_frameStamp->getReferenceTime());
|
||||||
@ -513,7 +530,6 @@ void Viewer::update()
|
|||||||
osgDB::Registry::instance()->getDatabasePager()->updateSceneGraph(_frameStamp->getReferenceTime());
|
osgDB::Registry::instance()->getDatabasePager()->updateSceneGraph(_frameStamp->getReferenceTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_updateVisitor.valid())
|
if (_updateVisitor.valid())
|
||||||
{
|
{
|
||||||
_updateVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
_updateVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
||||||
|
Loading…
Reference in New Issue
Block a user