AnimatLab  2
Test
BlRPRO.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 "BlRPRO.h"
12 #include "BlSimulator.h"
13 
14 namespace BulletAnimatSim
15 {
16  namespace Environment
17  {
18  namespace Joints
19  {
20 
28 {
29  SetThisPointers();
30  //m_btSocket = NULL;
31 }
32 
40 {
41 
42  try
43  {
44  DeleteGraphics();
45  DeletePhysics(false);
46  }
47  catch(...)
48  {Std_TraceMsg(0, "Caught Error in desctructor of BlRPRO\r\n", "", -1, false, true);}
49 }
50 
51 void BlRPRO::SetupPhysics()
52 {
53  if(m_btJoint)
54  DeletePhysics(false);
55 
56  InitBaseJointPointers(m_lpParent, m_lpChild, m_aryRelaxations, -1);
57 
58  btTransform mtJointRelParent, mtJointRelChild;
59  CalculateRelativeJointMatrices(mtJointRelParent, mtJointRelChild);
60 
61  //All limits are turned off by default.
62  m_btSocket = new btAnimatGeneric6DofConstraint(*m_lpBlParent->Part(), *m_lpBlChild->Part(), mtJointRelParent, mtJointRelChild, true);
63  m_btSocket->setLinearLowerLimit(btVector3(0, 0, 0));
64  m_btSocket->setLinearUpperLimit(btVector3(0, 0, 0));
65  m_btSocket->setAngularLowerLimit(btVector3(0, 0, 0));
66  m_btSocket->setAngularUpperLimit(btVector3(0, 0, 0));
67 
68  GetBlSimulator()->DynamicsWorld()->addConstraint(m_btSocket, true);
69  m_btSocket->setDbgDrawSize(btScalar(5.f));
70 
71  m_btJoint = m_btSocket;
72  m_bt6DofJoint = m_btSocket;
73 
74  RPRO::Initialize();
75  BlJoint::Initialize();
76 }
77 
79 {
80  SetupGraphics();
81  SetupPhysics();
82 }
83 
84 #pragma region DataAccesMethods
85 
86 bool BlRPRO::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
87 {
88  if(BlJoint::Physics_SetData(strDataType, strValue))
89  return true;
90 
91  if(RPRO::SetData(strDataType, strValue, false))
92  return true;
93 
94  //If it was not one of those above then we have a problem.
95  if(bThrowError)
96  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
97 
98  return false;
99 }
100 
101 void BlRPRO::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
102 {
103  BlJoint::Physics_QueryProperties(aryProperties);
104  RPRO::QueryProperties(aryProperties);
105 }
106 
107 #pragma endregion
108 
109  } //Joints
110  } // Environment
111 } //BulletAnimatSim
btAnimatGeneric6DofConstraint * m_btSocket
The vortex socket class.
Definition: BlRPRO.h:29
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
RigidBody * m_lpChild
The child rigid body for this joint.
Definition: Joint.h:44
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.
virtual void CreateJoint()
Creates the joint.
Definition: BlRPRO.cpp:78
Declares the vortex relative position, relative orientation class.
ConstraintRelaxation * m_aryRelaxations[6]
The relaxations for the constraints.
Definition: Joint.h:64