00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024 #ifndef H_SPK_CYLINDER
00025 #define H_SPK_CYLINDER
00026
00027 #include "Core/SPK_Zone.h"
00028
00029 namespace SPK
00030 {
00045 class SPK_PREFIX Cylinder : public Zone
00046 {
00047 SPK_IMPLEMENT_REGISTERABLE(Cylinder)
00048
00049 public :
00050
00052
00054
00061 Cylinder(const Vector3D& position = Vector3D(0.0f,0.0f,0.0f),const Vector3D& direction = Vector3D(0.0f,1.0f,0.0f),float radius = 1.0f,float length = 1.0f);
00062
00070 static Cylinder* create(const Vector3D& position = Vector3D(0.0f,0.0f,0.0f),const Vector3D& direction = Vector3D(0.0f,1.0f,0.0f),float radius = 1.0f,float length = 1.0f);
00071
00073
00075
00083 void setDirection(const Vector3D& direction);
00084
00093 void setRadius(float radius);
00094
00103 void setLength(float length);
00104
00106
00108
00113 const Vector3D& getDirection() const;
00114
00119 const Vector3D& getTransformedDirection() const;
00120
00125 float getRadius() const;
00126
00131 float getLength() const;
00132
00134
00136
00137 virtual void generatePosition(Particle& particle,bool full) const;
00138 virtual bool contains(const Vector3D& v) const;
00139 virtual bool intersects(const Vector3D& v0,const Vector3D& v1,Vector3D* intersection,Vector3D* normal) const;
00140 virtual void moveAtBorder(Vector3D& v,bool inside) const;
00141 virtual Vector3D computeNormal(const Vector3D& point) const;
00142
00143 protected :
00144
00145 virtual void innerUpdateTransform();
00146
00147 private :
00148
00149 Vector3D direction;
00150 Vector3D tDirection;
00151
00152 float radius,length;
00153 };
00154
00155
00156 inline Cylinder* Cylinder::create(const Vector3D& position,const Vector3D& direction,float radius,float length)
00157 {
00158 Cylinder* obj = new Cylinder(position,direction,radius,length);
00159 registerObject(obj);
00160 return obj;
00161 }
00162
00163 inline void Cylinder::setDirection(const Vector3D& direction)
00164 {
00165 this->direction = direction;
00166 this->direction.normalize();
00167 tDirection = this->direction;
00168 notifyForUpdate();
00169 }
00170
00171 inline void Cylinder::setRadius(float radius)
00172 {
00173 this->radius = (radius < 0 ? -radius : radius);
00174 }
00175
00176 inline void Cylinder::setLength(float length)
00177 {
00178 this->length = (length < 0 ? -length : length);
00179 }
00180
00181 inline const Vector3D& Cylinder::getDirection() const
00182 {
00183 return direction;
00184 }
00185
00186 inline const Vector3D& Cylinder::getTransformedDirection() const
00187 {
00188 return tDirection;
00189 }
00190
00191 inline float Cylinder::getRadius() const
00192 {
00193 return radius;
00194 }
00195
00196 inline float Cylinder::getLength() const
00197 {
00198 return length;
00199 }
00200 }
00201
00202 #endif