Show
Ignore:
Timestamp:
07/30/04 17:44:59 (10 years ago)
Author:
robert
Message:

Added beginnings of new TrackballManipulator?

Files:
1 modified

Legend:

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

    r3098 r3205  
    1919#include <osgParticle/ParticleSystemUpdater> 
    2020 
     21#include <osgGA/TrackerManipulator> 
     22 
    2123// for the grid data.. 
    2224#include "../osghangglide/terrain_coords.h" 
     
    6062    if (glider) 
    6163    { 
     64        glider->setName("glider"); 
     65 
    6266        const osg::BoundingSphere& bs = glider->getBound(); 
    6367 
     
    8286    if (cessna) 
    8387    { 
     88        cessna->setName("cessna"); 
     89     
    8490        const osg::BoundingSphere& bs = cessna->getBound(); 
    8591 
     
    246252} 
    247253 
     254class FindNamedNodeVisitor : public osg::NodeVisitor 
     255{ 
     256public: 
     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 
    248277 
    249278////////////////////////////////////////////////////////////////////////////// 
     
    268297    // set up the value with sensible default event handlers. 
    269298    viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
     299 
     300 
    270301 
    271302    // get details on keyboard and mouse bindings used by the viewer. 
     
    295326    viewer.setSceneData(root); 
    296327         
     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 
    297345    // create the windows and run the threads. 
    298346    viewer.realize();