From ca0ff266e2314df11bfd05664dac5b8213c74d6b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 19 Mar 2003 15:49:21 +0000 Subject: [PATCH] First pass fix at implementing requestWarpPointer. --- include/osgProducer/EventAdapter | 2 ++ src/osgProducer/KeyboardMouseCallback.cpp | 1 - src/osgProducer/Viewer.cpp | 37 ++++++++++++++++++++--- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/include/osgProducer/EventAdapter b/include/osgProducer/EventAdapter index 75eecb14a..91f850f86 100644 --- a/include/osgProducer/EventAdapter +++ b/include/osgProducer/EventAdapter @@ -107,6 +107,8 @@ class OSGPRODUCER_EXPORT EventAdapter : public osgGA::GUIEventAdapter unsigned int _modKeyMask; double _time; + public: + // used to accumulate the button mask state, it represents // the current button mask state, which is modified by the // adaptMouse() method which then copies it to value _buttonMask diff --git a/src/osgProducer/KeyboardMouseCallback.cpp b/src/osgProducer/KeyboardMouseCallback.cpp index 7b8102dbd..67c87eed4 100644 --- a/src/osgProducer/KeyboardMouseCallback.cpp +++ b/src/osgProducer/KeyboardMouseCallback.cpp @@ -53,7 +53,6 @@ void KeyboardMouseCallback::mouseMotion( float mx, float my) _mx = mx; _my = my; - osg::ref_ptr event = new EventAdapter; event->adaptMouseMotion(getTime(),mx,my); diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index 2f8dc3ce0..0149f5ae9 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -182,6 +182,14 @@ unsigned int Viewer::addCameraManipulator(osgGA::CameraManipulator* cm) void Viewer::realize( ThreadingModel thread_model) { + + OsgCameraGroup::realize( thread_model ); + + // force a sync before we intialize the keyswitch manipulator to home + // so that Producer has a chance to set up the windows before we do + // any work on them. + OsgCameraGroup::sync(); + if (_keyswitchManipulator.valid() && _keyswitchManipulator->getCurrentCameraManipulator()) { osg::ref_ptr init_event = new osgProducer::EventAdapter; @@ -191,15 +199,14 @@ void Viewer::realize( ThreadingModel thread_model) _keyswitchManipulator->setNode(getSceneDecorator()); _keyswitchManipulator->home(*init_event,*this); } - - OsgCameraGroup::realize( thread_model ); - // set up osg::State objects with a the _done prt to allow early termination of + // set up osg::State objects with the _done prt to allow early termination of // draw traversal. for(SceneHandlerList::iterator p=_shvec.begin(); p!=_shvec.end(); p++ ) { (*p)->getState()->setAbortRenderingPtr(&_done); } + OsgCameraGroup::sync(); } @@ -258,7 +265,29 @@ void Viewer::selectCameraManipulator(unsigned int no) void Viewer::requestWarpPointer(int x,int y) { - osg::notify(osg::WARN) << "Warning: requestWarpPointer("<getNumberOfCameras(); i++ ) + { + Producer::Camera* cam = _cfg->getCamera(i); + rs = cam->getRenderSurface(); + } + + if (rs) + { + EventAdapter::_s_mx = x; + EventAdapter::_s_my = y; + rs->positionPointer(x,y); + } + else + { + osg::notify(osg::WARN) << "Warning: requestWarpPointer("<