Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/particle/ParticleInterface.cc @ 1479

Last change on this file since 1479 was 1293, checked in by scheusso, 16 years ago

merged changes from input & camera & network branch into trunk

File size: 4.3 KB
RevLine 
[535]1/*
[708]2*   ORXONOX - the hottest 3D action shooter ever to exist
3*
4*
5*   License notice:
6*
7*   This program is free software; you can redistribute it and/or
8*   modify it under the terms of the GNU General Public License
9*   as published by the Free Software Foundation; either version 2
10*   of the License, or (at your option) any later version.
11*
12*   This program is distributed in the hope that it will be useful,
13*   but WITHOUT ANY WARRANTY; without even the implied warranty of
14*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*   GNU General Public License for more details.
16*
17*   You should have received a copy of the GNU General Public License
18*   along with this program; if not, write to the Free Software
19*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20*
21*   Author:
22*      ...
23*   Co-authors:
24*      ...
25*
26*/
[535]27
[658]28/**
[708]29* @file ParticleInterface.cc
30* @brief class to control praticle effects
31*/
[658]32
[786]33#include "OrxonoxStableHeaders.h"
[1039]34#include "ParticleInterface.h"
[784]35
[618]36// #include <OgreParticleSystem.h>
37// #include <Ogre.h>
[708]38// #include <OIS/OIS.h>
[535]39// #include <CEGUI/CEGUI.h>
40// #include <CEGUIRenderer.h>
41
42
43
[708]44namespace orxonox {
45  using namespace Ogre;
[535]46
[715]47  ParticleInterface::ParticleInterface( SceneManager *sceneManager, std::string name, std::string templateName )
[592]48  {
49    sceneManager_ = sceneManager;
50    particleSystem_ = sceneManager->createParticleSystem(name, templateName);
[535]51
[592]52    //Variabeln einlesen, Emitter1_ ist Referenz-Emitter
53    velocity_ = particleSystem_->getSpeedFactor();
54    colour_ = particleSystem_->getEmitter(0)->getColour();
55    rate_ = particleSystem_->getEmitter(0)->getEmissionRate();
56    distance_ = particleSystem_->getEmitter(0)->getTimeToLive();
[535]57
[592]58    //Anzahl der Emitter
59    numberOfEmitters_ = particleSystem_->getNumEmitters();
60    standardizeEmitters();
61  }
[535]62
[659]63  ParticleInterface::~ParticleInterface(void)
64  {
[1293]65    while(particleSystem_->getNumEmitters()>0)
66      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
[659]67    sceneManager_->destroyParticleSystem(particleSystem_);
68  }
69
[592]70  void ParticleInterface::standardizeEmitters(void)
71  {
72    //Abgleichen der anderen Emitter an die Variabeln
[1037]73    for (int i=0; i < numberOfEmitters_; i++) {
[592]74      particleSystem_->getEmitter(i)->setColour( colour_ );
75      particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
76      particleSystem_->getEmitter(i)->setEmissionRate( rate_ );
77    }
[535]78
[592]79  }
[535]80
[592]81  void ParticleInterface::setVelocity(Real v)
82  {
83    velocity_ = v;
84    //partikel anpassen
85    particleSystem_->setSpeedFactor(v);
86  }
[535]87
[1037]88  void ParticleInterface::setRate(float r)
[592]89  {
90    rate_ = r;
91    //partikel anpassen
92    for (int i=0; i<numberOfEmitters_; i++) {
93      particleSystem_->getEmitter(i)->setEmissionRate(rate_);
94    }
95  }
[535]96
[592]97  void ParticleInterface::setDistance(Real d)
98  {
99    distance_ = d;
100    //partikel anpassen
[659]101    for (int i=0; i < numberOfEmitters_; i++) {
[592]102      particleSystem_->getEmitter(i)->setTimeToLive(distance_);
103    }
104  }
[535]105
[592]106  void ParticleInterface::setColour(ColourValue colour)
107  {
108    colour_ = colour;
109    //partikel anpassen
[659]110    for (int i=0; i < numberOfEmitters_; i++) {
[592]111      particleSystem_->getEmitter(i)->setColour(colour_);
112    }
113  }
[535]114
[592]115  ParticleEmitter* ParticleInterface::getEmitter( int emitterNr )
116  {
[659]117    if ( (emitterNr >= numberOfEmitters_) || (emitterNr < 0) ) return NULL;
[592]118    return particleSystem_->getEmitter(emitterNr);
119  }
[535]120
[659]121  void ParticleInterface::newEmitter ()
[592]122  {
123    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
[659]124    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_) );
125    numberOfEmitters_++;
[592]126  }
[535]127
[708]128  // TODO check if this really works
[592]129  Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
130  {
[1037]131    return particleSystem_->getEmitter(emitterNr)->getPosition();
[592]132  }
[535]133
[592]134  void ParticleInterface::setDirection ( Vector3 direction )
135  {
[728]136    for(int i=0; i < numberOfEmitters_; i++) {
[592]137      particleSystem_->getEmitter(i)->setDirection(direction);
138    }
139  }
[535]140
[592]141  void ParticleInterface::switchEnable(){
142    bool enable=(!(particleSystem_->getEmitter(0)->getEnabled()));
[728]143    for(int i=0; i < numberOfEmitters_; i++) {
[592]144      particleSystem_->getEmitter(i)->setEnabled(enable);
145    }
146  }
[535]147
[618]148}
Note: See TracBrowser for help on using the repository browser.