6 #include "VsSimulator.h"
17 VsMaterialType::VsMaterialType()
44 m_vxMaterialTable = NULL;
48 VsMaterialType::~VsMaterialType()
73 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionLinearPrimary",
true);
76 SetMaterialProperties();
99 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionLinearSecondary",
true);
101 SetMaterialProperties();
124 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionAngularNormal",
true);
127 SetMaterialProperties();
150 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionAngularPrimary",
true);
153 SetMaterialProperties();
176 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionAngularSecondary",
true);
179 SetMaterialProperties();
203 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionLinearPrimaryMax",
true);
209 SetMaterialProperties();
233 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionLinearSecondaryMax",
true);
239 SetMaterialProperties();
263 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionAngularNormalMax",
true);
269 SetMaterialProperties();
293 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionAngularPrimaryMax",
true);
299 SetMaterialProperties();
323 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionAngularSecondaryMax",
true);
329 SetMaterialProperties();
361 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlipLinearPrimary",
true);
367 SetMaterialProperties();
400 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlipLinearSecondary",
true);
406 SetMaterialProperties();
439 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlipAngularNormal",
true);
445 SetMaterialProperties();
477 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlipAngularPrimary",
true);
483 SetMaterialProperties();
516 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlipAngularSecondary",
true);
522 SetMaterialProperties();
554 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlideLinearPrimary",
true);
560 SetMaterialProperties();
594 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlideLinearSecondary",
true);
600 SetMaterialProperties();
633 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlideAngularNormal",
true);
639 SetMaterialProperties();
671 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlideAngularPrimary",
true);
677 SetMaterialProperties();
711 Std_IsAboveMin((
float) 0, fltVal,
true,
"SlideAngularSecondary",
true);
717 SetMaterialProperties();
747 SetMaterialProperties();
777 SetMaterialProperties();
818 SetMaterialProperties();
852 SetMaterialProperties();
915 if(MaterialType::SetData(strType, strValue,
false))
918 if(strType ==
"FRICTIONLINEARPRIMARY")
924 if(strType ==
"FRICTIONLINEARSECONDARY")
930 if(strType ==
"FRICTIONANGULARNORMAL")
936 if(strType ==
"FRICTIONANGULARPRIMARY")
942 if(strType ==
"FRICTIONANGULARSECONDARY")
948 if(strType ==
"FRICTIONLINEARPRIMARYMAX")
954 if(strType ==
"FRICTIONLINEARSECONDARYMAX")
960 if(strType ==
"FRICTIONANGULARNORMALMAX")
966 if(strType ==
"FRICTIONANGULARPRIMARYMAX")
972 if(strType ==
"FRICTIONANGULARSECONDARYMAX")
978 if(strType ==
"COMPLIANCE")
984 if(strType ==
"DAMPING")
986 Damping((
float) atof(strValue.c_str()));
990 if(strType ==
"RESTITUTION")
996 if(strType ==
"SLIPLINEARPRIMARY")
1002 if(strDataType ==
"SLIPLINEARSECONDARY")
1008 if(strDataType ==
"SLIPANGULARNORMAL")
1014 if(strType ==
"SLIPANGULARPRIMARY")
1020 if(strDataType ==
"SLIPANGULARSECONDARY")
1026 if(strType ==
"SLIDELINEARPRIMARY")
1032 if(strDataType ==
"SLIDELINEARSECONDARY")
1038 if(strDataType ==
"SLIDEANGULARNORMAL")
1044 if(strType ==
"SLIDEANGULARPRIMARY")
1050 if(strDataType ==
"SLIDEANGULARSECONDARY")
1056 if(strType ==
"MAXADHESION")
1064 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
1069 void VsMaterialType::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
1071 MaterialType::QueryProperties(aryProperties);
1073 aryProperties.Add(
new TypeProperty(
"FrictionLinearPrimary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1074 aryProperties.Add(
new TypeProperty(
"FrictionLinearSecondary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1075 aryProperties.Add(
new TypeProperty(
"FrictionAngularNormal", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1076 aryProperties.Add(
new TypeProperty(
"FrictionAngularPrimary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1077 aryProperties.Add(
new TypeProperty(
"FrictionAngularSecondary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1078 aryProperties.Add(
new TypeProperty(
"FrictionLinearPrimaryMax", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1079 aryProperties.Add(
new TypeProperty(
"FrictionLinearSecondaryMax", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1080 aryProperties.Add(
new TypeProperty(
"FrictionAngularNormalMax", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1081 aryProperties.Add(
new TypeProperty(
"FrictionAngularPrimaryMax", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1082 aryProperties.Add(
new TypeProperty(
"FrictionAngularSecondaryMax", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1083 aryProperties.Add(
new TypeProperty(
"Compliance", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1084 aryProperties.Add(
new TypeProperty(
"Damping", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1085 aryProperties.Add(
new TypeProperty(
"Restitution", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1086 aryProperties.Add(
new TypeProperty(
"SlipLinearPrimary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1087 aryProperties.Add(
new TypeProperty(
"SlipLinearSecondary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1088 aryProperties.Add(
new TypeProperty(
"SlipAngularNormal", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1089 aryProperties.Add(
new TypeProperty(
"SlipAngularPrimary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1090 aryProperties.Add(
new TypeProperty(
"SlipAngularSecondary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1091 aryProperties.Add(
new TypeProperty(
"SlideLinearPrimary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1092 aryProperties.Add(
new TypeProperty(
"SlideLinearSecondary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1093 aryProperties.Add(
new TypeProperty(
"SlideAngularNormal", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1094 aryProperties.Add(
new TypeProperty(
"SlideAngularPrimary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1095 aryProperties.Add(
new TypeProperty(
"SlideAngularSecondary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1096 aryProperties.Add(
new TypeProperty(
"MaxAdhesion", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1099 void VsMaterialType::Load(CStdXml &oXml)
1101 MaterialType::Load(oXml);
1139 if(!m_vxMaterialTable)
1140 THROW_ERROR(Vs_Err_lMaterial_Table_Not_Defined, Vs_Err_strMaterial_Table_Not_Defined);
1142 return m_vxMaterialTable->getMaterialID(strName.c_str());
1151 THROW_ERROR(Vs_Err_lUnableToConvertToVsSimulator, Vs_Err_strUnableToConvertToVsSimulator);
1153 m_vxMaterialTable = lpVsSim->Frame()->getMaterialTable();
1155 m_vxMaterial = m_vxMaterialTable->registerMaterial(
m_strID.c_str());
1161 MaterialType::Initialize();
1164 SetMaterialProperties();
1167 void VsMaterialType::SetMaterialProperties()
1171 m_vxMaterial->setFrictionModel(VxContactMaterial::kFrictionAxisLinear, VxContactMaterial::kFrictionModelScaledBox);
1181 m_vxMaterial->setFrictionModel(VxContactMaterial::kFrictionAxisAngularNormal, VxContactMaterial::kFrictionModelScaledBox);
1186 m_vxMaterial->setFrictionModel(VxContactMaterial::kFrictionAxisAngularNormal, VxContactMaterial::kFrictionModelNeutral);
1190 m_vxMaterial->setFrictionModel(VxContactMaterial::kFrictionAxisAngularPrimary, VxContactMaterial::kFrictionModelScaledBox);
1195 m_vxMaterial->setFrictionModel(VxContactMaterial::kFrictionAxisAngularPrimary, VxContactMaterial::kFrictionModelNeutral);
1199 m_vxMaterial->setFrictionModel(VxContactMaterial::kFrictionAxisAngularSecondary, VxContactMaterial::kFrictionModelScaledBox);
1204 m_vxMaterial->setFrictionModel(VxContactMaterial::kFrictionAxisAngularSecondary, VxContactMaterial::kFrictionModelNeutral);
float m_fltFrictionAngularNormal
The angular normal coefficient of friction parameter. (this simulates spinning resistance) ...
virtual float SlipAngularNormal()
Gets the angular normal slip value.
virtual float FrictionLinearSecondaryMax()
Gets the maximum secondary friction allowed.
float m_fltFrictionAngularSecondaryMax
The maximum angular secondary friction that can created.
virtual float FrictionAngularPrimaryMax()
Gets the maximum angular primary friction allowed.
float m_fltFrictionAngularPrimaryMax
The maximum angular primary friction that can created.
virtual float InverseMassUnits()
Gets the inverse mass units.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
float m_fltFrictionAngularPrimary
The angular primary coefficient of friction parameter.(this simulates rolling resistance) ...
float m_fltSlipAngularSecondary
The angular secondary slip of the collision between those two materials.
virtual void CreateDefaultUnits()
This takes the default values defined in the constructor and scales them according to the distance an...
virtual float FrictionLinearPrimary()
Gets the primary friction coefficient.
Simulator * m_lpSim
The pointer to a Simulation.
float m_fltCompliance
The compliance of the collision between those two materials.
virtual float Damping()
Gets the damping for collisions between RigidBodies with these two materials.
virtual int GetMaterialID(std::string strName)
Gets a material identifier used by the physics engine.
virtual float SlideLinearSecondary()
Gets the linear secondary slide value.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
virtual float FrictionLinearSecondary()
Gets the secondary linear friction coefficient.
virtual float SlipLinearSecondary()
Gets the secondary linear slip value.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
float m_fltMaxAdhesive
The maximum adhesion of the collision between those two materials.
virtual float MaxAdhesive()
Gets the maximum adhesive for collisions between RigidBodies with these two materials.
float m_fltSlipAngularNormal
The angular normal slip of the collision between those two materials.
std::string m_strID
The unique Id for this object.
virtual void MassUnits(std::string strUnits)
Sets the mass units.
virtual float DisplayMassUnits()
Gets the density mass units.
float m_fltSlipLinearSecondary
The secondary linear slip of the collision between those two materials.
virtual float FrictionAngularNormalMax()
Gets the maximum angular normal friction allowed.
float m_fltDamping
The damping of the collision between those two materials.
virtual float FrictionAngularSecondary()
Gets the angular secondary friction coefficient.
virtual float SlipAngularSecondary()
Gets the angular secondary slip value.
float m_fltSlipAngularPrimary
The angular primary slip of the collision between those two materials.
virtual float SlideAngularNormal()
Gets the angular normal slide value.
float m_fltSlipLinearPrimary
The primary linear slip of the collision between those two materials.
float m_fltSlideLinearSecondary
The primary linear slide of the collision between those two materials.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
virtual float FrictionAngularSecondaryMax()
Gets the maximum angular secondary friction allowed.
float m_fltFrictionLinearPrimary
The primary linear coefficient of friction parameter.
virtual float FrictionLinearPrimaryMax()
Gets the maximum primary friction allowed.
virtual float SlipAngularPrimary()
Gets the angular primary slip value.
float m_fltFrictionLinearSecondary
The secondary linear coefficient of friction parameter.
virtual float Compliance()
Gets the compliance for collisions between RigidBodies with these two materials.
float m_fltFrictionLinearPrimaryMax
The maximum linear primary friction that can created.
float m_fltSlideAngularNormal
The angular normal slide of the collision between those two materials.
virtual void Initialize()
Initializes this object.
float m_fltFrictionLinearSecondaryMax
The maximum linear secondary friction that can created.
float m_fltSlideAngularPrimary
The angular primary slide of the collision between those two materials.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual float SlideLinearPrimary()
Gets the linear primary slide value.
virtual float FrictionAngularPrimary()
Gets the angular primary friction coefficient.
float m_fltRestitution
The restitution of the collision between those two materials.
float m_fltFrictionAngularNormalMax
The maximum angular normal friction that can created.
virtual float FrictionAngularNormal()
Gets the angular normal friction coefficient.
float m_fltFrictionAngularSecondary
The angular secondary coefficient of friction parameter.(this simulates rolling resistance) ...
virtual float Restitution()
Gets the restitution for collisions between RigidBodies with these two materials. ...
virtual float InverseDistanceUnits()
Gets the inverse distance units.
virtual float SlideAngularPrimary()
Gets the angular primary slide value.
virtual float SlipLinearPrimary()
Gets the primary linear slip value.
float m_fltSlideLinearPrimary
The primary linear slide of the collision between those two materials.
virtual void RegisterMaterialType()
Registers the material types within the physics engine.
virtual float SlideAngularSecondary()
Gets the angular secondary slide value.
float m_fltSlideAngularSecondary
The angular secondary slide of the collision between those two materials.