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