Show
Ignore:
Timestamp:
09/02/05 22:06:11 (9 years ago)
Author:
robert
Message:

Added commandline arguments for controlling number of cameras through to the windowing library to use.

Files:
1 modified

Legend:

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

    r4493 r4494  
    121121int main( int argc, char **argv ) 
    122122{ 
    123  
    124     if (argc<2)  
    125     { 
    126         std::cout << argv[0] <<": requires filename argument." << std::endl; 
    127         return 1; 
    128     } 
     123    // use an ArgumentParser object to manage the program arguments. 
     124    osg::ArgumentParser arguments(&argc,argv); 
     125 
     126    std::string windowingLibrary("osgProducer"); 
     127    while (arguments.read("--windowing",windowingLibrary)) {} 
    129128 
    130129    // load the osgProducer library manually. 
    131     osg::ref_ptr<osgDB::DynamicLibrary> osgProducerLib = 
    132             osgDB::DynamicLibrary::loadLibrary(osgDB::Registry::instance()->createLibraryNameForNodeKit("osgProducer")); 
    133  
    134  
    135     // load the scene. 
    136     osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(argv[1]); 
    137     if (!loadedModel)  
    138     { 
    139         std::cout << argv[0] <<": No data loaded." << std::endl; 
    140         return 1; 
    141     } 
    142  
    143      
    144     // set up the frame stamp for current frame to record the current time and frame number so that animtion code can advance correctly 
    145     osg::ref_ptr<osg::FrameStamp> frameStamp = new osg::FrameStamp; 
    146  
    147     unsigned int frameNum = 0; 
    148  
    149     osgUtil::UpdateVisitor updateVisitor; 
    150     updateVisitor.setFrameStamp(frameStamp.get()); 
    151  
     130    osg::ref_ptr<osgDB::DynamicLibrary> windowingLib = 
     131            osgDB::DynamicLibrary::loadLibrary(osgDB::Registry::instance()->createLibraryNameForNodeKit(windowingLibrary)); 
     132 
     133 
     134    if (!windowingLib) 
     135    { 
     136        std::cout<<"Error: failed to loading windowing library: "<<windowingLibrary<<std::endl; 
     137    } 
    152138 
    153139    unsigned int numberCameras = 3; 
     140    while (arguments.read("--cameras",numberCameras)) {} 
     141 
    154142    unsigned int xpos = 0; 
    155143    unsigned int ypos = 400; 
    156144    unsigned int width = 400; 
    157145    unsigned int height = 400; 
     146 
     147    while (arguments.read("--xpos",xpos)) {} 
     148    while (arguments.read("--ypos",ypos)) {} 
     149    while (arguments.read("--height",height)) {} 
     150    while (arguments.read("--width",width)) {} 
     151 
     152    unsigned int maxNumFrames = 1000; 
     153    while (arguments.read("--max-num-frames",maxNumFrames)) {} 
     154 
     155    // load the scene. 
     156    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); 
     157    if (!loadedModel)  
     158    { 
     159        std::cout << argv[0] <<": No data loaded." << std::endl; 
     160        return 1; 
     161    } 
     162 
     163     
     164    // set up the frame stamp for current frame to record the current time and frame number so that animtion code can advance correctly 
     165    osg::ref_ptr<osg::FrameStamp> frameStamp = new osg::FrameStamp; 
     166 
     167    unsigned int frameNum = 0; 
     168 
     169    osgUtil::UpdateVisitor updateVisitor; 
     170    updateVisitor.setFrameStamp(frameStamp.get()); 
    158171     
    159172    typedef std::list< osg::ref_ptr<osg::CameraNode> > CameraList; 
     
    310323     
    311324    bool done = false; 
    312     unsigned int maxNumFrames = 50; 
    313325 
    314326    // main loop -  update scene graph, dispatch frame, wait for frame done. 
     
    344356 
    345357    } 
    346  
    347     // delete the cameras, associated contexts and threads. 
    348     cameraList.clear(); 
    349358     
    350359    std::cout<<"Exiting application"<<std::endl;