From Jan Peciva, "I am sending one more improvement (separately from Inventor plugin).
I found very useful to have a control whether osgView::setCameraManipulator does or does not reset camera to home position. I extended method signature as follows: void setCameraManipulator(osgGA::MatrixManipulator* manipulator, bool resetPosition = true); keeping the current usage intact (default parameter), while enabling user to disable the position reset. That can be useful in the situation when manipulator position was already loaded, for example from a file (user specification), or defined any other way, while we do not want to be reset to home position. Other usability is usage of two manipulators in a modeling program (orbiting around the model, walking on the model) and changing between them while we want to preserve the position of a camera in the change. Games may benefit from it as well when we change from user-defined helicopter manipulator to soldier manipulator because the user escaped the helicopter. The camera will change manipulator but the position is expected to be kept in the transition (provided that user makes the state transition between the two manipulators himself). "
This commit is contained in:
@@ -98,8 +98,9 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
/* Get the const View's EventQueue.*/
|
||||
const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
|
||||
|
||||
/** Set the CameraManipulator that moves the View's master Camera position in response to events.*/
|
||||
void setCameraManipulator(osgGA::MatrixManipulator* manipulator);
|
||||
/** Set the CameraManipulator that moves the View's master Camera position in response to events.
|
||||
* The parameter resetPosition determines whether manipulator is set to its home position.*/
|
||||
void setCameraManipulator(osgGA::MatrixManipulator* manipulator, bool resetPosition = true);
|
||||
|
||||
/** Get the View's CameraManipulator.*/
|
||||
osgGA::MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); }
|
||||
|
||||
@@ -338,7 +338,7 @@ const osgDB::ImagePager* View::getImagePager() const
|
||||
}
|
||||
|
||||
|
||||
void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator)
|
||||
void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator, bool resetPosition)
|
||||
{
|
||||
_cameraManipulator = manipulator;
|
||||
|
||||
@@ -348,9 +348,11 @@ void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator)
|
||||
|
||||
if (getSceneData()) _cameraManipulator->setNode(getSceneData());
|
||||
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> dummyEvent = _eventQueue->createEvent();
|
||||
|
||||
_cameraManipulator->home(*dummyEvent, *this);
|
||||
if (resetPosition)
|
||||
{
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> dummyEvent = _eventQueue->createEvent();
|
||||
_cameraManipulator->home(*dummyEvent, *this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user