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

physics.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                     physics.h  -  Physics simulation classes
00003                              -------------------
00004     begin                : Tue Nov 6 2001
00005     copyright            : (C) 2001 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, physics.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2001
00023  Reality Rift Studios. All Rights Reserved.
00024 
00025  ***************************************************************************/
00026 
00027 #ifndef __NEPHYSICS_H
00028 #define __NEPHYSICS_H
00029 
00030 
00037 #include "base.h"
00038 #include "nemath.h"
00039 #include "room.h"
00040 #include "updateentity.h"
00041 #include "rigidbody.h"
00042 #include "contact.h"
00043 
00044 #include <vector>
00045 
00046 
00047 namespace NeoEngine
00048 {
00049 
00050 
00051 #ifdef WIN32
00052 #  ifdef _MSC_VER
00053 #    pragma warning( disable : 4231 )
00054 #  endif
00055 #  ifndef __HAVE_VECTOR_NERIGIDBODY
00056      UDTVectorEXPIMP( RigidBody* );
00057 #    define __HAVE_VECTOR_NERIGIDBODY
00058 #  endif
00059 #  ifndef __HAVE_VECTOR_NECONTACTSET
00060      UDTVectorEXPIMP( ContactSet* );
00061 #    define __HAVE_VECTOR_NECONTACTSET
00062 #  endif
00063 #  ifndef __HAVE_VECTOR_NECONTACTNODE
00064      UDTVectorEXPIMP( class ContactNode* );
00065 #    define __HAVE_VECTOR_NECONTACTNODE
00066 #  endif
00067 #  ifndef __HAVE_VECTOR_NEMATRIX
00068      UDTVectorEXPIMP( Matrix* );
00069 #    define __HAVE_VECTOR_NEMATRIX
00070 #  endif
00071 #endif
00072 
00073 
00078 class NEOENGINE_API ContactNode
00079 {
00080     public:
00081 
00085         enum CONTACTMODE
00086         {
00088           COLLISION,
00089 
00091           CONTACT,
00092 
00094           SHOCKPROPAGATION,
00095         };
00096 
00097 
00099         RigidBody                                    *m_pkBody;
00100 
00102         std::vector< ContactNode* >                   m_vpkParents;
00103 
00105         std::vector< ContactSet* >                    m_vpkContactSets;
00106 
00108         std::vector< Matrix* >                        m_vpkCollisionMatrix;
00109 
00111         std::vector< Matrix* >                        m_vpkInvCollisionMatrix;
00112 
00114         std::vector< ContactNode* >                   m_vpkChildren;
00115 
00117         bool                                          m_bVisited;
00118 
00120         bool                                          m_bFree;
00121 
00122 
00126                                                       ContactNode( RigidBody *pkBody );
00127 
00130         virtual                                      ~ContactNode();
00131 
00138         bool                                          Solve( CONTACTMODE eMode, unsigned int uiPass, unsigned int uiNumPasses );
00139 
00143         void                                          ResetVisited();
00144 
00150         void                                          AddContact( ContactNode *pkParent, ContactSet *pkSet );
00151 
00155         void                                          Clear();
00156 };
00157 
00158 
00163 class NEOENGINE_API PhysicsManager : public virtual UpdateEntity
00164 {
00165     public:
00166 
00170         enum PHYSICSMANAGERDEFS
00171         {
00173           DEFAULTCOLLISIONPASSES                      = 5,
00174 
00176           DEFAULTCONTACTPASSES                        = 5
00177         };
00178 
00179 
00180     protected:
00181 
00183         unsigned int                                  m_uiCollisionPasses;
00184 
00186         unsigned int                                  m_uiContactPasses;
00187 
00189         Room                                         *m_pkRoom;
00190 
00192         Vector3d                                      m_kGravity;
00193 
00195         std::vector< RigidBody* >                     m_vpkBodies;
00196 
00198         std::vector< ContactNode* >                   m_vpkBodyNodes;
00199 
00200 
00201     public:
00202 
00203 
00207                                                       PhysicsManager( Room *pkRoom, unsigned int uiCollisionPasses = DEFAULTCOLLISIONPASSES, unsigned int uiContactPasses = DEFAULTCONTACTPASSES );
00208 
00211         virtual                                      ~PhysicsManager();
00212 
00217         void                                          SetGravity( const Vector3d &rkGravity );
00218 
00223         virtual void                                  Update( float fDeltaTime );
00224 
00229         virtual void                                  AddRigidBody( RigidBody *pkBody );
00230 
00235         virtual void                                  RemoveRigidBody( RigidBody *pkBody );
00236 
00241         const std::vector< RigidBody* >              &GetRigidBodies() { return m_vpkBodies; }
00242 };
00243 
00244 
00245 };
00246 
00247 
00248 #endif

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