- Timestamp:
- 07/30/04 17:44:59 (9 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgsimulation/osgsimulation.cpp
r3098 r3205 19 19 #include <osgParticle/ParticleSystemUpdater> 20 20 21 #include <osgGA/TrackerManipulator> 22 21 23 // for the grid data.. 22 24 #include "../osghangglide/terrain_coords.h" … … 60 62 if (glider) 61 63 { 64 glider->setName("glider"); 65 62 66 const osg::BoundingSphere& bs = glider->getBound(); 63 67 … … 82 86 if (cessna) 83 87 { 88 cessna->setName("cessna"); 89 84 90 const osg::BoundingSphere& bs = cessna->getBound(); 85 91 … … 246 252 } 247 253 254 class FindNamedNodeVisitor : public osg::NodeVisitor 255 { 256 public: 257 FindNamedNodeVisitor(const std::string& name): 258 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), 259 _name(name) {} 260 261 virtual void apply(osg::Node& node) 262 { 263 if (node.getName()==_name) 264 { 265 _foundNodes.push_back(&node); 266 } 267 traverse(node); 268 } 269 270 typedef std::vector< osg::ref_ptr<osg::Node> > NodeList; 271 272 std::string _name; 273 NodeList _foundNodes; 274 }; 275 276 248 277 249 278 ////////////////////////////////////////////////////////////////////////////// … … 268 297 // set up the value with sensible default event handlers. 269 298 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 299 300 270 301 271 302 // get details on keyboard and mouse bindings used by the viewer. … … 295 326 viewer.setSceneData(root); 296 327 328 329 FindNamedNodeVisitor fnnv("cessna"); 330 root->accept(fnnv); 331 332 if (!fnnv._foundNodes.empty()) 333 { 334 osgGA::TrackerManipulator* tm = new osgGA::TrackerManipulator; 335 tm->setTrackNode(fnnv._foundNodes[0].get()); 336 337 std::cout<<"Found "<<std::endl; 338 339 unsigned int num = viewer.addCameraManipulator(tm); 340 viewer.selectCameraManipulator(num); 341 } 342 343 344 297 345 // create the windows and run the threads. 298 346 viewer.realize();
