Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 658 was 658, checked in by nicolasc, 16 years ago
  • fixed (possible) typo in network
  • some inlining in PI - probably more possible
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
41using namespace Ogre;
42
43namespace particle {
44
45  ParticleInterface::~ParticleInterface(void)
46  {
47    sceneManager_->destroyParticleSystem(particleSystem_);
48  }
49
50  ParticleInterface::ParticleInterface( SceneManager *sceneManager, String name, String templateName )
51  {
52    sceneManager_ = sceneManager;
53    particleSystem_ = sceneManager->createParticleSystem(name, templateName);
54
55    //Variabeln einlesen, Emitter1_ ist Referenz-Emitter
56    velocity_ = particleSystem_->getSpeedFactor();
57    colour_ = particleSystem_->getEmitter(0)->getColour();
58    rate_ = particleSystem_->getEmitter(0)->getEmissionRate();
59    distance_ = particleSystem_->getEmitter(0)->getTimeToLive();
60
61    //Anzahl der Emitter
62    numberOfEmitters_ = particleSystem_->getNumEmitters();
63    standardizeEmitters();
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_)) return NULL;
114    return particleSystem_->getEmitter(emitterNr);
115  }
116
117  void ParticleInterface::newEmitter ( void )
118  {
119    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
120    numberOfEmitters_=numberOfEmitters_+1;
121    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_-1) );
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.