AnimatLab  2
Test
BlRigidBody.h
1 // BlRigidBody.h: interface for the BlRigidBody class.
2 //
4 
5 #pragma once
6 
7 #include "BlMaterialType.h"
8 
9 namespace BulletAnimatSim
10 {
11  namespace Environment
12  {
13 
14 
15  class BULLET_PORT BlContactPoint
16  {
17  public:
18  btManifoldPoint *m_lpCP;
19  BlRigidBody *m_lpContacted;
20  bool m_bIsBodyA;
21 
22  BlContactPoint(btManifoldPoint *lpCP, BlRigidBody *lpContacted, bool bIsBodyA)
23  {
24  m_lpCP = lpCP;
25  m_lpContacted = lpContacted;
26  m_bIsBodyA = bIsBodyA;
27  }
28 
29  virtual ~BlContactPoint() {};
30 
31  };
32 
33  class BULLET_PORT BlBulletData
34  {
35  public:
36  BlRigidBody *m_lpBody;
37  bool m_bExclusionProcessing;
38 
39  BlBulletData(BlRigidBody *lpBody, bool bExclusionProcessing)
40  {
41  m_lpBody = lpBody;
42  m_bExclusionProcessing = bExclusionProcessing;
43  }
44 
45  virtual ~BlBulletData() {};
46 
47  };
48 
87  class BULLET_PORT BlRigidBody : public OsgRigidBody
88  {
89  protected:
90  btCollisionShape *m_btCollisionShape;
91  btCollisionObject *m_btCollisionObject;
92  btCompoundShape *m_btCompoundShape;
93  CStdPtrArray<btCollisionShape> m_aryCompoundChildShapes;
94 
95  btAnimatGeneric6DofConstraint *m_btStickyLock;
96  btAnimatGeneric6DofConstraint *m_btStickyLock2;
97 
98  btRigidBody *m_btPart;
99  osgbDynamics::MotionState *m_osgbMotion;
100  BroadphaseNativeTypes m_eBodyType;
101 
102  float m_fltStaticMasses;
103 
106  CStdFPoint m_vArea;
107 
110  CStdFPoint m_vRotatedArea;
111 
114 
117 
119  float m_vLinearDragForce[3];
120 
122  float m_vAngularDragTorque[3];
123 
124  //This is the data that is provided to the bullet body part user pointer.
125  //We can access this when all we have is a bullet pointer to a part.
126  BlBulletData *m_lpBulletData;
127 
128  BlSimulator *m_lpVsSim;
129 
132 
133  virtual void ProcessContacts();
134 
135  virtual void DeleteDynamicPart();
136  virtual void DeleteSensorPart();
137  virtual void DeleteCollisionGeometry();
138  virtual void DeletePhysics(bool bIncludeChildren);
139 
140  virtual void CreateSensorPart();
141  virtual void CreateStaticChildren(const CStdFPoint &vCom);
142  virtual void CreateDynamicPart();
143  virtual void CreateStickyLock();
144  virtual void SetupOffsetCOM(const CStdFPoint &vCom);
145  virtual btAnimatGeneric6DofConstraint *AddDynamicJoint(BlRigidBody *lpParent, BlRigidBody *lpChild);
146 
147  virtual void AddStaticGeometry(BlRigidBody *lpChild, btCompoundShape *btCompound, const CStdFPoint &vCom);
148  virtual void RemoveStaticGeometry(BlRigidBody *lpChild, btCompoundShape *btCompound);
149 
150  CStdFPoint Physics_GetCurrentPosition();
151  virtual void GetBaseValues();
152 
153  virtual void ResetStaticCollisionGeom();
154  virtual void ResetSensorCollisionGeom();
155  virtual void ResetDynamicCollisionGeom();
156 
157  virtual void DeleteChildPhysics();
158  virtual void DeleteAttachedJointPhysics();
159  virtual void RecreateAttachedJointPhysics();
160  virtual void ResizePhysicsGeometry();
161 
162  virtual void CalculateVolumeAndAreas() {};
163  virtual void CalculateRotatedAreas();
164 
165  public:
166  BlRigidBody();
167  virtual ~BlRigidBody();
168 
169  CStdPtrArray<BlContactPoint> m_aryContactPoints;
170 
171  btCompoundShape *CompoundShape() {return m_btCompoundShape;};
172  btCollisionShape *CollisionShape() {return m_btCollisionShape;};
173  btRigidBody *Part() {return m_btPart;};
174  osgbDynamics::MotionState *MotionState() {return m_osgbMotion;};
175  BlMaterialType *Material() {return m_lpMaterial;};
176 
177  virtual BlSimulator *GetBlSimulator();
178 
179  virtual bool NeedCollision(BlRigidBody *lpTest);
180  virtual void SetSurfaceContactCount();
181 
182  virtual bool Physics_IsDefined();
183  virtual bool Physics_IsGeometryDefined();
184  virtual void Physics_ResetSimulation();
185  virtual void Physics_EnableCollision(RigidBody *lpBody);
186  virtual void Physics_DisableCollision(RigidBody *lpBody);
187  virtual void Physics_CollectData();
188  virtual void Physics_CollectExtraData();
189  virtual void Physics_SetFreeze(bool bVal);
190  virtual void Physics_SetMass(float fltVal);
191  virtual void Physics_SetMaterialID(std::string strID);
192  virtual void Physics_SetVelocityDamping(float fltLinear, float fltAngular);
193  virtual void Physics_SetCenterOfMass(float fltTx, float fltTy, float fltTz);
194  virtual void Physics_UpdateNode();
195  virtual void Physics_FluidDataChanged();
196  virtual void Physics_WakeDynamics();
197  virtual void Physics_ContactSensorAdded(ContactSensor *lpSensor);
198  virtual void Physics_ContactSensorRemoved();
199  virtual void Physics_ChildBodyAdded(RigidBody *lpChild);
200  virtual void Physics_ChildBodyRemoved(bool bHasStaticJoint);
201  virtual void Physics_DeleteStickyLock();
202 
203  virtual void Physics_AddBodyForceAtLocalPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits);
204  virtual void Physics_AddBodyForceAtWorldPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits);
205  virtual void Physics_AddBodyTorque(float fltTx, float fltTy, float fltTz, bool bScaleUnits);
206  virtual CStdFPoint Physics_GetVelocityAtPoint(float x, float y, float z);
207  virtual float Physics_GetMass();
208  virtual float Physics_GetDensity();
209  virtual bool Physics_HasCollisionGeometry();
210  virtual void Physics_StepHydrodynamicSimulation();
211  virtual float *Physics_GetDataPointer(const std::string &strDataType);
212 
213  virtual osg::Matrix GetPhysicsWorldMatrix();
214 
215  virtual void MaterialTypeModified();
216 
217  friend class BlJoint;
218  };
219 
220  } // Environment
221 } //BulletAnimatSim
A common class for all rigid body data specific to vortex.
Definition: BlRigidBody.h:87
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
BlMaterialType * m_lpMaterial
The pointer to the material for this body.
Definition: BlRigidBody.h:131
float m_fltReportBuoyancy
The buoyancy force reported to the GUI.
Definition: BlRigidBody.h:116
float m_fltBuoyancy
The buoyancy force applied to this part.
Definition: BlRigidBody.h:113