Clean up to the osgProducer lib and demo.

This commit is contained in:
Robert Osfield
2003-01-22 15:30:17 +00:00
parent 4b671e5023
commit 6fd27a4b59
12 changed files with 106 additions and 189 deletions

View File

@@ -3,23 +3,42 @@
//as published by the Free Software Foundation.
#include <osgUtil/Optimizer>
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
#include <osgGA/AnimationPathManipulator>
#include <osgProducer/Viewer>
int main( int argc, char **argv )
{
// create the camera group.
osgProducer::Viewer viewer(argc,argv);
osgProducer::Viewer viewer;
// set up the database files to read.
std::vector<std::string> filenameList;
if (argc>1) filenameList.push_back(argv[1]);
else filenameList.push_back("cow.osg");
// create the commandline args.
std::string pathfile;
std::vector<std::string> commandLine;
for(int i=1;i<argc;++i) {
if( std::string(argv[i]) == "-p" ) {
if( (i+1) >= argc ) {
std::cout << "path argument required for -p option."<<std::endl;
return 1;
}
else
pathfile = std::string(argv[++i]);
}
else
commandLine.push_back(argv[i]);
}
osg::DisplaySettings::instance()->readCommandLine(commandLine);
osgDB::readCommandLine(commandLine);
// read the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(filenameList);
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(commandLine);
if (!loadedModel) return 1;
// optimize it, remove rendundent nodes and state etc.
@@ -30,6 +49,15 @@ int main( int argc, char **argv )
// set up the value with sensible defaults.
viewer.setUpViewer();
if( !pathfile.empty() ) {
osg::ref_ptr<osgGA::AnimationPathManipulator> apm = new osgGA::AnimationPathManipulator(pathfile);
if( apm.valid() && apm->valid() )
{
unsigned int num = viewer.addCameraManipulator(apm.get());
viewer.selectCameraManipulator(num);
}
}
// set the scene to render
viewer.setSceneData(loadedModel.get());

View File

@@ -150,18 +150,12 @@ int main( int argc, char **argv )
viewer.registerCameraManipulator(new osgGA::DriveManipulator);
if( !pathfile.empty() ) {
osgGA::AnimationPathManipulator *apm = new osgGA::AnimationPathManipulator(pathfile);
if( apm->valid() )
osg::ref_ptr<osgGA::AnimationPathManipulator> apm = new osgGA::AnimationPathManipulator(pathfile);
if( apm.valid() && apm->valid() )
{
//viewer.registerCameraManipulator(apm);
// selecting the animation path manipulator up front seems to disable view frustum
// in a heavy duty way that I'm do understand yet, so I'm commenting out for the
// time being. Simply pressing '4' will get you the animation path working correctly.
unsigned int no = viewer.registerCameraManipulator(apm);
viewer.selectCameraManipulator(no);
unsigned int num = viewer.registerCameraManipulator(apm.get());
viewer.selectCameraManipulator(num);
}
else
delete apm;
}
// osgUtil::RenderBin* depth_renderbin = osgUtil::RenderBin::getRenderBinPrototype("DepthSortedBin");