From efbf05cd59d2e815e6c8ca862dccdd3986279382 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 12 Apr 2013 09:05:11 +0000 Subject: [PATCH] Moved keystone event handler onto the keystone distortion Camera. --- examples/osgkeystone/osgkeystone.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/osgkeystone/osgkeystone.cpp b/examples/osgkeystone/osgkeystone.cpp index 4e4a281ed..3c3a2689d 100644 --- a/examples/osgkeystone/osgkeystone.cpp +++ b/examples/osgkeystone/osgkeystone.cpp @@ -652,6 +652,8 @@ void setUpViewForKeystone(osgViewer::View* view, Keystone* keystone) camera->setName("DistortionCorrectionCamera"); + camera->addEventCallback(new KeystoneHandler(keystone)); + view->addSlave(camera.get(), osg::Matrixd(), osg::Matrixd(), false); } } @@ -663,8 +665,6 @@ int main( int argc, char **argv ) // initialize the viewer. osgViewer::Viewer viewer(arguments); - osg::ref_ptr keystone = new Keystone; - osg::ref_ptr model = osgDB::readNodeFiles(arguments); if (!model) @@ -673,10 +673,7 @@ int main( int argc, char **argv ) return 1; } - osg::ref_ptr group = new osg::Group; - group->addChild(model.get()); - - viewer.setSceneData(group.get()); + viewer.setSceneData(model.get()); // add the state manipulator viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); @@ -687,13 +684,10 @@ int main( int argc, char **argv ) // add camera manipulator viewer.setCameraManipulator(new osgGA::TrackballManipulator()); - setUpViewForKeystone(&viewer, keystone); + setUpViewForKeystone(&viewer, new Keystone); viewer.realize(); - // Add keystone handler - viewer.addEventHandler(new KeystoneHandler(keystone)); - while(!viewer.done()) { viewer.advance();