7 #include "BlRigidBody.h"
8 #include "BlSimulator.h"
19 BlMaterialType::BlMaterialType()
26 BlMaterialType::~BlMaterialType()
50 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionLinearPrimary",
true);
53 SetMaterialProperties();
77 Std_IsAboveMin((
float) 0, fltVal,
true,
"FrictionAngularPrimary",
true);
80 SetMaterialProperties();
141 SetMaterialProperties();
162 if(MaterialType::SetData(strType, strValue,
false))
165 if(strType ==
"FRICTIONLINEARPRIMARY")
171 if(strType ==
"FRICTIONANGULARPRIMARY")
177 if(strType ==
"RESTITUTION")
185 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
190 void BlMaterialType::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
192 MaterialType::QueryProperties(aryProperties);
194 aryProperties.Add(
new TypeProperty(
"FrictionLinearPrimary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
195 aryProperties.Add(
new TypeProperty(
"FrictionAngularPrimary", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
196 aryProperties.Add(
new TypeProperty(
"Restitution", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
199 void BlMaterialType::Load(CStdXml &oXml)
201 MaterialType::Load(oXml);
227 if(!FindBodyByID(lpBody->ID(),
false))
244 if(FindBodyByID(lpBody->ID(),
false))
249 RigidBody *BlMaterialType::FindBodyByID(std::string strID,
bool bThrowError)
251 RigidBody *lpFind = NULL;
252 CStdMap<std::string, RigidBody *>::iterator oPos;
256 lpFind = oPos->second;
258 THROW_PARAM_ERROR(Al_Err_lIDNotFound, Al_Err_strIDNotFound,
"ID", strID);
274 MaterialType::Initialize();
277 SetMaterialProperties();
280 void BlMaterialType::SetMaterialProperties()
282 CStdMap<std::string, RigidBody *>::iterator oPos;
283 RigidBody *lpBody = NULL;
287 lpBody = oPos->second;
291 lpBlBody->MaterialTypeModified();
virtual void AddRigidBodyAssociation(RigidBody *lpBody)
Associates a rigid body with this material type. This is used when you change something about this ma...
virtual float FrictionAngularPrimaryConverted()
Gets the angular primary friction coefficient converted to match vortex values.
virtual void Initialize()
Initializes this object.
A common class for all rigid body data specific to vortex.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
CStdMap< std::string, RigidBody * > m_aryBodies
All the rigid bodies associated with this material type.
float m_fltFrictionAngularPrimary
The angular primary coefficient of friction parameter.(this simulates rolling resistance) ...
virtual void CreateDefaultUnits()
This takes the default values defined in the constructor and scales them according to the distance an...
virtual float Restitution()
Gets the restitution for collisions between RigidBodies with these two materials. ...
virtual float FrictionLinearPrimary()
Gets the primary friction coefficient.
float m_fltRestitution
The restitution of the collision between those two materials.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual int GetMaterialID(std::string strName)
Gets a material identifier used by the physics engine.
virtual void RegisterMaterialType()
Registers the material types within the physics engine.
virtual void RemoveRigidBodyAssociation(RigidBody *lpBody)
Removes the rigid body association described by lpBody from this material.
float m_fltFrictionLinearPrimary
The primary linear coefficient of friction parameter.
virtual float FrictionAngularPrimary()
Gets the angular primary friction coefficient.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.