Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 647 was 647, checked in by landauf, 18 years ago

good morning everybody!
did some changes in the steering of SpaceShip

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