Changeset 5954 for OpenSceneGraph/trunk/examples/osgplanets/osgplanets.cpp
- Timestamp:
- 01/10/07 14:52:22 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgplanets/osgplanets.cpp
r5381 r5954 32 32 #include <osgGA/FlightManipulator> 33 33 #include <osgGA/DriveManipulator> 34 35 #include <osgProducer/Viewer> 34 #include <osgGA/KeySwitchMatrixManipulator> 35 36 #include <osgViewer/Viewer> 36 37 37 38 … … 583 584 584 585 // initialize the viewer. 585 osgProducer::Viewer viewer(arguments); 586 587 // set up the value with sensible default event handlers. 588 viewer.setUpViewer(osgProducer::Viewer::ESCAPE_SETS_DONE | osgProducer::Viewer::VIEWER_MANIPULATOR | osgProducer::Viewer::STATE_MANIPULATOR); 589 590 // get details on keyboard and mouse bindings used by the viewer. 591 viewer.getUsage(*arguments.getApplicationUsage()); 586 osgViewer::Viewer viewer; 587 588 osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; 589 viewer.setCameraManipulator( keyswitchManipulator.get() ); 592 590 593 591 SolarSystem solarSystem; … … 898 896 899 897 // set up tracker manipulators, once for each astral body 900 901 898 { 902 899 FindNamedNodeVisitor fnnv("Moon"); … … 911 908 tm->setTrackNode( fnnv._foundNodes.front().get() ); 912 909 913 unsigned int num = viewer.addCameraManipulator( tm ); 914 viewer.selectCameraManipulator( num ); 910 unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 911 keyswitchManipulator->addMatrixManipulator( 'm', "moon", tm ); 912 keyswitchManipulator->selectMatrixManipulator( num ); 915 913 } 916 914 } … … 928 926 tm->setTrackNode( fnnv._foundNodes.front().get() ); 929 927 930 unsigned int num = viewer.addCameraManipulator( tm ); 931 viewer.selectCameraManipulator( num ); 928 unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 929 keyswitchManipulator->addMatrixManipulator( 'e', "earth", tm); 930 keyswitchManipulator->selectMatrixManipulator( num ); 932 931 } 933 932 } … … 945 944 tm->setTrackNode( fnnv._foundNodes.front().get() ); 946 945 947 unsigned int num = viewer.addCameraManipulator( tm ); 948 viewer.selectCameraManipulator( num ); 946 unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 947 keyswitchManipulator->addMatrixManipulator( 's', "sun", tm); 948 keyswitchManipulator->selectMatrixManipulator( num ); 949 949 } 950 950 } 951 952 // create the windows and run the threads. 953 viewer.realize(); 954 955 while( !viewer.done() ) 956 { 957 // wait for all cull and draw threads to complete. 958 viewer.sync(); 959 960 // update the scene by traversing it with the the update visitor which will 961 // call all node update callbacks and animations. 962 viewer.update(); 963 964 // fire off the cull and draw traversals of the scene. 965 viewer.frame(); 966 967 } 968 969 970 // wait for all cull and draw threads to complete. 971 viewer.sync(); 972 973 // run a clean up frame to delete all OpenGL objects. 974 viewer.cleanup_frame(); 975 976 // wait for all the clean up frame to complete. 977 viewer.sync(); 978 979 return 0; 951 952 return viewer.run(); 953 980 954 }// end main 981 955
