Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/particle/ParticleInterface.cc @ 1262

Last change on this file since 1262 was 1039, checked in by rgrieder, 17 years ago
  • train riding doesn't have to be boring
  • added some license notes
  • removed certain header dependencies in audio
  • changed order of header file inclusion in orxonox and audio (coding style guide will be updated)
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
[786]33#include "OrxonoxStableHeaders.h"
[1039]34#include "ParticleInterface.h"
[784]35
[618]36// #include <OgreParticleSystem.h>
37// #include <Ogre.h>
[708]38// #include <OIS/OIS.h>
[535]39// #include <CEGUI/CEGUI.h>
40// #include <CEGUIRenderer.h>
41
42
43
[708]44namespace orxonox {
45  using namespace Ogre;
[535]46
[715]47  ParticleInterface::ParticleInterface( SceneManager *sceneManager, std::string name, std::string templateName )
[592]48  {
49    sceneManager_ = sceneManager;
50    particleSystem_ = sceneManager->createParticleSystem(name, templateName);
[535]51
[592]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();
[535]57
[592]58    //Anzahl der Emitter
59    numberOfEmitters_ = particleSystem_->getNumEmitters();
60    standardizeEmitters();
61  }
[535]62
[659]63  ParticleInterface::~ParticleInterface(void)
64  {
65    sceneManager_->destroyParticleSystem(particleSystem_);
66  }
67
[592]68  void ParticleInterface::standardizeEmitters(void)
69  {
70    //Abgleichen der anderen Emitter an die Variabeln
[1037]71    for (int i=0; i < numberOfEmitters_; i++) {
[592]72      particleSystem_->getEmitter(i)->setColour( colour_ );
73      particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
74      particleSystem_->getEmitter(i)->setEmissionRate( rate_ );
75    }
[535]76
[592]77  }
[535]78
[592]79  void ParticleInterface::setVelocity(Real v)
80  {
81    velocity_ = v;
82    //partikel anpassen
83    particleSystem_->setSpeedFactor(v);
84  }
[535]85
[1037]86  void ParticleInterface::setRate(float r)
[592]87  {
88    rate_ = r;
89    //partikel anpassen
90    for (int i=0; i<numberOfEmitters_; i++) {
91      particleSystem_->getEmitter(i)->setEmissionRate(rate_);
92    }
93  }
[535]94
[592]95  void ParticleInterface::setDistance(Real d)
96  {
97    distance_ = d;
98    //partikel anpassen
[659]99    for (int i=0; i < numberOfEmitters_; i++) {
[592]100      particleSystem_->getEmitter(i)->setTimeToLive(distance_);
101    }
102  }
[535]103
[592]104  void ParticleInterface::setColour(ColourValue colour)
105  {
106    colour_ = colour;
107    //partikel anpassen
[659]108    for (int i=0; i < numberOfEmitters_; i++) {
[592]109      particleSystem_->getEmitter(i)->setColour(colour_);
110    }
111  }
[535]112
[592]113  ParticleEmitter* ParticleInterface::getEmitter( int emitterNr )
114  {
[659]115    if ( (emitterNr >= numberOfEmitters_) || (emitterNr < 0) ) return NULL;
[592]116    return particleSystem_->getEmitter(emitterNr);
117  }
[535]118
[659]119  void ParticleInterface::newEmitter ()
[592]120  {
121    particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType());
[659]122    particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_) );
123    numberOfEmitters_++;
[592]124  }
[535]125
[708]126  // TODO check if this really works
[592]127  Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
128  {
[1037]129    return particleSystem_->getEmitter(emitterNr)->getPosition();
[592]130  }
[535]131
[592]132  void ParticleInterface::setDirection ( Vector3 direction )
133  {
[728]134    for(int i=0; i < numberOfEmitters_; i++) {
[592]135      particleSystem_->getEmitter(i)->setDirection(direction);
136    }
137  }
[535]138
[592]139  void ParticleInterface::switchEnable(){
140    bool enable=(!(particleSystem_->getEmitter(0)->getEnabled()));
[728]141    for(int i=0; i < numberOfEmitters_; i++) {
[592]142      particleSystem_->getEmitter(i)->setEnabled(enable);
143    }
144  }
[535]145
[618]146}
Note: See TracBrowser for help on using the repository browser.