Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

massparticle.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                massparticle.h  -  Massive particle physics node
00003                              -------------------
00004     begin                : Sat Jan 3 2004
00005     copyright            : (C) 2004 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, massparticle.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2004
00023  Reality Rift Studios. All Rights Reserved.
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

Generated on Wed Jan 21 14:21:06 2004 for NeoEngine by doxygen 1.3.5