00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022 #ifndef H_SPK_RING
00023 #define H_SPK_RING
00024
00025 #include "Core/SPK_Zone.h"
00026
00027 namespace SPK
00028 {
00043 class SPK_PREFIX Ring : public Zone
00044 {
00045 SPK_IMPLEMENT_REGISTERABLE(Ring)
00046
00047 public :
00048
00050
00052
00060 Ring(const Vector3D& position = Vector3D(0.0f,0.0f,0.0f),const Vector3D& normal = Vector3D(0.0f,1.0f,0.0f),float minRadius = 0.0f,float maxRadius = 1.0f);
00061
00070 static Ring* create(const Vector3D& position = Vector3D(0.0f,0.0f,0.0f),const Vector3D& normal = Vector3D(0.0f,1.0f,0.0f),float minRadius = 0.0f,float maxRadius = 1.0f);
00071
00073
00075
00083 void setNormal(const Vector3D& normal);
00084
00094 void setRadius(float minRadius,float maxRadius);
00095
00097
00099
00104 const Vector3D& getNormal() const;
00105
00110 const Vector3D& getTransformedNormal() const;
00111
00116 float getMinRadius() const;
00117
00122 float getMaxRadius() const;
00123
00125
00127
00128 virtual void generatePosition(Particle& particle,bool full) const;
00129 virtual bool contains(const Vector3D& v) const;
00130 virtual bool intersects(const Vector3D& v0,const Vector3D& v1,Vector3D* intersection,Vector3D* normal) const;
00131 virtual void moveAtBorder(Vector3D& v,bool inside) const;
00132 virtual Vector3D computeNormal(const Vector3D& point) const;
00133
00134 protected :
00135
00136 virtual void innerUpdateTransform();
00137
00138 private :
00139
00140 Vector3D normal;
00141 Vector3D tNormal;
00142
00143 float minRadius;
00144 float maxRadius;
00145
00146
00147 float sqrMinRadius;
00148 float sqrMaxRadius;
00149 };
00150
00151
00152 inline Ring* Ring::create(const Vector3D& position,const Vector3D& normal,float minRadius,float maxRadius)
00153 {
00154 Ring* obj = new Ring(position,normal,minRadius,maxRadius);
00155 registerObject(obj);
00156 return obj;
00157 }
00158
00159 inline void Ring::setNormal(const Vector3D& normal)
00160 {
00161 this->normal = normal;
00162 this->normal.normalize();
00163 tNormal = this->normal;
00164 notifyForUpdate();
00165 }
00166
00167 inline const Vector3D& Ring::getNormal() const
00168 {
00169 return normal;
00170 }
00171
00172 inline const Vector3D& Ring::getTransformedNormal() const
00173 {
00174 return tNormal;
00175 }
00176
00177 inline float Ring::getMinRadius() const
00178 {
00179 return minRadius;
00180 }
00181
00182 inline float Ring::getMaxRadius() const
00183 {
00184 return maxRadius;
00185 }
00186
00187 inline bool Ring::contains(const Vector3D& v) const
00188 {
00189 return false;
00190 }
00191
00192 inline Vector3D Ring::computeNormal(const Vector3D& point) const
00193 {
00194 return tNormal;
00195 }
00196 }
00197
00198 #endif