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