Ported all glut based demos across to using the new osg::ArgumentParser.

This commit is contained in:
Robert Osfield 2003-03-14 10:49:06 +00:00
parent 34fc7dd289
commit 2ca505b3d8
43 changed files with 873 additions and 1373 deletions

View File

@ -111,7 +111,6 @@ DEMOS_DIRS = \
osggeometry\ osggeometry\
osghangglide\ osghangglide\
osghud\ osghud\
osgtext\
osgimpostor\ osgimpostor\
osglight\ osglight\
osglightpoint\ osglightpoint\
@ -120,13 +119,14 @@ DEMOS_DIRS = \
osgoccluder\ osgoccluder\
osgparticle\ osgparticle\
osgprerender\ osgprerender\
osgshadowtexture\
osgreflect\ osgreflect\
osgscribe\ osgscribe\
osgsequence\ osgsequence\
osgshadowtexture\
osgshape\ osgshape\
osgstereoimage\ osgstereoimage\
osgteapot\ osgteapot\
osgtext\
osgtexture1D\ osgtexture1D\
osgtexture2D\ osgtexture2D\
osgtexture3D\ osgtexture3D\

View File

@ -3,6 +3,12 @@
OSG News (most significant items from ChangeLog) OSG News (most significant items from ChangeLog)
================================================ ================================================
Improvemnts to the Makefle system.
Added support for early abort of rendering, useful for interactive
applications which occasional have rendering that takes that long
enough (i.e. several second) that end users may wish to abort
during the drawing.
Improved thread safety when working multipipe systems. Improved thread safety when working multipipe systems.
@ -10,7 +16,7 @@ OSG News (most significant items from ChangeLog)
New MD2 plugin New MD2 plugin
New osgText implementions. New thread safe osgText implemention.
24th January 2003 - OpenSceneGraph-0.9.3.tar.gz 24th January 2003 - OpenSceneGraph-0.9.3.tar.gz

View File

@ -42,11 +42,11 @@ class SG_EXPORT DisplaySettings : public osg::Referenced
readEnvironmentalVariables(); readEnvironmentalVariables();
} }
DisplaySettings(std::vector<std::string>& commandLine) DisplaySettings(ArgumentParser& arguments)
{ {
setDefaults(); setDefaults();
readEnvironmentalVariables(); readEnvironmentalVariables();
readCommandLine(commandLine); readCommandLine(arguments);
} }
DisplaySettings(const DisplaySettings& vs); DisplaySettings(const DisplaySettings& vs);
@ -61,12 +61,8 @@ class SG_EXPORT DisplaySettings : public osg::Referenced
void readEnvironmentalVariables(); void readEnvironmentalVariables();
/** read the command line string list, removing any matched control sequences.*/
void readCommandLine(std::vector<std::string>& commandLine);
/** read the commandline arguments.*/ /** read the commandline arguments.*/
void readCommandLine(ArgumentParser& parser); void readCommandLine(ArgumentParser& arguments);
void setStereo(bool on) { _stereo = on; } void setStereo(bool on) { _stereo = on; }

View File

@ -51,9 +51,6 @@ class OSGDB_EXPORT Registry : public osg::Referenced
static Registry* instance(); static Registry* instance();
/** read the command line string list, removing any matched control sequences.*/
void readCommandLine(std::vector<std::string>& commandLine);
/** read the command line arguments.*/ /** read the command line arguments.*/
void readCommandLine(osg::ArgumentParser& commandLine); void readCommandLine(osg::ArgumentParser& commandLine);
@ -201,12 +198,6 @@ class OSGDB_EXPORT Registry : public osg::Referenced
}; };
/** read the command line string list into the osgDB::Registry(), removing any matched control sequences.*/
inline void readCommandLine(std::vector<std::string>& commandLine)
{
Registry::instance()->readCommandLine(commandLine);
}
/** read the command line arguments.*/ /** read the command line arguments.*/
inline void readCommandLine(osg::ArgumentParser& parser) inline void readCommandLine(osg::ArgumentParser& parser)
{ {

View File

@ -19,6 +19,7 @@
#include <osg/Geode> #include <osg/Geode>
#include <osg/Timer> #include <osg/Timer>
#include <osg/DisplaySettings> #include <osg/DisplaySettings>
#include <osg/ArgumentParser>
#include <osgGA/GUIEventAdapter> #include <osgGA/GUIEventAdapter>
#include <osgGA/CameraManipulator> #include <osgGA/CameraManipulator>
@ -46,8 +47,13 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
public: public:
Viewer(); Viewer();
Viewer(osg::ArgumentParser& arguments);
virtual ~Viewer(); virtual ~Viewer();
/** read the command line string list, removing any matched control sequences.*/
void readCommandLine(osg::ArgumentParser& arguments);
/** init is deprecated, you should use addViewport instead. init is /** init is deprecated, you should use addViewport instead. init is
* only available for backwards compatibility.*/ * only available for backwards compatibility.*/
virtual void init(osg::Node* rootnode); virtual void init(osg::Node* rootnode);
@ -108,8 +114,6 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
/// Toggle fullscreen /// Toggle fullscreen
virtual void toggleFullScreen(); virtual void toggleFullScreen();
/** read the command line string list, removing any matched control sequences.*/
void readCommandLine(std::vector<std::string>& commandLine);
void setDisplaySettings(osg::DisplaySettings* ds) { _displaySettings = ds; } void setDisplaySettings(osg::DisplaySettings* ds) { _displaySettings = ds; }
osg::DisplaySettings* getDisplaySettings() { return _displaySettings.get(); } osg::DisplaySettings* getDisplaySettings() { return _displaySettings.get(); }
@ -129,6 +133,8 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
int mapWindowXYToViewport(int x, int y); int mapWindowXYToViewport(int x, int y);
protected: protected:
void initialize();
virtual void clear(); virtual void clear();

View File

@ -12,8 +12,6 @@
#include <osgGA/FlightManipulator> #include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator> #include <osgGA/DriveManipulator>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
@ -190,26 +188,32 @@ osg::Node* createModel()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT // set up the usage document, in case we need to print out how to use this program.
glutInit( &argc, argv ); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* model = createModel(); osg::Node* model = createModel();

View File

@ -165,25 +165,32 @@ osg::Node* createModel()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// create a model from the images. // create a model from the images.
osg::Node* rootNode = createModel(); osg::Node* rootNode = createModel();

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osg/Transform> #include <osg/Transform>
@ -15,39 +13,8 @@
#include <osgGA/FlightManipulator> #include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator> #include <osgGA/DriveManipulator>
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
class UpdateCallback : public osg::NodeCallback class UpdateCallback : public osg::NodeCallback
{ {
@ -161,35 +128,35 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT // set up the usage document, in case we need to print out how to use this program.
glutInit( &argc, argv ); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)
{ {
// write_usage(osg::notify(osg::NOTICE),argv[0]); // write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -17,7 +17,6 @@
#include <osgGA/DriveManipulator> #include <osgGA/DriveManipulator>
#include <osgUtil/TransformCallback> #include <osgUtil/TransformCallback>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
@ -128,34 +127,35 @@ osg::Node* decorate_with_clip_node(osg::Node* subgraph)
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// if user request help write it out to cout.
// configure the viewer from the commandline arguments, and eat any if (arguments.read("-h") || arguments.read("--help"))
// parameters that have been matched. {
viewer.readCommandLine(commandLine); arguments.getApplicationUsage()->write(std::cout);
return 1;
// configure the plugin registry from the commandline arguments, and }
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine); // 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel) if (!loadedModel)
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]); write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -18,40 +18,8 @@
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
using namespace osg; using namespace osg;
// Customize the CopyOp so that we add our own verbose // Customize the CopyOp so that we add our own verbose
// output of what's being copied. // output of what's being copied.
class MyCopyOp : public osg::CopyOp class MyCopyOp : public osg::CopyOp
@ -166,38 +134,37 @@ class MyCopyOp : public osg::CopyOp
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT // set up the usage document, in case we need to print out how to use this program.
glutInit( &argc, argv ); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
if (argc<2)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// if user request help write it out to cout.
// configure the viewer from the commandline arguments, and eat any if (arguments.read("-h") || arguments.read("--help"))
// parameters that have been matched. {
viewer.readCommandLine(commandLine); arguments.getApplicationUsage()->write(std::cout);
return 1;
// configure the plugin registry from the commandline arguments, and }
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine); // 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 1; return 1;
} }

View File

@ -7,7 +7,6 @@
#include <osgGA/TrackballManipulator> #include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <osg/Math> #include <osg/Math>
@ -160,23 +159,33 @@ osg::Geode* createGeometryCube()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
glutInit( &argc, argv ); // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the commandline args. // if user request help write it out to cout.
std::vector<std::string> commandLine; if (arguments.read("-h") || arguments.read("--help"))
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]); {
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// create the viewer and the model to it. // any option left unread are converted into errors to write out later.
osgGLUT::Viewer viewer; arguments.reportRemainingOptionsAsUnrecognized();
viewer.setWindowTitle(argv[0]); // report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
// configure the viewer from the commandline arguments, and eat any arguments.writeErrorMessages(std::cout);
// parameters that have been matched. return 1;
viewer.readCommandLine(commandLine); }
osg::MatrixTransform* myTransform = new osg::MatrixTransform(); osg::MatrixTransform* myTransform = new osg::MatrixTransform();
myTransform->addChild( createGeometryCube() ); myTransform->addChild( createGeometryCube() );

View File

@ -17,44 +17,11 @@
#include <osgGA/DriveManipulator> #include <osgGA/DriveManipulator>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector> #include <vector>
void write_usage(std::ostream& out, const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out <<" -f - start with a full screen, borderless window." << std::endl;
out << std::endl;
}
void create_specular_highlights(osg::Node *node) void create_specular_highlights(osg::Node *node)
{ {
osg::StateSet *ss = node->getOrCreateStateSet(); osg::StateSet *ss = node->getOrCreateStateSet();
@ -103,32 +70,35 @@ void create_specular_highlights(osg::Node *node)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2) {
write_usage(std::cout, argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1; i<argc; ++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) { if (!rootnode) {
return 1; return 1;
} }

View File

@ -26,41 +26,6 @@
// geo loader and having direct links with it. // geo loader and having direct links with it.
#include "../../osgPlugins/geo/osgGeoAnimation.h" #include "../../osgPlugins/geo/osgGeoAnimation.h"
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out <<" -f - start with a full screen, borderless window." << std::endl;
out <<" -p pathfile - Use the AnimationPathManipulator (key binding '4') and use\n"
" pathfile to define the animation path. pathfile is an ascii\n"
" file containing lines of eight floating point numbers representing\n"
" time, position (x,y,z) and attitude (x,y,z,w as a quaternion)." << std::endl;
out << std::endl;
}
//== event trapper gets events //== event trapper gets events
@ -122,63 +87,46 @@ double dodynamics(const double time, const double val, const std::string name)
int main( int argc, char **argv ) 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","Use specificed animation path file for camera animation");
// read the commandline args.
std::string pathfile; std::string pathfile;
while (arguments.read("-p",pathfile)) {}
float camera_fov=-1; float camera_fov=-1;
while (arguments.read("-fov",camera_fov)) {}
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) {
if( std::string(argv[i]) == "-p" ) {
if( (i+1) >= argc ) {
write_usage( std::cout, argv[0]);
return 1;
}
else
pathfile = std::string(argv[++i]);
} else if( std::string(argv[i]) == "-fov" ) {
camera_fov=atof(argv[i+1]);
++i; // skip the value
}
else
commandLine.push_back(argv[i]);
}
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
// get the path of the executable and use it to set internal data and library paths.
std::string executablePath = osgDB::getFilePath(argv[0]);
if (!executablePath.empty())
{ {
osg::notify(osg::NOTICE) << "Adding executable path '"<<executablePath<<"' to OpenSceneGraph data and library file paths."<<std::endl; arguments.getApplicationUsage()->write(std::cout);
osgDB::getDataFilePathList().push_front(executablePath); return 1;
osgDB::getLibraryFilePathList().push_front(executablePath); }
// 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;
} }
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 1; return 1;
} }

View File

@ -13,7 +13,6 @@
#include <osgGA/TrackballManipulator> #include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <osg/Math> #include <osg/Math>
@ -643,20 +642,32 @@ osg::Node* createBackground()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
glutInit( &argc, argv ); // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// create the commandline args. // initialize the viewer.
std::vector<std::string> commandLine; osgGLUT::Viewer viewer(arguments);
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// create the viewer and the model to it. // if user request help write it out to cout.
osgGLUT::Viewer viewer; if (arguments.read("-h") || arguments.read("--help"))
viewer.setWindowTitle(argv[0]); {
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// configure the viewer from the commandline arguments, and eat any // any option left unread are converted into errors to write out later.
// parameters that have been matched. arguments.reportRemainingOptionsAsUnrecognized();
viewer.readCommandLine(commandLine);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// create the model // create the model

View File

@ -12,7 +12,6 @@
#include <osgGA/AnimationPathManipulator> #include <osgGA/AnimationPathManipulator>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include "GliderManipulator.h" #include "GliderManipulator.h"
@ -104,26 +103,36 @@ osg::Group* createModel()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
glutInit( &argc, argv );
// create the commandline args. // use an ArgumentParser object to manage the program arguments.
std::vector<std::string> commandLine; osg::ArgumentParser arguments(&argc,argv);
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// if user request help write it out to cout.
// configure the viewer from the commandline arguments, and eat any if (arguments.read("-h") || arguments.read("--help"))
// parameters that have been matched. {
viewer.readCommandLine(commandLine); arguments.getApplicationUsage()->write(std::cout);
return 1;
// configure the plugin registry from the commandline arguments, and }
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine); // 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) rootnode = createModel(); if (!rootnode) rootnode = createModel();
viewer.addViewport( rootnode ); viewer.addViewport( rootnode );

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osg/MatrixTransform> #include <osg/MatrixTransform>
@ -24,37 +22,6 @@
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
osg::Node* createHUD() osg::Node* createHUD()
{ {
osg::Geode* geode = new osg::Geode(); osg::Geode* geode = new osg::Geode();
@ -159,35 +126,36 @@ struct MyCallback : public osg::NodeCallback
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT // set up the usage document, in case we need to print out how to use this program.
glutInit( &argc, argv ); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// 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;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)
{ {
// write_usage(osg::notify(osg::NOTICE),argv[0]); // write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -225,11 +225,11 @@ int main( int argc, char **argv )
viewer.setWindowTitle(argv[0]); viewer.setWindowTitle(argv[0]);
// create the commandline args. // create the commandline args.
std::vector<std::string> commandLine; std::vector<std::string> arguments;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]); for(int i=1;i<argc;++i) arguments.push_back(argv[i]);
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* model = osgDB::readNodeFiles(commandLine); osg::Node* model = osgDB::readNodeFiles(arguments);
if (model) if (model)
{ {
// the osgUtil::InsertImpostorsVisitor used lower down to insert impostors // the osgUtil::InsertImpostorsVisitor used lower down to insert impostors

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osg/Group> #include <osg/Group>
@ -301,29 +299,36 @@ osg::Node* createRoom(osg::Node* loadedModel)
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT // set up the usage document, in case we need to print out how to use this program.
glutInit( &argc, argv ); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// 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;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
// create a room made of foor walls, a floor, a roof, and swinging light fitting. // create a room made of foor walls, a floor, a roof, and swinging light fitting.
osg::Node* rootnode = createRoom(loadedModel); osg::Node* rootnode = createRoom(loadedModel);

View File

@ -20,37 +20,6 @@
#include <osgSim/LightPointNode> #include <osgSim/LightPointNode>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
#define INTERPOLATE(member) lp.member = start.member*rstart + end.member*rend; #define INTERPOLATE(member) lp.member = start.member*rstart + end.member*rend;
void addToLightPointNode(osgSim::LightPointNode& lpn,osgSim::LightPoint& start,osgSim::LightPoint& end,unsigned int noSteps) void addToLightPointNode(osgSim::LightPointNode& lpn,osgSim::LightPoint& start,osgSim::LightPoint& end,unsigned int noSteps)
@ -149,30 +118,38 @@ osg::Node* createLightPointsDatabase()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
// create the commandline args. // set up the usage document, in case we need to print out how to use this program.
std::vector<std::string> commandLine; arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// 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;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
osg::Group* rootnode = new osg::Group; osg::Group* rootnode = new osg::Group;
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
rootnode->addChild(osgDB::readNodeFiles(commandLine)); rootnode->addChild(osgDB::readNodeFiles(arguments));
rootnode->addChild(createLightPointsDatabase()); rootnode->addChild(createLightPointsDatabase());
if (!rootnode) if (!rootnode)
{ {

View File

@ -17,7 +17,6 @@
#include <osgGA/TrackballManipulator> #include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
@ -404,24 +403,35 @@ osg::Node* createLogo()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
glutInit( &argc, argv ); // use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// create the commandline args. // set up the usage document, in case we need to print out how to use this program.
std::vector<std::string> commandLine; arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("ps","Render the Professional Services logo");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the viewer and the model to it. // if user request help write it out to cout.
osgGLUT::Viewer viewer; if (arguments.read("-h") || arguments.read("--help"))
{
viewer.setWindowTitle(argv[0]); arguments.getApplicationUsage()->write(std::cout);
return 1;
}
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
if (arguments.find("ps")) s_ProfessionalServices = true;
if (std::find(commandLine.begin(),commandLine.end(),std::string("ps"))!=commandLine.end()) s_ProfessionalServices = true; // 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 = createLogo(); osg::Node* node = createLogo();

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osg/Notify> #include <osg/Notify>
@ -15,72 +13,40 @@
#include <osgGA/FlightManipulator> #include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator> #include <osgGA/DriveManipulator>
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT // set up the usage document, in case we need to print out how to use this program.
glutInit( &argc, argv ); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)
{ {
// write_usage(osg::notify(osg::NOTICE),argv[0]); // write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -1,5 +1,3 @@
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osg/MatrixTransform> #include <osg/MatrixTransform>
@ -23,45 +21,6 @@
#include <osg/OccluderNode> #include <osg/OccluderNode>
#include <osg/Geometry> #include <osg/Geometry>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -c - set osgoccluder's manual mode for creating occluders."<< std::endl;
out <<" press 'a' to start/add points to an occluder, using "<< std::endl;
out <<" the nearest vertex to the current mouse poistion."<< std::endl;
out <<" press 'e' to end occluder, this occluder is then added"<< std::endl;
out <<" into the model."<< std::endl;
out <<" press 'O' save just the occluders to disk. "<< std::endl;
out << std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
class OccluderEventHandler : public osgGA::GUIEventHandler class OccluderEventHandler : public osgGA::GUIEventHandler
{ {
@ -320,42 +279,39 @@ osg::Group* createOccludersAroundModel(osg::Node* model)
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
bool manuallyCreateImpostors = false;
std::vector<std::string>::iterator itr=std::find(commandLine.begin(),commandLine.end(),std::string("-c"));
if (itr!=commandLine.end())
{
manuallyCreateImpostors = true;
commandLine.erase(itr);
}
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-c","Mannually create occluders");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any bool manuallyCreateOccluders = false;
// parameters that have been matched. while (arguments.read("-c")) { manuallyCreateOccluders = true; }
viewer.readCommandLine(commandLine);
// if user request help write it out to cout.
// configure the plugin registry from the commandline arguments, and if (arguments.read("-h") || arguments.read("--help"))
// eat any parameters that have been matched. {
osgDB::readCommandLine(commandLine); 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedmodel = osgDB::readNodeFiles(commandLine); osg::Node* loadedmodel = osgDB::readNodeFiles(arguments);
if (!loadedmodel) if (!loadedmodel)
{ {
// write_usage(osg::notify(osg::NOTICE),argv[0]); // write_usage(osg::notify(osg::NOTICE),argv[0]);
@ -369,7 +325,7 @@ int main( int argc, char **argv )
// add the occluders to the loaded model. // add the occluders to the loaded model.
osg::Group* rootnode = NULL; osg::Group* rootnode = NULL;
if (manuallyCreateImpostors) if (manuallyCreateOccluders)
{ {
rootnode = new osg::Group; rootnode = new osg::Group;
rootnode->addChild(loadedmodel); rootnode->addChild(loadedmodel);
@ -388,7 +344,7 @@ int main( int argc, char **argv )
viewer.registerCameraManipulator(new osgGA::FlightManipulator); viewer.registerCameraManipulator(new osgGA::FlightManipulator);
viewer.registerCameraManipulator(new osgGA::DriveManipulator); viewer.registerCameraManipulator(new osgGA::DriveManipulator);
if (manuallyCreateImpostors) if (manuallyCreateOccluders)
{ {
viewer.prependEventHandler(new OccluderEventHandler(viewer.getViewportSceneView(0),rootnode)); viewer.prependEventHandler(new OccluderEventHandler(viewer.getViewportSceneView(0),rootnode));
} }

View File

@ -601,8 +601,8 @@ int main( int argc, char **argv )
} }
// create the commandline args. // create the commandline args.
std::vector<std::string> commandLine; std::vector<std::string> arguments;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]); for(int i=1;i<argc;++i) arguments.push_back(argv[i]);
// initialize the viewer. // initialize the viewer.
@ -611,14 +611,14 @@ int main( int argc, char **argv )
// configure the viewer from the commandline arguments, and eat any // configure the viewer from the commandline arguments, and eat any
// parameters that have been matched. // parameters that have been matched.
viewer.readCommandLine(commandLine); viewer.readCommandLine(arguments);
// configure the plugin registry from the commandline arguments, and // configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched. // eat any parameters that have been matched.
osgDB::readCommandLine(commandLine); osgDB::readCommandLine(arguments);
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel) if (!loadedModel)

View File

@ -21,7 +21,6 @@
#include <osgDB/Registry> #include <osgDB/Registry>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
class MyUpdateCallback : public osg::NodeCallback class MyUpdateCallback : public osg::NodeCallback
@ -364,70 +363,38 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph)
return parent; return parent;
} }
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// initialize the GLUT // set up the usage document, in case we need to print out how to use this program.
glutInit( &argc, argv ); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
if (argc<2) // if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]); arguments.getApplicationUsage()->write(std::cout);
return 0; return 1;
} }
// create the commandline args. // any option left unread are converted into errors to write out later.
std::vector<std::string> commandLine; arguments.reportRemainingOptionsAsUnrecognized();
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// initialize the viewer.
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel) if (!loadedModel)
{ {
// write_usage(osg::notify(osg::NOTICE),argv[0]); // write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -17,7 +17,6 @@
#include <osgDB/Registry> #include <osgDB/Registry>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
@ -307,34 +306,35 @@ osg::Node* createMirroredScene(osg::Node* model)
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2) // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{ {
//write_usage(osg::notify(osg::NOTICE),argv[0]); arguments.getApplicationUsage()->write(std::cout);
return 0; return 1;
} }
// create the commandline args. // any option left unread are converted into errors to write out later.
std::vector<std::string> commandLine; arguments.reportRemainingOptionsAsUnrecognized();
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer. // report any errors if they have occured when parsing the program aguments.
osgGLUT::Viewer viewer; if (arguments.errors())
viewer.setWindowTitle(argv[0]); {
arguments.writeErrorMessages(std::cout);
// configure the viewer from the commandline arguments, and eat any return 1;
// parameters that have been matched. }
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel) if (!loadedModel)

View File

@ -18,72 +18,40 @@
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2)
{
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// if user request help write it out to cout.
// configure the viewer from the commandline arguments, and eat any if (arguments.read("-h") || arguments.read("--help"))
// parameters that have been matched. {
viewer.readCommandLine(commandLine); arguments.getApplicationUsage()->write(std::cout);
return 1;
// configure the plugin registry from the commandline arguments, and }
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine); // 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel) if (!loadedModel)
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 1; return 1;
} }

View File

@ -9,7 +9,6 @@
#include <osgGA/TrackballManipulator> #include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osgGLUT/glut>
// //
@ -69,25 +68,6 @@ private:
std::vector<osg::Sequence*>* _seq; std::vector<osg::Sequence*>* _seq;
}; };
void write_usage(std::ostream& out, const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out<<std::endl;
}
osg::Sequence* generateSeq(osg::Sequence::LoopMode mode, osg::Sequence* generateSeq(osg::Sequence::LoopMode mode,
float speed, int nreps, float speed, int nreps,
std::vector<osg::Node*>& model) std::vector<osg::Node*>& model)
@ -114,39 +94,44 @@ osg::Sequence* generateSeq(osg::Sequence::LoopMode mode,
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc < 2) // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{ {
write_usage(osg::notify(osg::NOTICE), argv[0]); arguments.getApplicationUsage()->write(std::cout);
return 0; return 1;
} }
// create commandline args // any option left unread are converted into errors to write out later.
std::vector<std::string> commandLine; arguments.reportRemainingOptionsAsUnrecognized();
for (int ia = 1; ia < argc; ia++)
commandLine.push_back(argv[ia]);
// initialize the viewer // report any errors if they have occured when parsing the program aguments.
osgGLUT::Viewer viewer; if (arguments.errors())
viewer.setWindowTitle(argv[0]); {
arguments.writeErrorMessages(std::cout);
// configure the viewer from the commandline arguments, and eat any return 1;
// parameters that have been matched. }
viewer.readCommandLine(commandLine);
// assumes any remaining parameters are models // assumes any remaining parameters are models
std::vector<osg::Node*> model; std::vector<osg::Node*> model;
unsigned int i; int i;
for (i = 0; i < commandLine.size(); i++) { for (i = 1; i < arguments.argc(); i++)
std::cerr << "Loading " << commandLine[i] << std::endl; {
osg::Node* node = osgDB::readNodeFile(commandLine[i]); std::cerr << "Loading " << arguments[i] << std::endl;
osg::Node* node = osgDB::readNodeFile(arguments[i]);
if (node) if (node)
model.push_back(node); model.push_back(node);
} }
if (model.empty()) { if (model.empty()) {
write_usage(osg::notify(osg::NOTICE),argv[0]);
return -1; return -1;
} }

View File

@ -15,7 +15,6 @@
#include <osgGA/DriveManipulator> #include <osgGA/DriveManipulator>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
@ -172,25 +171,32 @@ osg::Node* createModel()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* model = createModel(); osg::Node* model = createModel();

View File

@ -6,7 +6,6 @@
#include <osgGA/TrackballManipulator> #include <osgGA/TrackballManipulator>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osgGLUT/glut>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
@ -85,21 +84,32 @@ osg::Geode* createShapes()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
glutInit( &argc, argv ); // use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// create the commandline args. // set up the usage document, in case we need to print out how to use this program.
std::vector<std::string> commandLine; arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the viewer and the model to it. // if user request help write it out to cout.
osgGLUT::Viewer viewer; if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
viewer.setWindowTitle(argv[0]); // 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.
// configure the viewer from the commandline arguments, and eat any if (arguments.errors())
// parameters that have been matched. {
viewer.readCommandLine(commandLine); arguments.writeErrorMessages(std::cout);
return 1;
}
osg::Node* node = createShapes(); osg::Node* node = createShapes();

View File

@ -9,88 +9,49 @@
#include <osgDB/Registry> #include <osgDB/Registry>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] image_left_eye image_right_eye"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
out<<"example:"<<std::endl;
out<<" Images/dog_left_eye.jpg Images/dog_right_eye.jpg"<<std::endl;
out<<std::endl;
}
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2) // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]); arguments.getApplicationUsage()->write(std::cout);
return 0; return 1;
} }
// create the commandline args. // any option left unread are converted into errors to write out later.
std::vector<std::string> commandLine; arguments.reportRemainingOptionsAsUnrecognized();
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// report any errors if they have occured when parsing the program aguments.
// initialize the viewer. if (arguments.errors())
osgGLUT::Viewer viewer; {
viewer.setWindowTitle(argv[0]); arguments.writeErrorMessages(std::cout);
return 1;
}
// default to enabling stereo. // default to enabling stereo.
viewer.getDisplaySettings()->setStereo(true); viewer.getDisplaySettings()->setStereo(true);
// configure the viewer from the commandline arguments, and eat any if (arguments.argc()<=2)
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
if (commandLine.size()<2)
{ {
osg::notify(osg::NOTICE) << "Please specify two images required for stereo imaging."<<std::endl; osg::notify(osg::NOTICE) << "Please specify two images required for stereo imaging."<<std::endl;
return 0; return 0;
} }
osg::Image* imageLeft = osgDB::readImageFile(commandLine[0]); osg::Image* imageLeft = osgDB::readImageFile(arguments[1]);
osg::Image* imageRight = osgDB::readImageFile(commandLine[1]); osg::Image* imageRight = osgDB::readImageFile(arguments[2]);
if (imageLeft && imageRight) if (imageLeft && imageRight)

View File

@ -318,22 +318,32 @@ osg::Geode* createTeapot()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
glutInit( &argc, argv ); // use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// create the commandline args. // set up the usage document, in case we need to print out how to use this program.
std::vector<std::string> commandLine; arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// create the viewer and the model to it. // if user request help write it out to cout.
osgGLUT::Viewer viewer; if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
viewer.setWindowTitle(argv[0]); // 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.
// configure the viewer from the commandline arguments, and eat any if (arguments.errors())
// parameters that have been matched. {
viewer.readCommandLine(commandLine); arguments.writeErrorMessages(std::cout);
return 1;
}
// add model to viewer. // add model to viewer.
viewer.addViewport( createTeapot() ); viewer.addViewport( createTeapot() );

View File

@ -420,28 +420,35 @@ osg::Group* create3DText(const osg::Vec3& center,float radius)
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::ref_ptr<osg::Node> rootNode = osgDB::readNodeFiles(commandLine); osg::ref_ptr<osg::Node> rootNode = osgDB::readNodeFiles(arguments);
// prepare scene. // prepare scene.
{ {

View File

@ -179,34 +179,35 @@ void write_usage(std::ostream& out,const std::string& name)
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2) // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]); arguments.getApplicationUsage()->write(std::cout);
return 0; return 1;
} }
// create the commandline args. // any option left unread are converted into errors to write out later.
std::vector<std::string> commandLine; arguments.reportRemainingOptionsAsUnrecognized();
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// report any errors if they have occured when parsing the program aguments.
// initialize the viewer. if (arguments.errors())
osgGLUT::Viewer viewer; {
viewer.setWindowTitle(argv[0]); arguments.writeErrorMessages(std::cout);
return 1;
// configure the viewer from the commandline arguments, and eat any }
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the images specified on command line // load the images specified on command line
osg::Node* loadedModel = osgDB::readNodeFiles(commandLine); osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
if (loadedModel) if (loadedModel)

View File

@ -72,19 +72,17 @@ class Texture2DCallback : public osg::NodeCallback
* Function to read several images files (typically one) as specified * Function to read several images files (typically one) as specified
* on the command line, and return them in an ImageList * on the command line, and return them in an ImageList
*/ */
ImageList getImagesFromFiles(std::vector<std::string>& commandLine) ImageList getImagesFromFiles(osg::ArgumentParser& arguments)
{ {
ImageList imageList; ImageList imageList;
for(std::vector<std::string>::iterator itr=commandLine.begin(); for(int i=1;i<arguments.argc();++i)
itr!=commandLine.end();
++itr)
{ {
if ((*itr)[0]!='-') if (!arguments.isOption(i))
{ {
// not an option so assume string is a filename. // not an option so assume string is a filename.
osg::Image *image = osgDB::readImageFile( *itr ); osg::Image *image = osgDB::readImageFile( arguments[i] );
if (image) if (image)
{ {
imageList.push_back(image); imageList.push_back(image);
@ -389,72 +387,38 @@ osg::Node* createModelFromImages(ImageList& imageList)
return root; return root;
} }
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] image_infile1 [image_infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
out<<"example:"<<std::endl;
out<<" osgtexture lz.rgb"<<std::endl;
out<<std::endl;
}
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2) // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]); arguments.getApplicationUsage()->write(std::cout);
return 0; return 1;
} }
// create the commandline args. // any option left unread are converted into errors to write out later.
std::vector<std::string> commandLine; arguments.reportRemainingOptionsAsUnrecognized();
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// report any errors if they have occured when parsing the program aguments.
// initialize the viewer. if (arguments.errors())
osgGLUT::Viewer viewer; {
viewer.setWindowTitle(argv[0]); arguments.writeErrorMessages(std::cout);
return 1;
// configure the viewer from the commandline arguments, and eat any }
// parameters that have been matched.
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the images specified on command line // load the images specified on command line
ImageList imageList = getImagesFromFiles(commandLine); ImageList imageList = getImagesFromFiles(arguments);
if (!imageList.empty()) if (!imageList.empty())
@ -479,7 +443,6 @@ int main( int argc, char **argv )
} }
else else
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]);
return 0; return 0;
} }

View File

@ -199,25 +199,32 @@ osg::Node* createModel()
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// create a model from the images. // create a model from the images.
osg::Node* rootNode = createModel(); osg::Node* rootNode = createModel();

View File

@ -1,14 +1,47 @@
#include <osg/UnitTestFramework> #include <osg/UnitTestFramework>
#include <osg/ArgumentParser>
#include <osg/ApplicationUsage>
int main( int argc, char** argv )
int main( int /*argc*/, char** /*argv*/ )
{ {
// std::cout<<"***** Qualified Tests ******"<<std::endl; osg::ArgumentParser arguments(&argc,argv);
//
// osgUtx::QualifiedTestPrinter printer;
// osgUtx::TestGraph::instance().root()->accept( printer );
// std::cout<<endl;
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options]");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("qt","Display qualified tests.");
bool printQualifiedTest = false;
while (arguments.read("qt")) printQualifiedTest = true;
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
std::cout<<arguments.getApplicationUsage()->getCommandLineUsage()<<std::endl;
arguments.getApplicationUsage()->write(std::cout,arguments.getApplicationUsage()->getCommandLineOptions());
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;
}
if (printQualifiedTest)
{
std::cout<<"***** Qualified Tests ******"<<std::endl;
osgUtx::QualifiedTestPrinter printer;
osgUtx::TestGraph::instance().root()->accept( printer );
std::cout<<endl;
}
std::cout<<"****** Running tests ******"<<std::endl; std::cout<<"****** Running tests ******"<<std::endl;

View File

@ -344,32 +344,39 @@ osg::Node* addRefractStateSet(osg::Node* node)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
glutInitDisplayString("rgba double depth>=16");
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1; i<argc; ++i) commandLine.push_back(argv[i]);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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::Group* rootnode = new osg::Group; osg::Group* rootnode = new osg::Group;
rootnode->addChild(createSkyBox()); rootnode->addChild(createSkyBox());
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* model = osgDB::readNodeFiles(commandLine); osg::Node* model = osgDB::readNodeFiles(arguments);
if (!model) if (!model)
{ {
const float radius = 1.0f; const float radius = 1.0f;

View File

@ -14,68 +14,38 @@
#include <osg/Quat> #include <osg/Quat>
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out << std::endl;
}
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
// initialize the GLUT // use an ArgumentParser object to manage the program arguments.
glutInit( &argc, argv ); osg::ArgumentParser arguments(&argc,argv);
if (argc<2) // set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// initialize the viewer.
osgGLUT::Viewer viewer(arguments);
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{ {
write_usage(osg::notify(osg::NOTICE),argv[0]); arguments.getApplicationUsage()->write(std::cout);
return 0; return 1;
} }
// create the commandline args. // any option left unread are converted into errors to write out later.
std::vector<std::string> commandLine; arguments.reportRemainingOptionsAsUnrecognized();
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// initialize the viewer. // report any errors if they have occured when parsing the program aguments.
osgGLUT::Viewer viewer; if (arguments.errors())
viewer.setWindowTitle(argv[0]); {
arguments.writeErrorMessages(std::cout);
// configure the viewer from the commandline arguments, and eat any return 1;
// parameters that have been matched. }
viewer.readCommandLine(commandLine);
// configure the plugin registry from the commandline arguments, and
// eat any parameters that have been matched.
osgDB::readCommandLine(commandLine);
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)
{ {
// write_usage(osg::notify(osg::NOTICE),argv[0]); // write_usage(osg::notify(osg::NOTICE),argv[0]);

View File

@ -1,6 +1,3 @@
#include <stdio.h>
#include <osg/GL>
#include <osgGLUT/glut>
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osg/Node> #include <osg/Node>
@ -14,7 +11,6 @@
#include <osgGA/DriveManipulator> #include <osgGA/DriveManipulator>
#include <osgGA/AnimationPathManipulator> #include <osgGA/AnimationPathManipulator>
#include <osgUtil/Optimizer> #include <osgUtil/Optimizer>
struct SortByAverageDistanceFunctor struct SortByAverageDistanceFunctor
@ -51,87 +47,42 @@ struct MySortCallback : public osgUtil::RenderBin::SortCallback
} }
}; };
void write_usage(std::ostream& out,const std::string& name)
{
out << std::endl;
out <<"usage:"<< std::endl;
out <<" "<<name<<" [options] infile1 [infile2 ...]"<< std::endl;
out << std::endl;
out <<"options:"<< std::endl;
out <<" -l libraryName - load plugin of name libraryName"<< std::endl;
out <<" i.e. -l osgdb_pfb"<< std::endl;
out <<" Useful for loading reader/writers which can load"<< std::endl;
out <<" other file formats in addition to its extension."<< std::endl;
out <<" -e extensionName - load reader/wrter plugin for file extension"<< std::endl;
out <<" i.e. -e pfb"<< std::endl;
out <<" Useful short hand for specifying full library name as"<< std::endl;
out <<" done with -l above, as it automatically expands to"<< std::endl;
out <<" the full library name appropriate for each platform."<< std::endl;
out <<std::endl;
out <<" -O \"options string\" - create an options string to pass to the reader/wrter "<< std::endl;
out <<" for controlling reading and writing parameters."<< std::endl;
out <<std::endl;
out <<" -stereo - switch on stereo rendering, using the default of,"<< std::endl;
out <<" ANAGLYPHIC or the value set in the OSG_STEREO_MODE "<< std::endl;
out <<" environmental variable. See doc/stereo.html for "<< std::endl;
out <<" further details on setting up accurate stereo "<< std::endl;
out <<" for your system. "<< std::endl;
out <<" -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering."<< std::endl;
out <<" -stereo QUAD_BUFFER - switch on quad buffered stereo rendering."<< std::endl;
out <<std::endl;
out <<" -stencil - use a visual with stencil buffer enabled, this "<< std::endl;
out <<" also allows the depth complexity statistics mode"<< std::endl;
out <<" to be used (press 'p' three times to cycle to it)."<< std::endl;
out <<" -f - start with a full screen, borderless window." << std::endl;
out <<" -p pathfile - Use the AnimationPathManipulator (key binding '4') and use\n"
" pathfile to define the animation path. pathfile is an ascii\n"
" file containing lines of eight floating point numbers representing\n"
" time, position (x,y,z) and attitude (x,y,z,w as a quaternion)." << std::endl;
out << std::endl;
}
int main( int argc, char **argv ) 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()->setCommandLineUsage(arguments.getProgramName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","Use specificed animation path file for camera animation");
// read the commandline args.
std::string pathfile; std::string pathfile;
while (arguments.read("-p",pathfile)) {}
// initialize the GLUT
glutInit( &argc, argv );
if (argc<2)
{
write_usage(std::cout,argv[0]);
return 1;
}
// create the commandline args.
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) {
if( std::string(argv[i]) == "-p" ) {
if( (i+1) >= argc ) {
write_usage( std::cout, argv[0]);
return 1;
}
else
pathfile = std::string(argv[++i]);
}
else
commandLine.push_back(argv[i]);
}
// initialize the viewer. // initialize the viewer.
osgGLUT::Viewer viewer; osgGLUT::Viewer viewer(arguments);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any // if user request help write it out to cout.
// parameters that have been matched. if (arguments.read("-h") || arguments.read("--help"))
viewer.readCommandLine(commandLine); {
arguments.getApplicationUsage()->write(std::cout);
// configure the plugin registry from the commandline arguments, and return 1;
// eat any parameters that have been matched. }
osgDB::readCommandLine(commandLine);
// 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;
}
// load the nodes from the commandline arguments. // load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(commandLine); osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (!rootnode) if (!rootnode)
{ {
return 1; return 1;

View File

@ -224,77 +224,6 @@ void DisplaySettings::readEnvironmentalVariables()
} }
} }
void DisplaySettings::readCommandLine(std::vector<std::string>& commandLine)
{
bool found = true;
while (found)
{
found = false;
// check for stereo based options.
std::vector<std::string>::iterator itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-stereo") break;
}
if (itr!=commandLine.end())
{
_stereo = true;
std::vector<std::string>::iterator start = itr;
++itr;
if (itr!=commandLine.end())
{
if (*itr=="ANAGLYPHIC") { _stereo = true;_stereoMode = ANAGLYPHIC; ++itr; }
else if (*itr=="QUAD_BUFFER") { _stereo = true;_stereoMode = QUAD_BUFFER; ++itr; }
else if (*itr=="HORIZONTAL_SPLIT") { _stereo = true;_stereoMode = HORIZONTAL_SPLIT; ++itr; }
else if (*itr=="VERTICAL_SPLIT") { _stereo = true;_stereoMode = VERTICAL_SPLIT; ++itr; }
else if (*itr=="LEFT_EYE") { _stereo = true;_stereoMode = LEFT_EYE; ++itr; }
else if (*itr=="RIGHT_EYE") { _stereo = true;_stereoMode = RIGHT_EYE; ++itr; }
else if (*itr=="ON") { _stereo = true; ++itr; }
else if (*itr=="OFF") { _stereo = false; ++itr; }
}
commandLine.erase(start,itr);
found = true;
}
// check destination alpha
itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-rgba") break;
}
if (itr!=commandLine.end())
{
_RGB = true;
_minimumNumberAlphaBits = 1;
commandLine.erase(itr);
found = true;
}
// check stencil buffer
itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-stencil") break;
}
if (itr!=commandLine.end())
{
_minimumNumberStencilBits = 1;
commandLine.erase(itr);
found = true;
}
}
}
void DisplaySettings::readCommandLine(ArgumentParser& arguments) void DisplaySettings::readCommandLine(ArgumentParser& arguments)
{ {

View File

@ -71,6 +71,8 @@ Registry::Registry()
addFileExtensionAlias("jpeg", "qt"); addFileExtensionAlias("jpeg", "qt");
addFileExtensionAlias("tif", "qt"); addFileExtensionAlias("tif", "qt");
addFileExtensionAlias("tiff", "qt"); addFileExtensionAlias("tiff", "qt");
addFileExtensionAlias("gif", "qt");
addFileExtensionAlias("png", "qt");
#else #else
addFileExtensionAlias("jpg", "jpeg"); addFileExtensionAlias("jpg", "jpeg");
addFileExtensionAlias("jpe", "jpeg"); addFileExtensionAlias("jpe", "jpeg");
@ -225,79 +227,6 @@ void Registry::initLibraryFilePathList()
} }
void Registry::readCommandLine(std::vector<std::string>& commandLine)
{
bool found = true;
while (found)
{
found = false;
// load library option.
std::vector<std::string>::iterator itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-l") break;
}
if (itr!=commandLine.end())
{
std::vector<std::string>::iterator start = itr;
++itr;
if (itr!=commandLine.end())
{
loadLibrary(*itr);
++itr;
}
commandLine.erase(start,itr);
found = true;
}
// load library for extension
itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-e") break;
}
if (itr!=commandLine.end())
{
std::vector<std::string>::iterator start = itr;
++itr;
if (itr!=commandLine.end())
{
std::string libName = osgDB::Registry::instance()->createLibraryNameForExt(*itr);
loadLibrary(libName);
++itr;
}
commandLine.erase(start,itr);
found = true;
}
// read any option strings that exist.
itr = commandLine.begin();
for(;itr!=commandLine.end();++itr)
{
if (*itr=="-O") break;
}
if (itr!=commandLine.end())
{
std::vector<std::string>::iterator start = itr;
++itr;
if (itr!=commandLine.end())
{
osgDB::Registry::instance()->setOptions(new osgDB::ReaderWriter::Options(*itr));
++itr;
}
commandLine.erase(start,itr);
found = true;
}
}
}
void Registry::readCommandLine(osg::ArgumentParser& arguments) void Registry::readCommandLine(osg::ArgumentParser& arguments)
{ {
// report the usage options. // report the usage options.

View File

@ -36,9 +36,11 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
{ {
if(!_drawState.valid()) return false; if(!_drawState.valid()) return false;
if(ea.getEventType()==GUIEventAdapter::KEYDOWN){ if(ea.getEventType()==GUIEventAdapter::KEYDOWN)
{
switch( ea.getKey() ){ switch( ea.getKey() )
{
case 'b' : case 'b' :
_backface = !_backface; _backface = !_backface;
@ -64,24 +66,24 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
return true; return true;
break; break;
case 'w' : case 'w' :
{
osg::PolygonMode* polyModeObj = dynamic_cast<osg::PolygonMode*>(_drawState->getAttribute(osg::StateAttribute::POLYGONMODE));
if (!polyModeObj)
{ {
polyModeObj = new osg::PolygonMode; osg::PolygonMode* polyModeObj = dynamic_cast<osg::PolygonMode*>(_drawState->getAttribute(osg::StateAttribute::POLYGONMODE));
_drawState->setAttribute(polyModeObj); if (!polyModeObj)
{
polyModeObj = new osg::PolygonMode;
_drawState->setAttribute(polyModeObj);
}
// cycle through the available modes.
switch(polyModeObj->getMode(osg::PolygonMode::FRONT_AND_BACK))
{
case osg::PolygonMode::FILL : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); break;
case osg::PolygonMode::LINE : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::POINT); break;
case osg::PolygonMode::POINT : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL); break;
}
} }
break;
// cycle through the available modes.
switch(polyModeObj->getMode(osg::PolygonMode::FRONT_AND_BACK))
{
case osg::PolygonMode::FILL : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); break;
case osg::PolygonMode::LINE : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::POINT); break;
case osg::PolygonMode::POINT : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL); break;
}
}
break;
} }
} }
return false; return false;

View File

@ -20,6 +20,7 @@
#include <osgGLUT/Viewer> #include <osgGLUT/Viewer>
#include <osgGLUT/GLUTEventAdapter> #include <osgGLUT/GLUTEventAdapter>
#include <osg/ApplicationUsage>
#include <osg/Switch> #include <osg/Switch>
#include <osg/Billboard> #include <osg/Billboard>
#include <osg/LOD> #include <osg/LOD>
@ -39,6 +40,7 @@
#include <osg/Fog> #include <osg/Fog>
#include <osgDB/WriteFile> #include <osgDB/WriteFile>
#include <osgDB/Registry>
#include <osgUtil/IntersectVisitor> #include <osgUtil/IntersectVisitor>
#include <osgUtil/DisplayListVisitor> #include <osgUtil/DisplayListVisitor>
@ -88,6 +90,22 @@ using namespace std;
Viewer* Viewer::s_theViewer = 0; Viewer* Viewer::s_theViewer = 0;
Viewer::Viewer() Viewer::Viewer()
{
initialize();
}
Viewer::Viewer(osg::ArgumentParser& arguments)
{
initialize();
glutInit( &arguments.argc(), arguments.argv() );
setWindowTitle(arguments.getProgramName().c_str());
readCommandLine(arguments);
}
void Viewer::initialize()
{ {
s_theViewer = this; s_theViewer = this;
@ -147,24 +165,27 @@ void Viewer::clear()
Window::clear(); Window::clear();
} }
void Viewer::readCommandLine(osg::ArgumentParser& arguments)
/** read the command line string list, removing any matched control sequences.*/
void Viewer::readCommandLine(std::vector<std::string>& commandLine)
{ {
std::vector<std::string>::iterator itr = commandLine.begin(); // report the usage options.
for(;itr!=commandLine.end();++itr) if (arguments.getApplicationUsage())
{ {
if (*itr=="-f") arguments.getApplicationUsage()->addCommandLineOption("-f","open the application in fullscreen mode");
{
_fullscreen = true;
break;
}
} }
_displaySettings->readCommandLine(commandLine);
while(arguments.read("-f"))
{
_fullscreen = true;
}
_displaySettings->readCommandLine(arguments);
osgDB::readCommandLine(arguments);
} }
void
Viewer::toggleFullScreen() void Viewer::toggleFullScreen()
{ {
_fullscreen = !_fullscreen; _fullscreen = !_fullscreen;
if (_fullscreen) if (_fullscreen)