00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022
00023 #ifndef H_SPK_VORTEX
00024 #define H_SPK_VORTEX
00025
00026 #include "Core/SPK_Modifier.h"
00027
00028 namespace SPK
00029 {
00054 class SPK_PREFIX Vortex : public Modifier
00055 {
00056 SPK_IMPLEMENT_REGISTERABLE(Vortex)
00057
00058 public :
00059
00061
00063
00071 Vortex(const Vector3D& position = Vector3D(),const Vector3D& direction = Vector3D(0.0f,1.0f,0.0f),float rotationSpeed = 1.0f,float attractionSpeed = 0.0f);
00072
00081 static Vortex* create(const Vector3D& position = Vector3D(),const Vector3D& direction = Vector3D(0.0f,1.0f,0.0f),float rotationSpeed = 1.0f,float attractionSpeed = 0.0f);
00082
00084
00086
00094 void setPosition(const Vector3D& position);
00095
00104 void setDirection(const Vector3D& direction);
00105
00119 void setRotationSpeed(float rotationSpeed,bool angular);
00120
00136 void setAttractionSpeed(float attractionSpeed,bool linear);
00137
00145 void setEyeRadius(float eyeRadius);
00146
00151 void enableParticleKilling(bool kill);
00152
00154
00156
00161 const Vector3D& getPosition() const;
00162
00167 const Vector3D& getDirection() const;
00168
00173 const Vector3D& getTransformedPosition() const;
00174
00179 const Vector3D& getTransformedDirection() const;
00180
00185 float getRotationSpeed() const;
00186
00191 float getAttractionSpeed() const;
00192
00197 bool isRotationSpeedAngular() const;
00198
00203 bool isAttractionSpeedLinear() const;
00204
00209 float getEyeRadius() const;
00210
00215 bool isParticleKillingEnabled() const;
00216
00217 protected :
00218
00219 virtual void innerUpdateTransform();
00220
00221 private :
00222
00223 Vector3D position;
00224 Vector3D direction;
00225
00226 Vector3D tPosition;
00227 Vector3D tDirection;
00228
00229 float rotationSpeed;
00230 float attractionSpeed;
00231
00232 bool angularSpeedEnabled;
00233 bool linearSpeedEnabled;
00234
00235 float eyeRadius;
00236 bool killingParticleEnabled;
00237
00238 virtual void modify(Particle& particle,float deltaTime) const;
00239 };
00240
00241
00242 inline Vortex* Vortex::create(const Vector3D& position,const Vector3D& direction,float rotationSpeed,float attractionSpeed)
00243 {
00244 Vortex* obj = new Vortex(position,direction,rotationSpeed,attractionSpeed);
00245 registerObject(obj);
00246 return obj;
00247 }
00248
00249 inline void Vortex::setPosition(const Vector3D& position)
00250 {
00251 this->position = position;
00252 tPosition = this->position;
00253 notifyForUpdate();
00254 }
00255
00256 inline void Vortex::setDirection(const Vector3D& direction)
00257 {
00258 this->direction = direction;
00259 this->direction.normalize();
00260 tDirection = this->direction;
00261 notifyForUpdate();
00262 }
00263
00264 inline void Vortex::setRotationSpeed(float rotationSpeed,bool angular)
00265 {
00266 this->rotationSpeed = rotationSpeed;
00267 angularSpeedEnabled = angular;
00268 }
00269
00270 inline void Vortex::setAttractionSpeed(float attractionSpeed,bool linear)
00271 {
00272 this->attractionSpeed = attractionSpeed;
00273 linearSpeedEnabled = linear;
00274 }
00275
00276 inline void Vortex::setEyeRadius(float eyeRadius)
00277 {
00278 if (eyeRadius < 0.0f) eyeRadius = -eyeRadius;
00279 this->eyeRadius = eyeRadius;
00280 }
00281
00282 inline void Vortex::enableParticleKilling(bool kill)
00283 {
00284 killingParticleEnabled = kill;
00285 }
00286
00287 inline const Vector3D& Vortex::getPosition() const
00288 {
00289 return position;
00290 }
00291
00292 inline const Vector3D& Vortex::getDirection() const
00293 {
00294 return direction;
00295 }
00296
00297 inline const Vector3D& Vortex::getTransformedPosition() const
00298 {
00299 return tPosition;
00300 }
00301
00302 inline const Vector3D& Vortex::getTransformedDirection() const
00303 {
00304 return tDirection;
00305 }
00306
00307 inline float Vortex::getRotationSpeed() const
00308 {
00309 return rotationSpeed;
00310 }
00311
00312 inline float Vortex::getAttractionSpeed() const
00313 {
00314 return attractionSpeed;
00315 }
00316
00317 inline bool Vortex::isRotationSpeedAngular() const
00318 {
00319 return angularSpeedEnabled;
00320 }
00321
00322 inline bool Vortex::isAttractionSpeedLinear() const
00323 {
00324 return linearSpeedEnabled;
00325 }
00326
00327 inline float Vortex::getEyeRadius() const
00328 {
00329 return eyeRadius;
00330 }
00331
00332 inline bool Vortex::isParticleKillingEnabled() const
00333 {
00334 return killingParticleEnabled;
00335 }
00336 }
00337
00338 #endif