AnimatLab  2
Test
BlSimulator.h
1 
2 #pragma once
3 
4 #include "BlMaterialType.h"
5 #include "BlAnimatCollisionDispatcher.h"
6 
12 namespace BulletAnimatSim
13 {
14 
15  class BULLET_PORT BlSimulator : public OsgSimulator
16  {
17  protected:
18  btDefaultCollisionConfiguration *m_lpCollisionConfiguration;
19  BlAnimatCollisionDispatcher *m_lpDispatcher;
20  btConstraintSolver *m_lpSolver;
21  btBroadphaseInterface *m_lpBroadPhase;
22  btDiscreteDynamicsWorld *m_lpDynamicsWorld;
23  osgbCollision::GLDebugDrawer m_dbgDraw;
24 
25  std::list<FluidPlane *> m_aryFluidPlanes;
26 
27  bool m_bDrawDebug;
28 
29  double m_dblTotalVortexStepTime;
30  long m_lStepVortexTimeCount;
31 
32  int m_iSubstepCallbackCount;
33 
34  virtual AnimatSim::Recording::SimulationRecorder *CreateSimulationRecorder();
35 
36  //helper functions
37  void InitializeBullet(int argc, const char **argv);
38  void InitializeBulletViewer(int argc, const char **argv);
39  void SetSimulationStabilityParams();
40 
41  virtual void StepSimulation();
42  virtual void SimulateEnd();
43 
44  public:
45  BlSimulator();
46  virtual ~BlSimulator();
47 
48  btDefaultCollisionConfiguration *CollisionConfig() {return m_lpCollisionConfiguration;};
49  btCollisionDispatcher *Dispatcher() {return m_lpDispatcher;};
50  btConstraintSolver *Solver() {return m_lpSolver;};
51  btBroadphaseInterface *BroadPhase() {return m_lpBroadPhase;}
52  btDiscreteDynamicsWorld *DynamicsWorld() {return m_lpDynamicsWorld;};
53 
54 #pragma region CreateMethods
55 
56  virtual void GenerateCollisionMeshFile(std::string strOriginalMeshFile, std::string strCollisionMeshFile, float fltScaleX, float fltScaleY, float fltScaleZ);
57  virtual void ConvertV1MeshFile(std::string strOriginalMeshFile, std::string strNewMeshFile, std::string strTexture);
58 
59 #pragma endregion
60 
61 #pragma region MutatorOverrides
62 
63  virtual void StabilityScale(float fltVal);
64  virtual void LinearCompliance(float fltVal, bool bUseScaling = true);
65  virtual void AngularCompliance(float fltVal, bool bUseScaling = true);
66  virtual void LinearDamping(float fltVal, bool bUseScaling = true);
67  virtual void AngularDamping(float fltVal, bool bUseScaling = true);
68  virtual void LinearKineticLoss(float fltVal, bool bUseScaling = true);
69  virtual void AngularKineticLoss(float fltVal, bool bUseScaling = true);
70 
71  virtual void Gravity(float fltVal, bool bUseScaling = true);
72 
73 #pragma endregion
74 
75 #pragma region HelperMethods
76 
77  virtual void GetPositionAndRotationFromD3DMatrix(float (&aryTransform)[4][4], CStdFPoint &vPos, CStdFPoint &vRot);
78 
79 #pragma endregion
80 
81 #pragma region FluidMethods
82 
83  virtual void AddFluidPlane(FluidPlane *lpPlane);
84  virtual void RemoveFluidPlane(FluidPlane *lpPlane);
85  virtual bool HasFluidPlane(FluidPlane *lpPlane);
86  virtual void SortFluidPlanes();
87  virtual FluidPlane *FindFluidPlaneForDepth(float fltDepth);
88 
89 #pragma endregion
90 
91  void BulletStepFinished(btScalar timeStep);
92 
93  virtual void Reset(); //Resets the entire application back to the default state
94  virtual void ResetSimulation(); //Resets the current simulation back to time 0.0
95  virtual void Initialize(int argc, const char **argv);
96  };
97 
98 } //BulletAnimatSim
Records the simulation keyframes and videos.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.