Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 733 was 728, checked in by nicolasc, 17 years ago
  • various cleanup
  • improved readability in PI
  • fixed iterator in language
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 "ParticleInterface.h"
34// #include <OgreParticleSystem.h>
35// #include <Ogre.h>
36// #include <OIS/OIS.h>
37// #include <CEGUI/CEGUI.h>
38// #include <CEGUIRenderer.h>
39
40
41
42namespace orxonox {
43  using namespace Ogre;
44
45  ParticleInterface::ParticleInterface( SceneManager *sceneManager, std::string name, std::string templateName )
46  {
47    sceneManager_ = sceneManager;
48    particleSystem_ = sceneManager->createParticleSystem(name, templateName);
49
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();
55
56    //Anzahl der Emitter
57    numberOfEmitters_ = particleSystem_->getNumEmitters();
58    standardizeEmitters();
59  }
60
61  ParticleInterface::~ParticleInterface(void)
62  {
63    sceneManager_->destroyParticleSystem(particleSystem_);
64  }
65
66  void ParticleInterface::standardizeEmitters(void)
67  {
68    //Abgleichen der anderen Emitter an die Variabeln
69    for (int i=1; i < numberOfEmitters_; i++) {
70      particleSystem_->getEmitter(i)->setColour( colour_ );
71      particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
72      particleSystem_->getEmitter(i)->setEmissionRate( rate_ );
73    }
74
75  }
76
77  void ParticleInterface::setVelocity(Real v)
78  {
79    velocity_ = v;
80    //partikel anpassen
81    particleSystem_->setSpeedFactor(v);
82  }
83
84  void ParticleInterface::setRate(int r)
85  {
86    rate_ = r;
87    //partikel anpassen
88    for (int i=0; i<numberOfEmitters_; i++) {
89      particleSystem_->getEmitter(i)->setEmissionRate(rate_);
90    }
91  }
92
93  void ParticleInterface::setDistance(Real d)
94  {
95    distance_ = d;
96    //partikel anpassen
97    for (int i=0; i < numberOfEmitters_; i++) {
98      particleSystem_->getEmitter(i)->setTimeToLive(distance_);
99    }
100  }
101
102  void ParticleInterface::setColour(ColourValue colour)
103  {
104    colour_ = colour;
105    //partikel anpassen
106    for (int i=0; i < numberOfEmitters_; i++) {
107      particleSystem_->getEmitter(i)->setColour(colour_);
108    }
109  }
110
111  ParticleEmitter* ParticleInterface::getEmitter( int emitterNr )
112  {
113    if ( (emitterNr >= numberOfEmitters_) || (emitterNr < 0) ) return NULL;
114    return particleSystem_->getEmitter(emitterNr);
115  }
116
117  void ParticleInterface::newEmitter ()
118  {
119    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
120    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_) );
121    numberOfEmitters_++;
122  }
123
124  // TODO check if this really works
125  Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
126  {
127    return particleSystem_->getEmitter(0)->getPosition();
128  }
129
130  void ParticleInterface::setDirection ( Vector3 direction )
131  {
132    for(int i=0; i < numberOfEmitters_; i++) {
133      particleSystem_->getEmitter(i)->setDirection(direction);
134    }
135  }
136
137  void ParticleInterface::switchEnable(){
138    bool enable=(!(particleSystem_->getEmitter(0)->getEnabled()));
139    for(int i=0; i < numberOfEmitters_; i++) {
140      particleSystem_->getEmitter(i)->setEnabled(enable);
141    }
142  }
143
144}
Note: See TracBrowser for help on using the repository browser.