Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 728 was 728, checked in by nicolasc, 16 years ago
  • various cleanup
  • improved readability in PI
  • fixed iterator in language
File size: 4.2 KB
RevLine 
[535]1/*
[708]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*/
[535]27
[658]28/**
[708]29* @file ParticleInterface.cc
30* @brief class to control praticle effects
31*/
[658]32
[535]33#include "ParticleInterface.h"
[618]34// #include <OgreParticleSystem.h>
35// #include <Ogre.h>
[708]36// #include <OIS/OIS.h>
[535]37// #include <CEGUI/CEGUI.h>
38// #include <CEGUIRenderer.h>
39
40
41
[708]42namespace orxonox {
43  using namespace Ogre;
[535]44
[715]45  ParticleInterface::ParticleInterface( SceneManager *sceneManager, std::string name, std::string templateName )
[592]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
[659]61  ParticleInterface::~ParticleInterface(void)
62  {
63    sceneManager_->destroyParticleSystem(particleSystem_);
64  }
65
[592]66  void ParticleInterface::standardizeEmitters(void)
67  {
68    //Abgleichen der anderen Emitter an die Variabeln
[728]69    for (int i=1; i < numberOfEmitters_; i++) {
[592]70      particleSystem_->getEmitter(i)->setColour( colour_ );
71      particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
72      particleSystem_->getEmitter(i)->setEmissionRate( rate_ );
73    }
[535]74
[592]75  }
[535]76
[592]77  void ParticleInterface::setVelocity(Real v)
78  {
79    velocity_ = v;
80    //partikel anpassen
81    particleSystem_->setSpeedFactor(v);
82  }
[535]83
[592]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  }
[535]92
[592]93  void ParticleInterface::setDistance(Real d)
94  {
95    distance_ = d;
96    //partikel anpassen
[659]97    for (int i=0; i < numberOfEmitters_; i++) {
[592]98      particleSystem_->getEmitter(i)->setTimeToLive(distance_);
99    }
100  }
[535]101
[592]102  void ParticleInterface::setColour(ColourValue colour)
103  {
104    colour_ = colour;
105    //partikel anpassen
[659]106    for (int i=0; i < numberOfEmitters_; i++) {
[592]107      particleSystem_->getEmitter(i)->setColour(colour_);
108    }
109  }
[535]110
[592]111  ParticleEmitter* ParticleInterface::getEmitter( int emitterNr )
112  {
[659]113    if ( (emitterNr >= numberOfEmitters_) || (emitterNr < 0) ) return NULL;
[592]114    return particleSystem_->getEmitter(emitterNr);
115  }
[535]116
[659]117  void ParticleInterface::newEmitter ()
[592]118  {
119    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
[659]120    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_) );
121    numberOfEmitters_++;
[592]122  }
[535]123
[708]124  // TODO check if this really works
[592]125  Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
126  {
127    return particleSystem_->getEmitter(0)->getPosition();
128  }
[535]129
[592]130  void ParticleInterface::setDirection ( Vector3 direction )
131  {
[728]132    for(int i=0; i < numberOfEmitters_; i++) {
[592]133      particleSystem_->getEmitter(i)->setDirection(direction);
134    }
135  }
[535]136
[592]137  void ParticleInterface::switchEnable(){
138    bool enable=(!(particleSystem_->getEmitter(0)->getEnabled()));
[728]139    for(int i=0; i < numberOfEmitters_; i++) {
[592]140      particleSystem_->getEmitter(i)->setEnabled(enable);
141    }
142  }
[535]143
[618]144}
Note: See TracBrowser for help on using the repository browser.