src/C_Chute.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 "C_Chute.h"
00024 
00025 C_Chute::C_Chute(osg::Group *g,osg::Group *n,string pathTextEau)
00026 {
00027         rootNode = g;
00028         geode = new osg::Geode;
00029         rootNode->addChild(geode);
00030         pathTexture = pathTextEau;
00031         node_emitter = n;
00032         enableShooter  = false;
00033         enableAcc = true;
00034         enableGrav = false;
00035 }
00036 
00037 void C_Chute::Creer_Chute(double x, double y, double z)
00038 {
00039         ChuteParticleSystem = new osgParticle::ParticleSystem;
00040         ChuteParticleSystem->setDefaultAttributes(pathTexture,false, false);
00041         geode->addDrawable(ChuteParticleSystem);
00042  
00043         ChuteSystemUpdater = new osgParticle::ParticleSystemUpdater;
00044         ChuteSystemUpdater->addParticleSystem(ChuteParticleSystem);
00045         rootNode->addChild(ChuteSystemUpdater);
00046 
00047         osgParticle::Particle smokeParticle; 
00048         smokeParticle.setSizeRange(osgParticle::rangef(range_min,range_max));
00049         smokeParticle.setLifeTime(lifeTime);
00050         smokeParticle.setMass(mass);
00051         ChuteParticleSystem->setDefaultParticleTemplate(smokeParticle);
00052 
00053         
00054         emitter= new osgParticle::ModularEmitter;
00055         emitter->setParticleSystem(ChuteParticleSystem);
00056         switch (type){
00057                 case CHU : emitter->setUpdateCallback(new PSChuteCallback()); break;
00058                 case HZ  : emitter->setUpdateCallback(new PSChuteHzCallback()); break;
00059                 case NUAG : emitter->setUpdateCallback(new PSChuteNuageCallback()); break;
00060                 default: ; 
00061         }
00062         osgParticle::RandomRateCounter *ChuteRate = static_cast<osgParticle::RandomRateCounter *>(emitter->getCounter());
00063         ChuteRate->setRateRange(nbGenerate, nbGenerate);
00064         
00065         placer = new osgParticle::SectorPlacer;
00066         placer->setCenter(x, y, z);
00067         placer->setRadiusRange(radiusRangeMin, radiusRangeMax);
00068         emitter->setPlacer(placer);
00069 
00070         smokeShooter = new osgParticle::RadialShooter();
00071         if (enableShooter)
00072         {
00073                 smokeShooter->setThetaRange(thetaRangeMin, thetaRangeMax); // radians, relative to Z axis.
00074                 smokeShooter->setPhiRange(phiRangeMin, phiRangeMax);
00075                 smokeShooter->setInitialSpeedRange(speedRangeMin,speedRangeMax); // meters/second
00076         }
00077         emitter->setShooter(smokeShooter);
00078         node_emitter->addChild(emitter);
00079 
00080         osgParticle::ModularProgram *moveDustInAir = new osgParticle::ModularProgram;
00081         moveDustInAir->setParticleSystem(ChuteParticleSystem);
00082 
00083         accelUp = new osgParticle::AccelOperator;
00084         if (enableAcc)
00085                 accelUp->setAcceleration(vecAcceleration);
00086         if (enableGrav)
00087                 accelUp->setToGravity(gravite); // scale factor for normal acceleration due to gravity. 
00088         moveDustInAir->addOperator(accelUp);
00089         
00090         airFriction = new osgParticle::FluidFrictionOperator;
00091         airFriction->setFluidToWater();
00092         moveDustInAir->addOperator(airFriction);
00093         rootNode->addChild(moveDustInAir);
00094 }

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