00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <string>
00026 #include <osgProducer/Viewer>
00027 #include <osgDB/ReadFile>
00028 #include <osgDB/FileUtils>
00029
00030 #include "scene3D.h"
00031
00032
00033 using std::cout;
00034 using std::endl;
00035 using std::cerr;
00036 using std::string;
00037 using namespace osg;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00059 #ifdef WIN32
00060 #include "stdafx.h"
00061 #else
00062 #define _TCHAR char
00063 #define _tmain main
00064 #endif
00065
00066 int _tmain(int argc, _TCHAR* argv[])
00067 {
00068
00069
00070
00071 osgDB::FilePathList pathList = osgDB::getDataFilePathList();
00072 pathList.push_back("./");
00073 pathList.push_back("../");
00074 pathList.push_back("data/");
00075 pathList.push_back("../data/");
00076 pathList.push_back("data/Textures/");
00077 pathList.push_back("../data/Textures/");
00078
00079 pathList.push_back("Debug/data/");
00080 pathList.push_back("Debug/");
00081 osgDB::setDataFilePathList(pathList);
00082
00083
00084
00085 osg::ArgumentParser arguments(&argc,argv);
00086
00087
00088
00089 arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an animated dam, showing the strenght of OpenSceneGraph.");
00090 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] ...");
00091 arguments.getApplicationUsage()->addCommandLineOption("-nosound","Disable the sound.");
00092 arguments.getApplicationUsage()->addCommandLineOption("-notree","Disable all trees.");
00093 arguments.getApplicationUsage()->addCommandLineOption("-nofog","Disable all the fog.");
00094 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
00095
00096
00097 try{
00098
00099
00100
00101 osgProducer::Viewer viewer;
00102
00103
00104 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
00105
00106
00107 viewer.getUsage(*arguments.getApplicationUsage());
00108
00109
00110
00111 arguments.getApplicationUsage()->write(std::cout);
00112
00113 if (arguments.read("-h") || arguments.read("--help"))
00114 {
00115 arguments.getApplicationUsage()->write(std::cout);
00116 return 1;
00117 }
00118
00119 if (arguments.errors())
00120 {
00121 arguments.writeErrorMessages(std::cout);
00122 return 1;
00123 }
00124
00125
00126 Scene3D* scene = new Scene3D();
00127
00128 scene->attach(&viewer);
00129
00130 if (!arguments.read("-nosound"))
00131 {
00132
00133 scene->initSound();
00134
00135 }
00136
00137 if (arguments.read("-notree"))
00138 scene->setTrees(false);
00139 if (arguments.read("-nofog"))
00140 scene->setFogs(false);
00141
00142
00143 scene->createScene();
00144
00145
00146
00147
00148 std::cout << "Loading elements...please wait...." <<std::endl;
00149 viewer.realize();
00150
00151 while( !viewer.done() )
00152 {
00153 viewer.sync();
00154 viewer.update();
00155 viewer.frame();
00156 }
00157
00158
00159 delete scene;
00160 }
00161 catch(string error){
00162 std::cout << error << endl;
00163 return 1;
00164 }
00165 return 0;
00166 }