[535] | 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 | #include "ParticleInterface.h" |
---|
[618] | 29 | // #include <OgreParticleSystem.h> |
---|
| 30 | // #include <Ogre.h> |
---|
[544] | 31 | //#include <OIS/OIS.h> |
---|
[535] | 32 | // #include <CEGUI/CEGUI.h> |
---|
| 33 | // #include <CEGUIRenderer.h> |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | using namespace Ogre; |
---|
| 37 | |
---|
| 38 | namespace particle { |
---|
| 39 | |
---|
[592] | 40 | ParticleInterface::~ParticleInterface(void) |
---|
| 41 | { |
---|
| 42 | sceneManager_->destroyParticleSystem(particleSystem_); |
---|
[535] | 43 | |
---|
[592] | 44 | delete sceneNode_; |
---|
| 45 | delete particleSystem_; |
---|
| 46 | delete sceneManager_; |
---|
| 47 | } |
---|
[535] | 48 | |
---|
[592] | 49 | ParticleInterface::ParticleInterface( SceneManager *sceneManager, String name, String templateName ) |
---|
| 50 | { |
---|
| 51 | sceneManager_ = sceneManager; |
---|
| 52 | particleSystem_ = sceneManager->createParticleSystem(name, templateName); |
---|
[535] | 53 | |
---|
[592] | 54 | //Variabeln einlesen, Emitter1_ ist Referenz-Emitter |
---|
| 55 | velocity_ = particleSystem_->getSpeedFactor(); |
---|
| 56 | colour_ = particleSystem_->getEmitter(0)->getColour(); |
---|
| 57 | rate_ = particleSystem_->getEmitter(0)->getEmissionRate(); |
---|
| 58 | distance_ = particleSystem_->getEmitter(0)->getTimeToLive(); |
---|
[535] | 59 | |
---|
[592] | 60 | //Anzahl der Emitter |
---|
| 61 | numberOfEmitters_ = particleSystem_->getNumEmitters(); |
---|
| 62 | standardizeEmitters(); |
---|
| 63 | } |
---|
[535] | 64 | |
---|
[592] | 65 | void ParticleInterface::standardizeEmitters(void) |
---|
| 66 | { |
---|
| 67 | //Abgleichen der anderen Emitter an die Variabeln |
---|
| 68 | for (int i=1; i<numberOfEmitters_; i++) { |
---|
| 69 | particleSystem_->getEmitter(i)->setColour( colour_ ); |
---|
| 70 | particleSystem_->getEmitter(i)->setTimeToLive( distance_ ); |
---|
| 71 | particleSystem_->getEmitter(i)->setEmissionRate( rate_ ); |
---|
| 72 | } |
---|
[535] | 73 | |
---|
[592] | 74 | } |
---|
[535] | 75 | |
---|
[592] | 76 | void ParticleInterface::addToSceneNode( SceneNode* sceneNode ) |
---|
| 77 | { |
---|
| 78 | sceneNode_ = sceneNode; |
---|
| 79 | sceneNode_->attachObject(particleSystem_); |
---|
| 80 | } |
---|
[535] | 81 | |
---|
[592] | 82 | void ParticleInterface::dettachFromSceneNode ( void ) |
---|
| 83 | { |
---|
| 84 | sceneNode_->detachObject(particleSystem_); |
---|
| 85 | sceneNode_ = NULL; |
---|
| 86 | } |
---|
[535] | 87 | |
---|
[592] | 88 | Real ParticleInterface::getVelocity() |
---|
| 89 | { |
---|
| 90 | return velocity_; |
---|
| 91 | } |
---|
[535] | 92 | |
---|
[592] | 93 | void ParticleInterface::setVelocity(Real v) |
---|
| 94 | { |
---|
| 95 | velocity_ = v; |
---|
| 96 | //partikel anpassen |
---|
| 97 | particleSystem_->setSpeedFactor(v); |
---|
| 98 | } |
---|
[535] | 99 | |
---|
[592] | 100 | int ParticleInterface::getRate() |
---|
| 101 | { |
---|
| 102 | return rate_; |
---|
| 103 | } |
---|
| 104 | void ParticleInterface::setRate(int r) |
---|
| 105 | { |
---|
| 106 | rate_ = r; |
---|
| 107 | //partikel anpassen |
---|
| 108 | for (int i=0; i<numberOfEmitters_; i++) { |
---|
| 109 | particleSystem_->getEmitter(i)->setEmissionRate(rate_); |
---|
| 110 | } |
---|
| 111 | } |
---|
[535] | 112 | |
---|
[592] | 113 | Real ParticleInterface::getDistance() |
---|
| 114 | { |
---|
| 115 | return distance_; |
---|
| 116 | } |
---|
[535] | 117 | |
---|
[592] | 118 | void ParticleInterface::setDistance(Real d) |
---|
| 119 | { |
---|
| 120 | distance_ = d; |
---|
| 121 | //partikel anpassen |
---|
| 122 | for (int i=0; i<numberOfEmitters_; i++) { |
---|
| 123 | particleSystem_->getEmitter(i)->setTimeToLive(distance_); |
---|
| 124 | } |
---|
| 125 | } |
---|
| 126 | ColourValue ParticleInterface::getColour() |
---|
| 127 | { |
---|
| 128 | return colour_; |
---|
| 129 | } |
---|
[535] | 130 | |
---|
[592] | 131 | void ParticleInterface::setColour(ColourValue colour) |
---|
| 132 | { |
---|
| 133 | colour_ = colour; |
---|
| 134 | //partikel anpassen |
---|
| 135 | for (int i=0; i<numberOfEmitters_; i++) { |
---|
| 136 | particleSystem_->getEmitter(i)->setColour(colour_); |
---|
| 137 | } |
---|
| 138 | } |
---|
[535] | 139 | |
---|
[592] | 140 | ParticleEmitter* ParticleInterface::getEmitter( int emitterNr ) |
---|
| 141 | { |
---|
| 142 | if (!(emitterNr<numberOfEmitters_)) return NULL; |
---|
| 143 | return particleSystem_->getEmitter(emitterNr); |
---|
| 144 | } |
---|
[535] | 145 | |
---|
[592] | 146 | void ParticleInterface::newEmitter ( void ) |
---|
| 147 | { |
---|
| 148 | particleSystem_->addEmitter(particleSystem_->getEmitter(0)->getType()); |
---|
| 149 | numberOfEmitters_=numberOfEmitters_+1; |
---|
| 150 | particleSystem_->getEmitter(0)->copyParametersTo( particleSystem_->getEmitter(numberOfEmitters_-1) ); |
---|
| 151 | } |
---|
[535] | 152 | |
---|
[592] | 153 | void ParticleInterface::setPositionOfEmitter ( int emitterNr, Vector3 position ) |
---|
| 154 | { |
---|
| 155 | particleSystem_->getEmitter(emitterNr)->setPosition(position); |
---|
| 156 | } |
---|
[535] | 157 | |
---|
[592] | 158 | Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr ) |
---|
| 159 | { |
---|
| 160 | return particleSystem_->getEmitter(0)->getPosition(); |
---|
| 161 | } |
---|
[535] | 162 | |
---|
[592] | 163 | void ParticleInterface::setDirection ( Vector3 direction ) |
---|
| 164 | { |
---|
| 165 | for(int i=0; i<numberOfEmitters_; i++) { |
---|
| 166 | particleSystem_->getEmitter(i)->setDirection(direction); |
---|
| 167 | } |
---|
| 168 | } |
---|
[535] | 169 | |
---|
| 170 | |
---|
[592] | 171 | Vector3 ParticleInterface::getDirection ( void ) |
---|
| 172 | { |
---|
| 173 | return particleSystem_->getEmitter(0)->getDirection(); |
---|
| 174 | } |
---|
[535] | 175 | |
---|
[592] | 176 | void ParticleInterface::switchEnable(){ |
---|
| 177 | bool enable=(!(particleSystem_->getEmitter(0)->getEnabled())); |
---|
| 178 | for(int i=0; i<numberOfEmitters_; i++) { |
---|
| 179 | particleSystem_->getEmitter(i)->setEnabled(enable); |
---|
| 180 | } |
---|
| 181 | } |
---|
[535] | 182 | |
---|
[618] | 183 | } |
---|