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_LINEARFORCE
00024 #define H_SPK_LINEARFORCE
00025
00026 #include "Core/SPK_Modifier.h"
00027 #include "Core/SPK_Model.h"
00028
00029
00030 namespace SPK
00031 {
00037 enum ForceFactor
00038 {
00039 FACTOR_NONE,
00040 FACTOR_LINEAR,
00041 FACTOR_SQUARE,
00042 };
00043
00059 class SPK_PREFIX LinearForce : public Modifier
00060 {
00061 SPK_IMPLEMENT_REGISTERABLE(LinearForce)
00062
00063 public :
00064
00066
00068
00077 LinearForce(Zone* zone = NULL,
00078 ModifierTrigger trigger = INSIDE_ZONE,
00079 const Vector3D& force = Vector3D(),
00080 ForceFactor type = FACTOR_NONE,
00081 ModelParam param = PARAM_SIZE);
00082
00093 static LinearForce* create(Zone* zone = NULL,
00094 ModifierTrigger trigger = INSIDE_ZONE,
00095 const Vector3D& force = Vector3D(),
00096 ForceFactor type = FACTOR_NONE,
00097 ModelParam param = PARAM_SIZE);
00098
00100
00102
00108 void setForce(const Vector3D& force);
00109
00115 void setFactor(ForceFactor type,ModelParam param = PARAM_SIZE);
00116
00118
00120
00126 const Vector3D& getForce() const;
00127
00133 const Vector3D& getTransformedForce() const;
00134
00139 ForceFactor getFactorType() const;
00140
00145 ModelParam getFactorParam() const;
00146
00147 protected :
00148
00149 virtual void innerUpdateTransform();
00150
00151 private :
00152
00153 Vector3D force;
00154 Vector3D tForce;
00155
00156 ForceFactor factorType;
00157 ModelParam factorParam;
00158
00159 virtual void modify(Particle& particle,float deltaTime) const;
00160 };
00161
00162
00163 inline LinearForce* LinearForce::create(Zone* zone,ModifierTrigger trigger,const Vector3D& force,ForceFactor type,ModelParam param)
00164 {
00165 LinearForce* obj = new LinearForce(zone,trigger,force,type,param);
00166 registerObject(obj);
00167 return obj;
00168 }
00169
00170 inline void LinearForce::setForce(const Vector3D& force)
00171 {
00172 this->force = tForce = force;
00173 notifyForUpdate();
00174 }
00175
00176 inline void LinearForce::setFactor(ForceFactor type,ModelParam param)
00177 {
00178 factorType = type;
00179 factorParam = param;
00180 }
00181
00182 inline const Vector3D& LinearForce::getForce() const
00183 {
00184 return force;
00185 }
00186
00187 inline const Vector3D& LinearForce::getTransformedForce() const
00188 {
00189 return tForce;
00190 }
00191
00192 inline ForceFactor LinearForce::getFactorType() const
00193 {
00194 return factorType;
00195 }
00196
00197 inline ModelParam LinearForce::getFactorParam() const
00198 {
00199 return factorParam;
00200 }
00201
00202 inline void LinearForce::innerUpdateTransform()
00203 {
00204 Modifier::innerUpdateTransform();
00205 transformDir(tForce,force);
00206 }
00207 }
00208
00209 #endif