Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/releases/0.1.0/src/orxonox/particle/ParticleInterface.cc @ 1998

Last change on this file since 1998 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

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