Show
Ignore:
Timestamp:
05/02/06 11:45:31 (8 years ago)
Author:
robert
Message:

Reorganised the Group::removeChild and Geode::removeDrawable methods so
that removeChild(Node*), removeChild(uint) and equivilant Geode methods are
now inline methods, not designed to be overriden, and seperated out the
multiple remove method to be called removeChildren(uint, uint) which is
now the only virtual method. There removeChildren is now the method to
override in subclasses.

This reorganisation requires some call code to be rename removeChild usage
to removeChildren.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgsimulation/osgsimulation.cpp

    r5076 r5122  
    2626#include <osg/MatrixTransform> 
    2727#include <osg/CoordinateSystemNode> 
    28 #include <osg/Shape> 
    29 #include <osg/PolygonMode> 
    3028 
    3129#include <osgDB/FileUtils> 
     
    313311 
    314312    osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(root.get()); 
    315     osg::Group * overlaySubGraph = new osg::Group; 
    316313    if (csn) 
    317314    { 
     
    319316        bool insertOverlayNode = true; 
    320317        osg::ref_ptr<osgSim::OverlayNode> overlayNode; 
    321         osg::Node* cessna = osgDB::readNodeFile("cessna.osg"); 
    322         double s = 200000.0 / cessna->getBound().radius(); 
    323  
    324318        if (insertOverlayNode) 
    325319        { 
     
    332326                overlayNode->addChild( csn->getChild(i) ); 
    333327            } 
    334             csn->removeChild(0, csn->getNumChildren()); 
     328 
     329            csn->removeChildren(0, csn->getNumChildren()); 
    335330            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()); 
    351331             
    352             geode->getOrCreateStateSet()->setAttributeAndModes(polymode.get(), osg::StateAttribute::ON); 
    353332            // tell the overlay node to continously update its overlay texture 
    354333            // as we know we'll be tracking a moving target. 
     
    357336         
    358337         
    359         //osg::Node* cessna = osgDB::readNodeFile("f15.ive"); 
     338        osg::Node* cessna = osgDB::readNodeFile("cessna.osg"); 
    360339        if (cessna) 
    361340        { 
     341            double s = 200000.0 / cessna->getBound().radius(); 
     342         
    362343            osg::MatrixTransform* scaler = new osg::MatrixTransform; 
    363344            scaler->addChild(cessna); 
     
    368349            mt->addChild(scaler); 
    369350 
     351 
    370352            if (!nc) nc = new ModelPositionCallback; 
    371353 
     
    373355 
    374356            csn->addChild(mt); 
    375  
    376             // if (overlaySubGraph) overlaySubGraph->addChild(mt); 
    377357             
    378358            // 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            } 
    379363 
    380364            osgGA::NodeTrackerManipulator* tm = new osgGA::NodeTrackerManipulator; 
     
    391375        } 
    392376         
    393         if (overlayNode.valid()) 
    394         { 
    395             // overlayNode->setOverlaySubgraph(overlaySubGraph); 
    396         } 
    397377    }     
    398378