8 #include "RbMovableItem.h"
11 #include "RbMotorizedJoint.h"
12 #include "RbRigidBody.h"
14 #include "RbHingeLimit.h"
16 #include "RbSimulator.h"
66 {
Std_TraceMsg(0,
"Caught Error in desctructor of RbHinge\r\n",
"", -1,
false,
true);}
71 Hinge::EnableLimits(bVal);
76 void RbHinge::SetLimitValues()
128 #pragma region DataAccesMethods
130 float *RbHinge::GetDataPointer(
const std::string &strDataType)
135 if(strType ==
"JOINTROTATION")
137 else if(strType ==
"JOINTPOSITION")
139 else if(strType ==
"JOINTACTUALVELOCITY")
141 else if(strType ==
"JOINTFORCE")
143 else if(strType ==
"JOINTROTATIONDEG")
145 else if(strType ==
"JOINTDESIREDPOSITION")
147 else if(strType ==
"JOINTDESIREDPOSITIONDEG")
149 else if(strType ==
"JOINTSETPOSITION")
151 else if(strType ==
"JOINTDESIREDVELOCITY")
153 else if(strType ==
"JOINTSETVELOCITY")
155 else if(strType ==
"ENABLE")
157 else if(strType ==
"CONTACTCOUNT")
158 THROW_PARAM_ERROR(Al_Err_lMustBeContactBodyToGetCount, Al_Err_strMustBeContactBodyToGetCount,
"JointID",
m_strName);
161 lpData = RbMotorizedJoint::Physics_GetDataPointer(strType);
162 if(lpData)
return lpData;
164 lpData = Hinge::GetDataPointer(strType);
165 if(lpData)
return lpData;
167 THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"JointID: " + STR(
m_strName) +
" DataType: " + strDataType);
173 bool RbHinge::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
178 if(Hinge::SetData(strDataType, strValue,
false))
183 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
188 void RbHinge::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
191 Hinge::QueryProperties(aryProperties);
193 aryProperties.Add(
new TypeProperty(
"JointRotation", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
194 aryProperties.Add(
new TypeProperty(
"JointPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
195 aryProperties.Add(
new TypeProperty(
"JointActualVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
196 aryProperties.Add(
new TypeProperty(
"JointForce", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
197 aryProperties.Add(
new TypeProperty(
"JointRotationDeg", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
198 aryProperties.Add(
new TypeProperty(
"JointDesiredPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
199 aryProperties.Add(
new TypeProperty(
"JointDesiredPositionDeg", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
200 aryProperties.Add(
new TypeProperty(
"JointSetPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
201 aryProperties.Add(
new TypeProperty(
"JointDesiredVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
202 aryProperties.Add(
new TypeProperty(
"JointSetVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
203 aryProperties.Add(
new TypeProperty(
"Enable", AnimatPropertyType::Boolean, AnimatPropertyDirection::Get));
214 void RbHinge::Physics_EnableLock(
bool bOn,
float fltPosition,
float fltMaxLockForce)
217 m_bJointLocked =
true;
219 Physics_EnableMotor(
true, 0, fltMaxLockForce,
false);
224 void RbHinge::Physics_EnableMotor(
bool bOn,
float fltDesiredVelocity,
float fltMaxForce,
bool bForceWakeup)
228 if(!m_bMotorOn || bForceWakeup || m_bJointLocked)
236 m_lpThisJoint->WakeDynamics();
242 if(m_bMotorOn || bForceWakeup || m_bJointLocked)
246 m_lpThisJoint->WakeDynamics();
254 void RbHinge::Physics_MaxForce(
float fltVal)
260 void RbHinge::TurnMotorOff()
278 void RbHinge::SetConstraintFriction()
280 if(!m_bJointLocked && !m_bMotorOn &&
m_bEnabled)
286 Hinge::ResetSimulation();
virtual float LimitPos()
Gets the limit position.
virtual void ResetSimulation()
Resets the simulation back to time 0.
float m_fltEnabled
This is used for reporting the enabled state in a GetDataPointer call.
ConstraintLimit * m_lpUpperLimit
Upper limit constring pointer.
virtual void IsShowPosition(bool bVal)
Sets whether this contstraint is actually just being used to show the current position of the joint...
float m_fltRotationDeg
The rotation of the hinge in degrees.
virtual void CreateJoint()
Creates the joint.
Declares the vortex hinge class.
float m_fltDesiredPositionDeg
The desired rotation of the hinge in degrees.
ConstraintLimit * m_lpLowerLimit
Lower limit constring pointer.
virtual void StepSimulation()
Step the simulation for this object.
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_fltForce
The current force being applied to the joint by the motor.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
float m_fltReportSetPosition
This is the variable that is reported to AnimatLab on what the set position was.
ConstraintLimit * m_lpPosFlap
Pointer to a constraint that is used to represent the position flap.
float m_fltReportSetVelocity
This is the variable that is reported to AnimatLab on what the set veloicty was.
virtual void SetVelocityToDesired()
Sets the desired velocity to use for the motor.
virtual float JointPosition()
Gets the joint position.
virtual void Color(float fltR, float fltG, float fltB, float fltA)
Sets the color to use when displaying this contraint.
virtual void IsLowerLimit(bool bVal)
Sets whether this is a lower limit or not..
RbHinge()
Default constructor.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual ~RbHinge()
Destructor.
virtual void ClearAssistForces()
Clears the assist forces.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
virtual void UpdateData()
Called to collect any body data for this part.
virtual bool EnableLimits()
Tells if ConstraintLimits are enabled.
std::string m_strName
The name for this object.