Moved keystone event handler onto the keystone distortion Camera.

This commit is contained in:
Robert Osfield 2013-04-12 09:05:11 +00:00
parent 835a80ae90
commit efbf05cd59

View File

@ -652,6 +652,8 @@ void setUpViewForKeystone(osgViewer::View* view, Keystone* keystone)
camera->setName("DistortionCorrectionCamera"); camera->setName("DistortionCorrectionCamera");
camera->addEventCallback(new KeystoneHandler(keystone));
view->addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false); view->addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false);
} }
} }
@ -663,8 +665,6 @@ int main( int argc, char **argv )
// initialize the viewer. // initialize the viewer.
osgViewer::Viewer viewer(arguments); osgViewer::Viewer viewer(arguments);
osg::ref_ptr<Keystone> keystone = new Keystone;
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments); osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
if (!model) if (!model)
@ -673,10 +673,7 @@ int main( int argc, char **argv )
return 1; return 1;
} }
osg::ref_ptr<osg::Group> group = new osg::Group; viewer.setSceneData(model.get());
group->addChild(model.get());
viewer.setSceneData(group.get());
// add the state manipulator // add the state manipulator
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
@ -687,13 +684,10 @@ int main( int argc, char **argv )
// add camera manipulator // add camera manipulator
viewer.setCameraManipulator(new osgGA::TrackballManipulator()); viewer.setCameraManipulator(new osgGA::TrackballManipulator());
setUpViewForKeystone(&viewer, keystone); setUpViewForKeystone(&viewer, new Keystone);
viewer.realize(); viewer.realize();
// Add keystone handler
viewer.addEventHandler(new KeystoneHandler(keystone));
while(!viewer.done()) while(!viewer.done())
{ {
viewer.advance(); viewer.advance();