Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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