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_OBSTACLE
00024 #define H_SPK_OBSTACLE
00025
00026 #include "Core/SPK_Modifier.h"
00027 #include "Core/SPK_Particle.h"
00028 #include "Core/SPK_Zone.h"
00029
00030 namespace SPK
00031 {
00036 class SPK_PREFIX Obstacle : public Modifier
00037 {
00038 SPK_IMPLEMENT_REGISTERABLE(Obstacle)
00039
00040 public :
00041
00043
00045
00053 Obstacle(Zone* zone = NULL,ModifierTrigger trigger = INTERSECT_ZONE,float bouncingRatio = 1.0f,float friction = 1.0f);
00054
00064 static Obstacle* create(Zone* zone = NULL,ModifierTrigger trigger = INTERSECT_ZONE,float bouncingRatio = 1.0f,float friction = 1.0f);
00065
00067
00069
00077 void setBouncingRatio(float bouncingRatio);
00078
00086 void setFriction(float friction);
00087
00089
00091
00096 float getBouncingRatio() const;
00097
00102 float getFriction() const;
00103
00104 private :
00105
00106 float bouncingRatio;
00107 float friction;
00108
00109 virtual void modify(Particle& particle,float deltaTime) const;
00110 virtual void modifyWrongSide(Particle& particle,bool inside) const;
00111 };
00112
00113
00114 inline Obstacle* Obstacle::create(Zone* zone,ModifierTrigger trigger,float bouncingRatio,float friction)
00115 {
00116 Obstacle* obj = new Obstacle(zone,trigger,bouncingRatio,friction);
00117 registerObject(obj);
00118 return obj;
00119 }
00120
00121 inline void Obstacle::setBouncingRatio(float bouncingRatio)
00122 {
00123 this->bouncingRatio = bouncingRatio < 0.0f ? 0.0f : bouncingRatio;
00124 }
00125
00126 inline void Obstacle::setFriction(float friction)
00127 {
00128 this->friction = friction;
00129 }
00130
00131 inline float Obstacle::getBouncingRatio() const
00132 {
00133 return bouncingRatio;
00134 }
00135
00136 inline float Obstacle::getFriction() const
00137 {
00138 return friction;
00139 }
00140
00141 inline void Obstacle::modifyWrongSide(Particle& particle,bool inside) const
00142 {
00143 if (isFullZone())
00144 getZone()->moveAtBorder(particle.position(),inside);
00145 }
00146 }
00147
00148 #endif