Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/shader/src/orxonox/particle/ParticleInterface.cc

Last change on this file was 1505, checked in by rgrieder, 16 years ago

f* svn: It doesn't even inform you if you attempt to set a non existing property. It is svn:eol-style and not eol-style when using the command by the way…

  • Property svn:eol-style set to native
File size: 4.2 KB
Line 
1/*
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*/
27
28/**
29* @file ParticleInterface.cc
30* @brief class to control praticle effects
31*/
32
33#include "OrxonoxStableHeaders.h"
34#include "ParticleInterface.h"
35
36// #include <OgreParticleSystem.h>
37// #include <Ogre.h>
38// #include <OIS/OIS.h>
39// #include <CEGUI/CEGUI.h>
40// #include <CEGUIRenderer.h>
41
42
43
44namespace orxonox {
45  using namespace Ogre;
46
47  ParticleInterface::ParticleInterface( SceneManager *sceneManager, std::string name, std::string templateName )
48  {
49    sceneManager_ = sceneManager;
50    particleSystem_ = sceneManager->createParticleSystem(name, templateName);
51
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();
57
58    //Anzahl der Emitter
59    numberOfEmitters_ = particleSystem_->getNumEmitters();
60    standardizeEmitters();
61  }
62
63  ParticleInterface::~ParticleInterface(void)
64  {
65    while(particleSystem_->getNumEmitters()>0)
66      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
67    sceneManager_->destroyParticleSystem(particleSystem_);
68  }
69
70  void ParticleInterface::standardizeEmitters(void)
71  {
72    //Abgleichen der anderen Emitter an die Variabeln
73    for (int i=0; i < numberOfEmitters_; i++) {
74      particleSystem_->getEmitter(i)->setColour( colour_ );
75      particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
76      particleSystem_->getEmitter(i)->setEmissionRate( rate_ );
77    }
78
79  }
80
81  void ParticleInterface::setVelocity(Real v)
82  {
83    velocity_ = v;
84    //partikel anpassen
85    particleSystem_->setSpeedFactor(v);
86  }
87
88  void ParticleInterface::setRate(float r)
89  {
90    rate_ = r;
91    //partikel anpassen
92    for (int i=0; i<numberOfEmitters_; i++) {
93      particleSystem_->getEmitter(i)->setEmissionRate(rate_);
94    }
95  }
96
97  void ParticleInterface::setDistance(Real d)
98  {
99    distance_ = d;
100    //partikel anpassen
101    for (int i=0; i < numberOfEmitters_; i++) {
102      particleSystem_->getEmitter(i)->setTimeToLive(distance_);
103    }
104  }
105
106  void ParticleInterface::setColour(ColourValue colour)
107  {
108    colour_ = colour;
109    //partikel anpassen
110    for (int i=0; i < numberOfEmitters_; i++) {
111      particleSystem_->getEmitter(i)->setColour(colour_);
112    }
113  }
114
115  ParticleEmitter* ParticleInterface::getEmitter( int emitterNr )
116  {
117    if ( (emitterNr >= numberOfEmitters_) || (emitterNr < 0) ) return NULL;
118    return particleSystem_->getEmitter(emitterNr);
119  }
120
121  void ParticleInterface::newEmitter ()
122  {
123    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
124    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_) );
125    numberOfEmitters_++;
126  }
127
128  // TODO check if this really works
129  Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
130  {
131    return particleSystem_->getEmitter(emitterNr)->getPosition();
132  }
133
134  void ParticleInterface::setDirection ( Vector3 direction )
135  {
136    for(int i=0; i < numberOfEmitters_; i++) {
137      particleSystem_->getEmitter(i)->setDirection(direction);
138    }
139  }
140
141  void ParticleInterface::switchEnable(){
142    bool enable=(!(particleSystem_->getEmitter(0)->getEnabled()));
143    for(int i=0; i < numberOfEmitters_; i++) {
144      particleSystem_->getEmitter(i)->setEnabled(enable);
145    }
146  }
147
148}
Note: See TracBrowser for help on using the repository browser.