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