Scene.cpp

Aller à la documentation de ce fichier.
00001 /*
00002  * Scene.cpp : Scene 3D
00003  * Copyright (C) 2007 Florence Zara, LIRIS
00004  *               florence.zara@liris.univ-lyon1.fr
00005  *               http://liris.cnrs.fr/florence.zara/
00006  *
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published
00010  * by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 
00031 #include <list>
00032 #include <string>
00033 #include <iostream>
00034 
00036 #ifndef WIN32
00037 #include <GL/gl.h>
00038 #include <GL/glu.h>
00039 #endif
00040 
00042 #include "Noeuds.h"
00043 #include "Scene.h"
00044 
00045 
00046 
00047 
00051 Scene::Scene(std::string Fichier_Param) 
00052 {
00053         // Lecture du fichier de parametres : 
00054         // recuperation de la gravite et de la viscosite
00055         Param(Fichier_Param);
00056 }
00057 
00058 
00059 
00063 void Scene::attache(Noeud *n)
00064 { 
00065         _enfants.push_back(n); 
00066 }
00067 
00068 
00072 void Scene::getName()
00073 {
00074         ListeNoeuds::iterator e;
00075         std::cout << "----------------- Objets de la scene : " ;
00076         
00077         for(e=_enfants.begin(); e!=_enfants.end(); e++)
00078         {
00079                 std::cout << (*e)->getName() << " " ;
00080         }
00081         
00082         std::cout << " " << std::endl;
00083 }
00084 
00085 
00089 void Scene::init()
00090 {
00091         //std::cout << "----------------- Scene::Initialisation()-------------" << std::endl;
00092         ListeNoeuds::iterator e;
00093         
00094         for(e=_enfants.begin(); e!=_enfants.end(); e++)
00095         {
00096                 (*e)->init();
00097         }
00098 }
00099 
00100 
00104 void Scene::affiche()
00105 {
00106         //std::cout << "----------------- Scene::Affiche()-------------" << std::endl;
00107         ListeNoeuds::iterator e;
00108         
00109         for(e=_enfants.begin(); e!=_enfants.end(); e++)
00110         {
00111                 (*e)->affiche();
00112         }
00113 }
00114 
00115 
00116 
00120 void Scene::Simulation(int Tps)
00121 {
00122         //std::cout << "----------------- Scene::Simulation()-------------" << std::endl;
00123         ListeNoeuds::iterator e;
00124         
00125         for(e=_enfants.begin(); e!=_enfants.end(); e++)
00126         {
00127                 (*e)->Simulation(_g, _visco, Tps);
00128         }
00129 }
00130 
00131 
00132 /*
00133  * Modification de la gravite de la scene 
00134  */
00135 void Scene::setGravite(Coord g)
00136 {
00137         // Composantes x, y et z du vecteur de la gravite 
00138         _g.setX(g.getX());
00139         _g.setY(g.getY());
00140         _g.setZ(g.getZ());
00141 }
00142 
00143 
00144 /*
00145  * Modification de la viscosite du milieu 
00146  */
00147 void Scene::setVisco(float visco)
00148 {
00149         // Viscosite du milieu
00150         _visco = visco;
00151 }

Généré le Thu Jan 24 19:11:42 2008 pour Animation 3D par  doxygen 1.5.1