AnimatLab  2
Test
VsBox.cpp
1 // VsBox.cpp: implementation of the VsBox class.
2 //
4 
5 #include "StdAfx.h"
6 #include "VsMovableItem.h"
7 #include "VsBody.h"
8 #include "VsJoint.h"
9 #include "VsMotorizedJoint.h"
10 #include "VsRigidBody.h"
11 #include "VsBox.h"
12 #include "VsStructure.h"
13 #include "VsSimulator.h"
14 #include "VsOsgUserData.h"
15 #include "VsOsgUserDataVisitor.h"
16 #include "VsDragger.h"
17 
18 namespace VortexAnimatSim
19 {
20  namespace Environment
21  {
22  namespace Bodies
23  {
24 
26 // Construction/Destruction
28 
29 VsBox::VsBox()
30 {
31  SetThisPointers();
32 }
33 
34 VsBox::~VsBox()
35 {
36  try
37  {
38  DeleteGraphics();
39  DeletePhysics();
40  }
41  catch(...)
42  {Std_TraceMsg(0, "Caught Error in desctructor of VsBox\r\n", "", -1, false, true);}
43 }
44 
45 void VsBox::CreateGraphicsGeometry()
46 {
47  m_osgGeometry = CreateBoxGeometry(Length(), Height(), Width(), LengthSegmentSize(), HeightSegmentSize(), WidthSegmentSize());
48 }
49 
50 void VsBox::CalculateEstimatedMassAndVolume()
51 {
54 }
55 
56 void VsBox::CreatePhysicsGeometry()
57 {
58  if(IsCollisionObject())
59  m_vxGeometry = new VxBox(m_fltLength, m_fltHeight, m_fltWidth);
60 
61  CalculateEstimatedMassAndVolume();
62 }
63 
65 {
66  CreateGeometry();
67 
68  VsRigidBody::CreateItem();
69  Box::CreateParts();
70  VsRigidBody::SetBody();
71 }
72 
74 {
77 
78  Box::CreateJoints();
79  VsRigidBody::Initialize();
80 }
81 
82 void VsBox::ResizePhysicsGeometry()
83 {
84  if(m_vxGeometry)
85  {
86  VxBox *vxBox = dynamic_cast<VxBox *>(m_vxGeometry);
87 
88  if(!vxBox)
89  THROW_TEXT_ERROR(Vs_Err_lGeometryMismatch, Vs_Err_strGeometryMismatch, m_lpThisAB->Name());
90 
91  vxBox->setDimensions(m_fltLength, m_fltHeight, m_fltWidth);
92 
93  CalculateEstimatedMassAndVolume();
94  }
95 }
96 
97 
98  } //Bodies
99  } // Environment
100 } //VortexAnimatSim
virtual bool IsCollisionObject()
Query if this object is collision object.
Definition: RigidBody.cpp:468
virtual float WidthSegmentSize()
Gets the width segment size.
Definition: Box.cpp:204
float m_fltEstimatedVolume
The estimated volume. See m_fltEstimatedMass desciption.
Definition: VsRigidBody.h:92
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
virtual void DistanceUnits(std::string strUnits)
Sets the distance units.
Definition: Simulator.cpp:1717
virtual float Width()
Gets the width of the box.
Definition: Box.cpp:82
virtual void CreateJoint()
Creates the joint.
Definition: Joint.cpp:602
float m_fltLength
The length dimension of the box.
Definition: Box.h:46
virtual float DisplayMassUnits()
Gets the density mass units.
Definition: Simulator.cpp:1810
virtual void CreateParts()
Allows the rigid body to create its parts using the chosen physics engine.
Definition: VsBox.cpp:64
float m_fltDensity
Uniform density for the rigid body.
Definition: RigidBody.h:79
virtual float Length()
Gets the length of the box.
Definition: Box.cpp:69
virtual float LengthSegmentSize()
Gets the length segment size.
Definition: Box.cpp:194
float m_fltWidth
The width dimension of the box.
Definition: Box.h:52
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
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.
float m_fltHeight
The height dimension of the box.
Definition: Box.h:58
virtual void CreateJoints()
Allows the rigid body to create its joints using the chosen physics engine.
Definition: VsBox.cpp:73
virtual float HeightSegmentSize()
Gets the height segment size.
Definition: Box.cpp:214
virtual float Height()
Gets the height of the box.
Definition: Box.cpp:95
Declares the vortex structure class.