Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/particle/ParticleInterface.cc @ 592

Last change on this file since 592 was 592, checked in by nicolasc, 16 years ago

added engineglow particle effect - based of treibwerk
other various changes

File size: 4.9 KB
RevLine 
[535]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#include "ParticleInterface.h"
29#include <Ogre.h>
[544]30//#include <OIS/OIS.h>
[535]31// #include <CEGUI/CEGUI.h>
32// #include <CEGUIRenderer.h>
33
34
35using namespace Ogre;
36
37namespace particle {
38
[592]39  ParticleInterface::~ParticleInterface(void)
40  {
41    sceneManager_->destroyParticleSystem(particleSystem_);
[535]42
[592]43    delete sceneNode_;
44    delete particleSystem_;
45    delete sceneManager_;
46  }
[535]47
[592]48  ParticleInterface::ParticleInterface( SceneManager *sceneManager, String name, String templateName )
49  {
50    sceneManager_ = sceneManager;
51    particleSystem_ = sceneManager->createParticleSystem(name, templateName);
[535]52
[592]53    //Variabeln einlesen, Emitter1_ ist Referenz-Emitter
54    velocity_ = particleSystem_->getSpeedFactor();
55    colour_ = particleSystem_->getEmitter(0)->getColour();
56    rate_ = particleSystem_->getEmitter(0)->getEmissionRate();
57    distance_ = particleSystem_->getEmitter(0)->getTimeToLive();
[535]58
[592]59    //Anzahl der Emitter
60    numberOfEmitters_ = particleSystem_->getNumEmitters();
61    standardizeEmitters();
62  }
[535]63
[592]64  void ParticleInterface::standardizeEmitters(void)
65  {
66    //Abgleichen der anderen Emitter an die Variabeln
67    for (int i=1; i<numberOfEmitters_; i++) {
68      particleSystem_->getEmitter(i)->setColour( colour_ );
69      particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
70      particleSystem_->getEmitter(i)->setEmissionRate( rate_ );
71    }
[535]72
[592]73  }
[535]74
[592]75  void ParticleInterface::addToSceneNode( SceneNode* sceneNode )
76  {
77    sceneNode_ = sceneNode;
78    sceneNode_->attachObject(particleSystem_);
79  }
[535]80
[592]81  void ParticleInterface::dettachFromSceneNode ( void )
82  {
83    sceneNode_->detachObject(particleSystem_);
84    sceneNode_ = NULL;
85  }
[535]86
[592]87  Real ParticleInterface::getVelocity()
88  {
89    return velocity_;
90  }
[535]91
[592]92  void ParticleInterface::setVelocity(Real v)
93  {
94    velocity_ = v;
95    //partikel anpassen
96    particleSystem_->setSpeedFactor(v);
97  }
[535]98
[592]99  int ParticleInterface::getRate()
100  {
101    return rate_;
102  }
103  void ParticleInterface::setRate(int r)
104  {
105    rate_ = r;
106    //partikel anpassen
107    for (int i=0; i<numberOfEmitters_; i++) {
108      particleSystem_->getEmitter(i)->setEmissionRate(rate_);
109    }
110  }
[535]111
[592]112  Real ParticleInterface::getDistance()
113  {
114    return distance_;
115  }
[535]116
[592]117  void ParticleInterface::setDistance(Real d)
118  {
119    distance_ = d;
120    //partikel anpassen
121    for (int i=0; i<numberOfEmitters_; i++) {
122      particleSystem_->getEmitter(i)->setTimeToLive(distance_);
123    }
124  }
125  ColourValue ParticleInterface::getColour()
126  {
127    return colour_;
128  }
[535]129
[592]130  void ParticleInterface::setColour(ColourValue colour)
131  {
132    colour_ = colour;
133    //partikel anpassen
134    for (int i=0; i<numberOfEmitters_; i++) {
135      particleSystem_->getEmitter(i)->setColour(colour_);
136    }
137  }
[535]138
[592]139  ParticleEmitter* ParticleInterface::getEmitter( int emitterNr )
140  {
141    if (!(emitterNr<numberOfEmitters_)) return NULL;
142    return particleSystem_->getEmitter(emitterNr);
143  }
[535]144
[592]145  void ParticleInterface::newEmitter ( void )
146  {
147    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
148    numberOfEmitters_=numberOfEmitters_+1;
149    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_-1) );
150  }
[535]151
[592]152  void ParticleInterface::setPositionOfEmitter ( int emitterNr, Vector3 position )
153  {
154    particleSystem_->getEmitter(emitterNr)->setPosition(position);
155  }
[535]156
[592]157  Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
158  {
159    return particleSystem_->getEmitter(0)->getPosition();
160  }
[535]161
[592]162  void ParticleInterface::setDirection ( Vector3 direction )
163  {
164    for(int i=0; i<numberOfEmitters_; i++) {
165      particleSystem_->getEmitter(i)->setDirection(direction);
166    }
167  }
[535]168
169
[592]170  Vector3 ParticleInterface::getDirection ( void )
171  {
172    return particleSystem_->getEmitter(0)->getDirection();
173  }
[535]174
[592]175  void ParticleInterface::switchEnable(){
176    bool enable=(!(particleSystem_->getEmitter(0)->getEnabled()));
177    for(int i=0; i<numberOfEmitters_; i++) {
178      particleSystem_->getEmitter(i)->setEnabled(enable);
179    }
180  }
[535]181
182}
Note: See TracBrowser for help on using the repository browser.