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();