8 #include "VsMovableItem.h"
11 #include "VsMotorizedJoint.h"
12 #include "VsPrismaticLimit.h"
13 #include "VsRigidBody.h"
16 #include "VsSimulator.h"
17 #include "VsOsgUserData.h"
18 #include "VsOsgUserDataVisitor.h"
19 #include "VsDragger.h"
71 {
Std_TraceMsg(0,
"Caught Error in desctructor of VsPrismatic/\r\n",
"", -1,
false,
true);}
77 Prismatic::EnableLimits(bVal);
80 m_vxPrismatic->setLimitsActive(m_vxPrismatic->kLinearCoordinate,
m_bEnableLimits);
97 void VsPrismatic::SetAlpha()
106 void VsPrismatic::DeleteJointGraphics()
114 if(lpUpperLimit && lpUpperLimit->BoxMT())
m_osgJointMT->removeChild(lpUpperLimit->BoxMT());
115 if(lpUpperLimit && lpUpperLimit->CylinderMT())
m_osgJointMT->removeChild(lpUpperLimit->CylinderMT());
117 if(lpLowerLimit && lpLowerLimit->BoxMT())
m_osgJointMT->removeChild(lpLowerLimit->BoxMT());
118 if(lpLowerLimit && lpLowerLimit->CylinderMT())
m_osgJointMT->removeChild(lpLowerLimit->CylinderMT());
120 if(lpPosFlap && lpPosFlap->BoxMT())
m_osgJointMT->removeChild(lpPosFlap->BoxMT());
134 lpPosFlap->
LimitPos(Prismatic::JointPosition());
152 m_osgParent = ParentOSG();
154 if(m_osgParent.valid())
157 CStdFPoint vPos(0, 0, 0), vRot(VX_PI/2, 0, 0);
158 vPos.Set(0, 0, 0); vRot.Set(0, VX_PI/2, 0);
170 SetVisible(m_lpThisMI->IsVisible());
173 m_osgParent->addChild(m_osgRoot.get());
176 Physics_UpdateAbsolutePosition();
181 osgVisitor->traverse(*m_osgMT);
185 void VsPrismatic::DeletePhysics()
190 if(GetVsSimulator() && GetVsSimulator()->Universe())
192 GetVsSimulator()->Universe()->removeConstraint(m_vxPrismatic);
193 delete m_vxPrismatic;
199 m_vxPrismatic = NULL;
203 void VsPrismatic::SetupPhysics()
209 THROW_ERROR(Al_Err_lParentNotDefined, Al_Err_strParentNotDefined);
212 THROW_ERROR(Al_Err_lChildNotDefined, Al_Err_strChildNotDefined);
216 THROW_ERROR(Vs_Err_lUnableToConvertToVsRigidBody, Vs_Err_strUnableToConvertToVsRigidBody);
220 THROW_ERROR(Vs_Err_lUnableToConvertToVsRigidBody, Vs_Err_strUnableToConvertToVsRigidBody);
222 CStdFPoint vGlobal = this->GetOSGWorldCoords();
225 VxOSG::copyOsgMatrix_to_VxReal44(this->GetOSGWorldMatrix(
true), vMT);
226 Vx::VxTransform vTrans(vMT);
228 vTrans.getRotationEulerAngles(vxRot);
230 CStdFPoint vLocalRot(vxRot[0], vxRot[1], vxRot[2]);
232 VxVector3 pos((
double) vGlobal.x, (
double) vGlobal.y, (
double) vGlobal.z);
233 VxVector3 axis = NormalizeAxis(vLocalRot);
235 m_vxPrismatic =
new VxPrismatic(lpVsParent->Part(), lpVsChild->Part(), pos.v, axis.v);
236 m_vxPrismatic->setName(
m_strID.c_str());
238 GetVsSimulator()->Universe()->addConstraint(m_vxPrismatic);
246 lpUpperLimit->PrismaticRef(m_vxPrismatic);
247 lpLowerLimit->PrismaticRef(m_vxPrismatic);
252 m_vxJoint = m_vxPrismatic;
253 m_iCoordID = m_vxPrismatic->kLinearCoordinate;
258 Prismatic::Initialize();
259 VsJoint::Initialize();
268 #pragma region DataAccesMethods
270 float *VsPrismatic::GetDataPointer(
const std::string &strDataType)
275 if(strType ==
"JOINTROTATION")
277 else if(strType ==
"JOINTPOSITION")
279 else if(strType ==
"JOINTACTUALVELOCITY")
281 else if(strType ==
"JOINTFORCE")
283 else if(strType ==
"JOINTDESIREDVELOCITY")
285 else if(strType ==
"JOINTSETVELOCITY")
287 else if(strType ==
"JOINTDESIREDPOSITION")
289 else if(strType ==
"JOINTSETPOSITION")
291 else if(strType ==
"ENABLE")
293 else if(strType ==
"MOTORFORCETOAX")
295 else if(strType ==
"MOTORFORCETOAY")
297 else if(strType ==
"MOTORFORCETOAZ")
299 else if(strType ==
"MOTORFORCETOBX")
301 else if(strType ==
"MOTORFORCETOBY")
303 else if(strType ==
"MOTORFORCETOBZ")
305 else if(strType ==
"MOTORTORQUETOAX")
307 else if(strType ==
"MOTORTORQUETOAY")
309 else if(strType ==
"MOTORTORQUETOAZ")
311 else if(strType ==
"MOTORTORQUETOBX")
313 else if(strType ==
"MOTORTORQUETOBY")
315 else if(strType ==
"MOTORTORQUETOBZ")
317 else if(strType ==
"CONTACTCOUNT")
318 THROW_PARAM_ERROR(Al_Err_lMustBeContactBodyToGetCount, Al_Err_strMustBeContactBodyToGetCount,
"JointID",
m_strName);
321 lpData = Prismatic::GetDataPointer(strDataType);
322 if(lpData)
return lpData;
324 THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"JointID: " + STR(
m_strName) +
" DataType: " + strDataType);
330 bool VsPrismatic::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
332 if(VsJoint::Physics_SetData(strDataType, strValue))
335 if(Prismatic::SetData(strDataType, strValue,
false))
340 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
345 void VsPrismatic::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
347 VsJoint::Physics_QueryProperties(aryProperties);
348 Prismatic::QueryProperties(aryProperties);
350 aryProperties.Add(
new TypeProperty(
"JointRotation", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
351 aryProperties.Add(
new TypeProperty(
"JointPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
352 aryProperties.Add(
new TypeProperty(
"JointActualVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
353 aryProperties.Add(
new TypeProperty(
"JointForce", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
354 aryProperties.Add(
new TypeProperty(
"JointRotationDeg", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
355 aryProperties.Add(
new TypeProperty(
"JointDesiredPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
356 aryProperties.Add(
new TypeProperty(
"JointSetPosition", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
357 aryProperties.Add(
new TypeProperty(
"JointDesiredVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
358 aryProperties.Add(
new TypeProperty(
"JointSetVelocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
359 aryProperties.Add(
new TypeProperty(
"Enable", AnimatPropertyType::Boolean, AnimatPropertyDirection::Get));
360 aryProperties.Add(
new TypeProperty(
"MotorForceToAX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
361 aryProperties.Add(
new TypeProperty(
"MotorForceToAY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
362 aryProperties.Add(
new TypeProperty(
"MotorForceToAZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
363 aryProperties.Add(
new TypeProperty(
"MotorForceToBX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
364 aryProperties.Add(
new TypeProperty(
"MotorForceToBY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
365 aryProperties.Add(
new TypeProperty(
"MotorForceToBZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
366 aryProperties.Add(
new TypeProperty(
"MotorTorqueToAX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
367 aryProperties.Add(
new TypeProperty(
"MotorTorqueToAY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
368 aryProperties.Add(
new TypeProperty(
"MotorTorqueToAZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
369 aryProperties.Add(
new TypeProperty(
"MotorTorqueToBX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
370 aryProperties.Add(
new TypeProperty(
"MotorTorqueToBY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
371 aryProperties.Add(
new TypeProperty(
"MotorTorqueToBZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
Declares the vs prismatic class.
virtual void DisableCollision(RigidBody *lpBody)
Disables collision between the past-in object and this object.
virtual void CreateJoint()
Creates the joint.
virtual void EnableCollision(RigidBody *lpBody)
Enables collision between the past-in object and this object.
virtual float LimitPos()
Gets the limit position.
virtual void UpdateData()
Called to collect any body data for this part.
float m_fltNullReport
This is used to report back 0 from GetDataPointer for items that are not supported in vortex...
A common class for all rigid body data specific to vortex.
virtual void Alpha(float fltA)=0
Sets the alpha color value for this constraint.
VsPrismatic()
Default constructor.
float m_fltEnabled
This is used for reporting the enabled state in a GetDataPointer call.
virtual void StepSimulation()
Step the simulation for this object.
virtual void IsShowPosition(bool bVal)
Sets whether this contstraint is actually just being used to show the current position of the joint...
std::string m_strID
The unique Id for this object.
ConstraintLimit * m_lpUpperLimit
Upper limit constring pointer.
virtual void SetupGraphics()
Sets up the graphics for the constraint.
virtual void SetupGraphics()
Sets up the graphics for the joint.
virtual bool EnableMotor()
Tells if the motor is enabled.
RigidBody * m_lpChild
The child rigid body for this joint.
bool m_bEnableLimits
If true then any ConstraintLimits for this joint are enabled.
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.
ConstraintLimit * m_lpLowerLimit
Lower limit constring pointer.
float m_fltForce
The current force being applied to the joint by the motor.
osg::ref_ptr< osg::MatrixTransform > m_osgJointMT
The osg joint matrix transform.
float m_fltReportSetPosition
This is the variable that is reported to AnimatLab on what the set position was.
virtual void SetLimitPos()=0
Sets the limit position using the current value set within the object.
float m_fltAlpha
The current alpha transparency for this body part.
virtual ~VsPrismatic()
Destructor.
float m_fltReportSetVelocity
This is the variable that is reported to AnimatLab on what the set veloicty was.
ConstraintLimit * m_lpPosFlap
Pointer to a constraint that is used to represent the position flap.
virtual void SetVelocityToDesired()
Sets the desired velocity to use for the motor.
virtual float JointPosition()
Gets the joint position.
virtual void DeleteGraphics()=0
Deletes up the graphics for the constraint.
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..
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual bool EnableLimits()
Tells if ConstraintLimits are enabled.
std::string m_strName
The name for this object.
Declares the vortex structure class.
virtual void CreateJointGraphics()
Creates the default ball graphics.