Added support for a -c option.
This commit is contained in:
@@ -15,10 +15,10 @@ int main( int argc, char **argv )
|
||||
{
|
||||
|
||||
// create the camera group.
|
||||
osgProducer::Viewer viewer;
|
||||
|
||||
// create the commandline args.
|
||||
std::string pathfile;
|
||||
std::string configfile;
|
||||
std::vector<std::string> commandLine;
|
||||
for(int i=1;i<argc;++i) {
|
||||
if( std::string(argv[i]) == "-p" ) {
|
||||
@@ -29,10 +29,23 @@ int main( int argc, char **argv )
|
||||
else
|
||||
pathfile = std::string(argv[++i]);
|
||||
}
|
||||
else
|
||||
if( std::string(argv[i]) == "-c" ) {
|
||||
if( (i+1) >= argc ) {
|
||||
std::cout << "path argument required for -c option."<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
configfile = std::string(argv[++i]);
|
||||
}
|
||||
else
|
||||
commandLine.push_back(argv[i]);
|
||||
}
|
||||
|
||||
osgProducer::Viewer* viewer = 0;
|
||||
if (!configfile.empty()) viewer = new osgProducer::Viewer(configfile);
|
||||
else viewer = new osgProducer::Viewer;
|
||||
|
||||
osg::DisplaySettings::instance()->readCommandLine(commandLine);
|
||||
osgDB::readCommandLine(commandLine);
|
||||
|
||||
@@ -47,37 +60,37 @@ int main( int argc, char **argv )
|
||||
|
||||
|
||||
// set up the value with sensible defaults.
|
||||
viewer.setUpViewer();
|
||||
viewer->setUpViewer();
|
||||
|
||||
if( !pathfile.empty() ) {
|
||||
osg::ref_ptr<osgGA::AnimationPathManipulator> apm = new osgGA::AnimationPathManipulator(pathfile);
|
||||
if( apm.valid() && apm->valid() )
|
||||
{
|
||||
unsigned int num = viewer.addCameraManipulator(apm.get());
|
||||
viewer.selectCameraManipulator(num);
|
||||
unsigned int num = viewer->addCameraManipulator(apm.get());
|
||||
viewer->selectCameraManipulator(num);
|
||||
}
|
||||
}
|
||||
|
||||
// set the scene to render
|
||||
viewer.setSceneData(loadedModel.get());
|
||||
viewer->setSceneData(loadedModel.get());
|
||||
|
||||
// set up the pthread stack size to large enough to run into problems.
|
||||
viewer.setStackSize( 20*1024*1024);
|
||||
viewer->setStackSize( 20*1024*1024);
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize(Producer::CameraGroup::ThreadPerCamera);
|
||||
viewer->realize(Producer::CameraGroup::ThreadPerCamera);
|
||||
|
||||
while( !viewer.done() )
|
||||
while( !viewer->done() )
|
||||
{
|
||||
// wait for all cull and draw threads to complete.
|
||||
viewer.sync();
|
||||
viewer->sync();
|
||||
|
||||
// update the scene by traversing it with the the update visitor which will
|
||||
// call all node update callbacks and animations.
|
||||
viewer.update();
|
||||
viewer->update();
|
||||
|
||||
// fire off the cull and draw traversals of the scene.
|
||||
viewer.frame();
|
||||
viewer->frame();
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user