00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __NEMASSPARTICLE_H
00028 #define __NEMASSPARTICLE_H
00029
00030
00037 #include "base.h"
00038 #include "physicsnode.h"
00039
00040 #include <vector>
00041
00042
00043 namespace NeoEngine
00044 {
00045
00046
00051 class NEOENGINE_API MassParticleState
00052 {
00053 public:
00054
00056 Vector3d m_kForce;
00057
00059 float m_fMass;
00060
00062 float m_fInvMass;
00063
00064
00067 MassParticleState() {}
00068
00074 MassParticleState( const Vector3d &rkForce, float fMass, float fInvMass ) : m_kForce( rkForce ), m_fMass( fMass ), m_fInvMass( fInvMass ) {}
00075
00079 MassParticleState( const MassParticleState &rkState ) : m_kForce( rkState.m_kForce ), m_fMass( rkState.m_fMass ), m_fInvMass( rkState.m_fInvMass ) {}
00080
00086 bool operator < ( const MassParticleState &rkState ) const { return( false ); }
00087
00093 bool operator == ( const MassParticleState &rkState ) const { return( ( m_kForce == rkState.m_kForce ) && ( m_fMass == rkState.m_fMass ) && ( m_fInvMass == rkState.m_fInvMass ) ); }
00094 };
00095
00096
00097 #ifdef WIN32
00098 # ifdef _MSC_VER
00099 # pragma warning( disable : 4231 )
00100 # endif
00101 # ifndef __HAVE_VECTOR_NEMASSPARTICLESTATEOBJ
00102 UDTVectorEXPIMP( MassParticleState );
00103 # define __HAVE_VECTOR_NEMASSPARTICLESTATEOBJ
00104 # endif
00105 #endif
00106
00107
00113 class NEOENGINE_API MassParticle : public PhysicsNode
00114 {
00115 private:
00116
00118 std::vector< MassParticleState > m_vkStateStack;
00119
00120
00121
00122 protected:
00123
00125 Vector3d m_kForce;
00126
00128 float m_fMass;
00129
00131 float m_fInvMass;
00132
00133
00134
00135 public:
00136
00139 MassParticle();
00140
00143 virtual ~MassParticle();
00144
00149 virtual SceneNode *Duplicate();
00150
00155 void SetMass( float fMass );
00156
00160 inline float GetMass() const { return m_fMass; }
00161
00165 inline float GetInvMass() const { return m_fInvMass; }
00166
00172 const Vector3d &ApplyForce( const Vector3d &rkForce );
00173
00178 void ApplyImpulse( const Vector3d &rkImpulse );
00179
00183 void ResetForce();
00184
00188 inline const Vector3d &GetForce() const { return m_kForce; }
00189
00194 virtual void Update( float fDeltaTime );
00195
00199 virtual void PushState();
00200
00205 virtual void PopState( bool bSet = true );
00206
00210 virtual void ClearState();
00211 };
00212
00213
00214 };
00215
00216
00217 #endif