Improvements to the handling of warp pointer call on start up.
This commit is contained in:
parent
c6e3cb044b
commit
cac6642de5
@ -52,7 +52,7 @@ void GliderManipulator::home(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
|
|
||||||
us.requestRedraw();
|
us.requestRedraw();
|
||||||
|
|
||||||
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2,(ea.getYmin()+ea.getYmax())/2);
|
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2.0f,(ea.getYmin()+ea.getYmax())/2.0f);
|
||||||
|
|
||||||
flushMouseEventStack();
|
flushMouseEventStack();
|
||||||
|
|
||||||
@ -70,7 +70,10 @@ void GliderManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
const osg::BoundingSphere& boundingSphere=_node->getBound();
|
const osg::BoundingSphere& boundingSphere=_node->getBound();
|
||||||
_velocity = boundingSphere._radius*0.01f;
|
_velocity = boundingSphere._radius*0.01f;
|
||||||
|
|
||||||
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2,(ea.getYmin()+ea.getYmax())/2);
|
if (ea.getEventType()!=GUIEventAdapter::RESIZE)
|
||||||
|
{
|
||||||
|
us.requestWarpPointer((ea.getXmin()+ea.getXmax())/2.0f,(ea.getYmin()+ea.getYmax())/2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,18 +210,15 @@ bool GliderManipulator::calcMovement()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float mx = (_ga_t0->getXmin()+_ga_t0->getXmax())/2.0f;
|
float dx = _ga_t0->getXnormalized();
|
||||||
float my = (_ga_t0->getYmin()+_ga_t0->getYmax())/2.0f;
|
float dy = _ga_t0->getYnormalized();
|
||||||
|
|
||||||
float dx = _ga_t0->getX()-mx;
|
|
||||||
float dy = _ga_t0->getY()-my;
|
|
||||||
|
|
||||||
osg::Vec3 center = _camera->getEyePoint();
|
osg::Vec3 center = _camera->getEyePoint();
|
||||||
osg::Vec3 sv = _camera->getSideVector();
|
osg::Vec3 sv = _camera->getSideVector();
|
||||||
osg::Vec3 lv = _camera->getLookVector();
|
osg::Vec3 lv = _camera->getLookVector();
|
||||||
|
|
||||||
float pitch = inDegrees(dy*0.15f*dt);
|
float pitch = inDegrees(dy*70.0f*dt);
|
||||||
float roll = inDegrees(dx*0.1f*dt);
|
float roll = inDegrees(dx*60.0f*dt);
|
||||||
|
|
||||||
osg::Matrix mat;
|
osg::Matrix mat;
|
||||||
mat.makeTranslate(-center);
|
mat.makeTranslate(-center);
|
||||||
|
@ -76,9 +76,10 @@ class OSGPRODUCER_EXPORT KeyboardMouseCallback : public Producer::KeyboardMouseC
|
|||||||
Producer::KeyboardMouse* getKeyboardMouse() { return _keyboardMouse; }
|
Producer::KeyboardMouse* getKeyboardMouse() { return _keyboardMouse; }
|
||||||
const Producer::KeyboardMouse* getKeyboardMouse() const { return _keyboardMouse; }
|
const Producer::KeyboardMouse* getKeyboardMouse() const { return _keyboardMouse; }
|
||||||
|
|
||||||
|
EventAdapter* createEventAdapter();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
EventAdapter* createEventAdapter();
|
|
||||||
|
|
||||||
Producer::KeyboardMouse* _keyboardMouse;
|
Producer::KeyboardMouse* _keyboardMouse;
|
||||||
float _mx, _my;
|
float _mx, _my;
|
||||||
|
@ -132,8 +132,8 @@ void Viewer::setUpViewer(unsigned int options)
|
|||||||
_old_style_osg_camera = new osg::Camera;
|
_old_style_osg_camera = new osg::Camera;
|
||||||
|
|
||||||
if (options&TRACKBALL_MANIPULATOR) addCameraManipulator(new osgGA::TrackballManipulator);
|
if (options&TRACKBALL_MANIPULATOR) addCameraManipulator(new osgGA::TrackballManipulator);
|
||||||
if (options&FLIGHT_MANIPULATOR) addCameraManipulator(new osgGA::FlightManipulator);
|
|
||||||
if (options&DRIVE_MANIPULATOR) addCameraManipulator(new osgGA::DriveManipulator);
|
if (options&DRIVE_MANIPULATOR) addCameraManipulator(new osgGA::DriveManipulator);
|
||||||
|
if (options&FLIGHT_MANIPULATOR) addCameraManipulator(new osgGA::FlightManipulator);
|
||||||
|
|
||||||
if (options&STATE_MANIPULATOR)
|
if (options&STATE_MANIPULATOR)
|
||||||
{
|
{
|
||||||
@ -141,20 +141,7 @@ void Viewer::setUpViewer(unsigned int options)
|
|||||||
statesetManipulator->setStateSet(getGlobalStateSet());
|
statesetManipulator->setStateSet(getGlobalStateSet());
|
||||||
_eventHandlerList.push_back(statesetManipulator.get());
|
_eventHandlerList.push_back(statesetManipulator.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (options&STATS_MANIPULATOR)
|
|
||||||
// {
|
|
||||||
// // register the drawing of stats to pipe 0.
|
|
||||||
// FrameStatsHandler* fsh = new FrameStatsHandler;
|
|
||||||
// setStatsHandler(fsh);
|
|
||||||
// getCamera(0)->addPostDrawCallback(fsh);
|
|
||||||
//
|
|
||||||
// // register the event handler for stats.
|
|
||||||
// getEventHandlerList().push_back(new StatsEventHandler(this));
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (options&VIEWER_MANIPULATOR)
|
if (options&VIEWER_MANIPULATOR)
|
||||||
{
|
{
|
||||||
getEventHandlerList().push_back(new ViewerEventHandler(this));
|
getEventHandlerList().push_back(new ViewerEventHandler(this));
|
||||||
@ -192,7 +179,7 @@ void Viewer::realize( ThreadingModel thread_model)
|
|||||||
|
|
||||||
if (_keyswitchManipulator.valid() && _keyswitchManipulator->getCurrentCameraManipulator())
|
if (_keyswitchManipulator.valid() && _keyswitchManipulator->getCurrentCameraManipulator())
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osgProducer::EventAdapter> init_event = new osgProducer::EventAdapter;
|
osg::ref_ptr<osgProducer::EventAdapter> init_event = _kbmcb->createEventAdapter();
|
||||||
init_event->adaptFrame(0.0);
|
init_event->adaptFrame(0.0);
|
||||||
|
|
||||||
_keyswitchManipulator->setCamera(_old_style_osg_camera.get());
|
_keyswitchManipulator->setCamera(_old_style_osg_camera.get());
|
||||||
|
Loading…
Reference in New Issue
Block a user