AnimatLab  2
Test
VsOrganism.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "VsMovableItem.h"
9 #include "VsBody.h"
10 #include "VsJoint.h"
11 #include "VsMotorizedJoint.h"
12 #include "VsRigidBody.h"
13 #include "VsOrganism.h"
14 #include "VsSimulator.h"
15 #include "VsDragger.h"
16 
17 namespace VortexAnimatSim
18 {
19  namespace Environment
20  {
21 
29 {
30  m_lpVsBody = NULL;
31  SetThisPointers();
32 }
33 
34 VsOrganism::~VsOrganism()
35 {
36  m_lpAssembly = NULL;
37 }
38 
39 void VsOrganism::Body(RigidBody *lpBody)
40 {
41  Organism::Body(lpBody);
42  m_lpVsBody = dynamic_cast<VsRigidBody *>(lpBody);
43 
44  if(!m_lpVsBody)
45  THROW_TEXT_ERROR(Vs_Err_lUnableToConvertToVsRigidBody, Vs_Err_strUnableToConvertToVsRigidBody, "ID: " + lpBody->Name());
46 }
47 
48 void VsOrganism::SetThisPointers()
49 {
50  VsMovableItem::SetThisPointers();
51 
52  m_lpThisST = dynamic_cast<Structure *>(this);
53  if(!m_lpThisST)
54  THROW_TEXT_ERROR(Vs_Err_lThisPointerNotDefined, Vs_Err_strThisPointerNotDefined, "m_lpThisST, " + m_lpThisAB->Name());
55 
56  m_lpThisOG = dynamic_cast<Organism *>(this);
57  if(!m_lpThisOG)
58  THROW_TEXT_ERROR(Vs_Err_lThisPointerNotDefined, Vs_Err_strThisPointerNotDefined, "m_lpThisOG, " + m_lpThisAB->Name());
59 }
60 
61 osg::Group *VsOrganism::ParentOSG()
62 {
63  return GetVsSimulator()->OSGRoot();
64 }
65 
66 void VsOrganism::Create()
67 {
68  CreateItem();
69 
70  Organism::Create();
71 }
72 
73 void VsOrganism::SetupPhysics()
74 {
75 }
76 
78 {
79  VsMovableItem::Physics_ResetSimulation();
80 
81  Organism::ResetSimulation();
82 }
83 
84 void VsOrganism::UpdatePositionAndRotationFromMatrix()
85 {
86  VsMovableItem::UpdatePositionAndRotationFromMatrix();
87 
88  if(m_lpVsBody)
89  m_lpVsBody->EndGripDrag();
90 }
91 
92  } // Environment
93 } //VortexAnimatSim
A common class for all rigid body data specific to vortex.
Definition: VsRigidBody.h:55
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: VsOrganism.cpp:77
Declares the vortex organism class.
virtual RigidBody * Body()
Gets the root body.
Definition: Structure.cpp:115
Organism()
Default constructor.
Definition: Organism.cpp:50
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
Structure()
Default constructor.
Definition: Structure.cpp:53