AnimatLab  2
Test
BlFluidPlane.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "BlJoint.h"
9 #include "BlMotorizedJoint.h"
10 #include "BlRigidBody.h"
11 #include "BlFluidPlane.h"
12 #include "BlSimulator.h"
13 
14 namespace BulletAnimatSim
15 {
16  namespace Environment
17  {
18  namespace Bodies
19  {
20 
28 {
29  SetThisPointers();
30 }
31 
39 {
40  try
41  {
42  DeleteGraphics();
43  DeletePhysics(false);
44  }
45  catch(...)
46  {Std_TraceMsg(0, "Caught Error in desctructor of BlFluidPlane/\r\n", "", -1, false, true);}
47 }
48 
49 float BlFluidPlane::Height()
50 {
51  CStdFPoint vPos = GetOSGWorldCoords();
52  return vPos.y;
53 }
54 
55 void BlFluidPlane::CreateGraphicsGeometry()
56 {
57  m_osgGeometry = CreateBoxGeometry(m_ptSize.x, m_ptSize.y, 0.1f, (m_ptSize.x/GridX()), (m_ptSize.y/GridY()), 0.1f);
58 }
59 
60 void BlFluidPlane::CreatePhysicsGeometry()
61 {
62 }
63 
65 {
66  CreateGeometry();
67 
68  //Create the geometry and osg drawable nodes.
69  m_eControlType = DynamicsControlType::ControlNode; //This is not a dynamic part.
70 
71  BlRigidBody::CreateItem();
72  FluidPlane::CreateParts();
73 }
74 
75 void BlFluidPlane::ResizePhysicsGeometry()
76 {
77 }
78 
79 //Planes can never have fluid interactions/dynamics.
80 void BlFluidPlane::Physics_FluidDataChanged()
81 {}
82 
83 void BlFluidPlane::UpdateFluidPlaneHeight()
84 {
85  BlSimulator *lpSim = GetBlSimulator();
86  //Remove this fluid plane from the simulation.
87  if(lpSim)
88  lpSim->SortFluidPlanes();
89 }
90 
91 void BlFluidPlane::Position(CStdFPoint &oPoint, bool bUseScaling, bool bFireChangeEvent, bool bUpdateMatrix)
92 {
93  FluidPlane::Position(oPoint, bUseScaling, bFireChangeEvent, bUpdateMatrix);
94  UpdateFluidPlaneHeight();
95 }
96 
97 void BlFluidPlane::Physics_PositionChanged()
98 {
99  BlRigidBody::Physics_PositionChanged();
100  UpdateFluidPlaneHeight();
101 }
102 
103 void BlFluidPlane::DeletePhysics(bool bIncludeChildren)
104 {
105  //Remove this fluid plane from the simulation.
106  BlSimulator *lpSim = GetBlSimulator();
107  if(lpSim)
108  lpSim->RemoveFluidPlane(this);
109 }
110 
111 void BlFluidPlane::SetupPhysics()
112 {
113  //Add this fluid plane to the simulation.
114  BlSimulator *lpSim = GetBlSimulator();
115  if(lpSim)
116  lpSim->AddFluidPlane(this);
117 }
118 
119 
120  } //Bodies
121  } // Environment
122 } //BulletAnimatSim
virtual float GridY()
Gets the length of a segment for the y dimension of the plane.
Definition: Plane.cpp:118
virtual CStdFPoint Position()
Gets the local position. (m_oPosition)
Definition: RigidBody.cpp:131
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
virtual float GridX()
Gets the width of a segment for the x dimension of the plane.
Definition: Plane.cpp:104
virtual void CreateParts()
Allows the rigid body to create its parts using the chosen physics engine.
Declares the vortex fluid plane class.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.