src/projetrv.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by                                                 *
00003  *         Pierre-yves JEZEQUEL, Julien MICHOT, Loic MOISAN,               *
00004  *         Julien PAPILLON, Sebastien PINEAUD, Barthelemy SERRES           *
00005  *                                                                         *
00006  *   https://sourceforge.net/projects/anidam                               *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  ***************************************************************************/
00023 //#include <iostream>
00024 //#include "SDL.h"
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                          int main(int, char* []){
00041                          try{
00042                          SceneManager manager;
00043                          cerr << "SDL Initialization Succeeded!"<< endl;
00044                          manager.startEventLoop();
00045 }
00046                          catch(string error){
00047                          cerr << error << endl;
00048                          return 1;
00049 }
00050                          return 0;
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 //int main( int argc, char **argv )
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     // use an ArgumentParser object to manage the program arguments.
00085     osg::ArgumentParser arguments(&argc,argv);
00086     
00087     // set up the usage document, in case we need to print out how to use this program.
00088         //arguments.getApplicationUsage()->addCommandLineOption(
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                 // construct the viewer.
00100         //    osgProducer::Viewer viewer(arguments);
00101                 osgProducer::Viewer viewer;
00102 
00103                 // set up the value with sensible default event handlers.
00104                 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
00105 
00106                 // get details on keyboard and mouse bindings used by the viewer.
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                 // report any errors if they have occured when parsing the program aguments.
00119                 if (arguments.errors())
00120                 {
00121                         arguments.writeErrorMessages(std::cout);
00122                         return 1;
00123                 }
00124                 
00125                 //instanciation d'un objet Scene3D
00126                 Scene3D* scene = new Scene3D();
00127 
00128                 scene->attach(&viewer);
00129 
00130                 if (!arguments.read("-nosound"))
00131                 {
00132                 //Initialisation du Son
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                 //Cr�ation de la sc�ne3D
00143                 scene->createScene();
00144               
00145           
00146 
00147                 //R�alisation!
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 }

Generated on Tue Jun 5 16:56:48 2007 for Anidam by  doxygen 1.5.1