Added support for Viewer::setViewer::setView so that the internal old
style osg::Camera and camera manipulators are updated correctly.
This commit is contained in:
parent
e928bca4c9
commit
8a3d731739
@ -145,7 +145,7 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
|
||||
/** Set the model view matrix of the camera group,
|
||||
* by individually set all the camera groups's camera.*/
|
||||
void setView(const osg::Matrix& matrix);
|
||||
virtual void setView(const osg::Matrix& matrix);
|
||||
|
||||
/** Get the model view martrix of the camera group,
|
||||
* taking its value for camera 0.*/
|
||||
|
@ -70,7 +70,12 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
|
||||
|
||||
void setUpViewer(unsigned int options=STANDARD_SETTINGS);
|
||||
|
||||
bool done() const { return _done; }
|
||||
/** 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);
|
||||
|
||||
/** Set the threading model and then call realize().*/
|
||||
virtual bool realize(ThreadingModel thread_model);
|
||||
|
@ -357,8 +357,8 @@ bool OsgCameraGroup::realize()
|
||||
getTopMostSceneData()->accept(sfpn);
|
||||
if (sfpn._foundParticles)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Warning: disabling multi-threading of cull and draw"<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<" to avoid threading problems in osgParticle."<<std::endl;
|
||||
osg::notify(osg::INFO)<<"Warning: disabling multi-threading of cull and draw"<<std::endl;
|
||||
osg::notify(osg::INFO)<<" to avoid threading problems in osgParticle."<<std::endl;
|
||||
_thread_model = Producer::CameraGroup::SingleThreaded;
|
||||
}
|
||||
}
|
||||
|
@ -172,6 +172,23 @@ unsigned int Viewer::addCameraManipulator(osgGA::CameraManipulator* cm)
|
||||
return num;
|
||||
}
|
||||
|
||||
bool Viewer::done() const
|
||||
{
|
||||
return _done;
|
||||
}
|
||||
|
||||
void Viewer::setView(const osg::Matrix& matrix)
|
||||
{
|
||||
OsgCameraGroup::setView(matrix);
|
||||
if (_keyswitchManipulator.valid() && _old_style_osg_camera.valid())
|
||||
{
|
||||
_old_style_osg_camera->home();
|
||||
_old_style_osg_camera->transformLookAt(matrix);
|
||||
osg::ref_ptr<osgProducer::EventAdapter> init_event = _kbmcb->createEventAdapter();
|
||||
_keyswitchManipulator->init(*init_event,*this);
|
||||
}
|
||||
}
|
||||
|
||||
bool Viewer::realize( ThreadingModel thread_model )
|
||||
{
|
||||
if( _realized ) return _realized;
|
||||
@ -194,7 +211,7 @@ bool Viewer::realize()
|
||||
{
|
||||
osg::ref_ptr<osgProducer::EventAdapter> init_event = _kbmcb->createEventAdapter();
|
||||
init_event->adaptFrame(0.0);
|
||||
|
||||
|
||||
_keyswitchManipulator->setCamera(_old_style_osg_camera.get());
|
||||
_keyswitchManipulator->setNode(getSceneDecorator());
|
||||
_keyswitchManipulator->home(*init_event,*this);
|
||||
@ -256,7 +273,7 @@ void Viewer::update()
|
||||
}
|
||||
|
||||
// update the main producer camera
|
||||
if (_old_style_osg_camera.valid()) setView(_old_style_osg_camera->getModelViewMatrix());
|
||||
if (_old_style_osg_camera.valid()) OsgCameraGroup::setView(_old_style_osg_camera->getModelViewMatrix());
|
||||
}
|
||||
|
||||
void Viewer::frame()
|
||||
@ -282,15 +299,13 @@ void Viewer::selectCameraManipulator(unsigned int no)
|
||||
|
||||
void Viewer::requestWarpPointer(float x,float y)
|
||||
{
|
||||
|
||||
if (_kbmcb)
|
||||
{
|
||||
EventAdapter::_s_mx = x;
|
||||
EventAdapter::_s_my = y;
|
||||
_kbmcb->getKeyboardMouse()->positionPointer(x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::getUsage(osg::ApplicationUsage& usage) const
|
||||
|
Loading…
Reference in New Issue
Block a user