Ported osgcopy, osgcubemap, osgdelaunay, osgdepthpartion, osgdistortion, osgfadetext, osgforest and osgfxbrowser to osgViewer

This commit is contained in:
Robert Osfield
2007-01-06 21:35:57 +00:00
parent 0cd64c8c4f
commit 19a7ec0f6b
33 changed files with 160 additions and 607 deletions

View File

@@ -23,7 +23,9 @@
#include <osgText/Text>
#include <osgProducer/Viewer>
#include <osgViewer/Viewer>
#include <iostream>
// for the grid data..
#include "../osghangglide/terrain_coords.h"
@@ -1069,76 +1071,20 @@ int main( int argc, char **argv )
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates the osg::Shape classes.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("--trees <number>","Set the number of trees to create");
// construct the viewer.
osgProducer::Viewer viewer(arguments);
osgViewer::Viewer viewer;
float numTreesToCreates = 10000;
arguments.read("--trees",numTreesToCreates);
// set up the value with sensible default event handlers.
viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
osg::ref_ptr<ForestTechniqueManager> ttm = new ForestTechniqueManager;
viewer.getEventHandlerList().push_front(new TechniqueEventHandler(ttm.get()));
// get details on keyboard and mouse bindings used by the viewer.
viewer.getUsage(*arguments.getApplicationUsage());
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
osg::Node* node = ttm->createScene((unsigned int)numTreesToCreates);
viewer.addEventHandler(new TechniqueEventHandler(ttm.get()));
// add model to viewer.
viewer.setSceneData( node );
viewer.setSceneData( ttm->createScene((unsigned int)numTreesToCreates) );
// create the windows and run the threads.
viewer.realize();
while( !viewer.done() )
{
// wait for all cull and draw threads to complete.
viewer.sync();
// update the scene by traversing it with the the update visitor which will
// call all node update callbacks and animations.
viewer.update();
// fire off the cull and draw traversals of the scene.
viewer.frame();
}
// wait for all cull and draw threads to complete.
viewer.sync();
// run a clean up frame to delete all OpenGL objects.
viewer.cleanup_frame();
// wait for all the clean up frame to complete.
viewer.sync();
return 0;
return viewer.run();
}