- Timestamp:
- 04/05/06 17:13:17 (7 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgsimulation/osgsimulation.cpp
r5007 r5076 26 26 #include <osg/MatrixTransform> 27 27 #include <osg/CoordinateSystemNode> 28 #include <osg/Shape> 29 #include <osg/PolygonMode> 28 30 29 31 #include <osgDB/FileUtils> … … 311 313 312 314 osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(root.get()); 315 osg::Group * overlaySubGraph = new osg::Group; 313 316 if (csn) 314 317 { … … 316 319 bool insertOverlayNode = true; 317 320 osg::ref_ptr<osgSim::OverlayNode> overlayNode; 321 osg::Node* cessna = osgDB::readNodeFile("cessna.osg"); 322 double s = 200000.0 / cessna->getBound().radius(); 323 318 324 if (insertOverlayNode) 319 325 { … … 326 332 overlayNode->addChild( csn->getChild(i) ); 327 333 } 328 329 334 csn->removeChild(0, csn->getNumChildren()); 330 335 csn->addChild(overlayNode.get()); 336 337 osg::ref_ptr<osg::PolygonMode> polymode = new osg::PolygonMode; 338 polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); 339 osg::NodeCallback* sphereCb = new ModelPositionCallback; 340 osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform; 341 mt->setUpdateCallback(sphereCb); 342 343 osg::ref_ptr<osg::Geode> geode = new osg::Geode; 344 osg::ref_ptr<osg::ShapeDrawable> sd; 345 sd = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),s)); 346 sd->setColor(osg::Vec4(1.0,0.0,0.0,1.0)); 347 geode->addDrawable(sd.get()); 348 349 mt->addChild(geode.get()); 350 overlaySubGraph->addChild(mt.get()); 331 351 352 geode->getOrCreateStateSet()->setAttributeAndModes(polymode.get(), osg::StateAttribute::ON); 332 353 // tell the overlay node to continously update its overlay texture 333 354 // as we know we'll be tracking a moving target. … … 336 357 337 358 338 osg::Node* cessna = osgDB::readNodeFile("cessna.osg");359 //osg::Node* cessna = osgDB::readNodeFile("f15.ive"); 339 360 if (cessna) 340 361 { 341 double s = 200000.0 / cessna->getBound().radius();342 343 362 osg::MatrixTransform* scaler = new osg::MatrixTransform; 344 363 scaler->addChild(cessna); … … 349 368 mt->addChild(scaler); 350 369 351 352 370 if (!nc) nc = new ModelPositionCallback; 353 371 … … 355 373 356 374 csn->addChild(mt); 375 376 // if (overlaySubGraph) overlaySubGraph->addChild(mt); 357 377 358 378 // if we are using an overaly node, use the cessna subgraph as the overlay subgraph 359 if (overlayNode.valid())360 {361 overlayNode->setOverlaySubgraph(mt);362 }363 379 364 380 osgGA::NodeTrackerManipulator* tm = new osgGA::NodeTrackerManipulator; … … 375 391 } 376 392 393 if (overlayNode.valid()) 394 { 395 // overlayNode->setOverlaySubgraph(overlaySubGraph); 396 } 377 397 } 378 398
