8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
13 #include "IPhysicsMovableItem.h"
14 #include "IPhysicsBody.h"
16 #include "MovableItem.h"
64 m_fltStiffnessTension = 0;
65 m_fltDampingTension = 0;
175 for(
int i=0; i<5; i++)
213 m_fltTension = m_fltStiffnessTension + m_fltDampingTension;
242 float *Spring::GetDataPointer(
const std::string &strDataType)
246 if(strType ==
"SPRINGLENGTH")
249 if(strType ==
"DISPLACEMENT")
252 if(strType ==
"TENSION")
255 if(strType ==
"STIFFNESSTENSION")
256 return &m_fltStiffnessTension;
258 if(strType ==
"DAMPINGTENSION")
259 return &m_fltDampingTension;
261 if(strType ==
"ENERGY")
264 if(strType ==
"VELOCITY")
267 if(strType ==
"ENABLE")
270 return LineBase::GetDataPointer(strDataType);
273 bool Spring::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
275 if(LineBase::SetData(strDataType, strValue,
false))
278 if(strDataType ==
"NATURALLENGTH")
284 if(strDataType ==
"STIFFNESS")
286 Stiffness((
float) atof(strValue.c_str()));
290 if(strDataType ==
"DAMPING")
292 Damping((
float) atof(strValue.c_str()));
298 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
303 void Spring::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
305 LineBase::QueryProperties(aryProperties);
307 aryProperties.Add(
new TypeProperty(
"SpringLength", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
308 aryProperties.Add(
new TypeProperty(
"Displacement", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
309 aryProperties.Add(
new TypeProperty(
"Tension", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
310 aryProperties.Add(
new TypeProperty(
"StiffnessTension", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
311 aryProperties.Add(
new TypeProperty(
"DampingTension", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
312 aryProperties.Add(
new TypeProperty(
"Energy", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
313 aryProperties.Add(
new TypeProperty(
"Velocity", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
314 aryProperties.Add(
new TypeProperty(
"Enable", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
316 aryProperties.Add(
new TypeProperty(
"NaturalLength", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
317 aryProperties.Add(
new TypeProperty(
"Stiffness", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
318 aryProperties.Add(
new TypeProperty(
"Damping", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
321 void Spring::Load(
CStdXml &oXml)
324 THROW_ERROR(Al_Err_lParentNotDefined, Al_Err_strParentNotDefined);
326 LineBase::Load(oXml);
virtual float Damping()
Gets the damping of the spring.
Base class file for all Animat simulation objects.
virtual float CalculateLength()
Calculates the length of the line.
float m_fltStiffness
The stiffness of the spring.
virtual void PhysicsTimeStep(float fltVal)
Sets the integration time step for the physics engine.
Declares the simulation recorder class.
virtual float NaturalLength()
Gets the natural length of the spring.
float m_fltNaturalLength
The natural length of the spring.
virtual float Tension()
Gets the current tension of the spring.
Root namespace for the base simulation library for AnimatLab.
virtual float InverseMassUnits()
Gets the inverse mass units.
float m_fltPrevLength
Length of the line in the previous timestep.
float m_fltDamping
The damping of the spring.
Declares the body part class.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void ResetSimulation()
Resets the simulation back to time 0.
Simulator * m_lpSim
The pointer to a Simulation.
float m_fltEnabled
This is used for reporting the enabled state in a GetDataPointer call.
virtual bool IntoElem()
Goes into the next element where the cursor is located.
virtual float Displacement()
Gets the curent displacement away from the natural length of the spring.
virtual float Energy()
Gets the current energy stored in the spring.
Class that stores information about types for QueryProperty information.
Declares the key frame class.
float m_fltVelocity
The velocity of the spring length change.
float m_fltAvgVelocity
The rolling average velocity over the last 5 steps.
virtual void CreateParts()
Allows the rigid body to create its parts using the chosen physics engine.
Declares the joint class.
Declares the organism class.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
virtual bool Enabled()
Tells whether this node is enabled.
Declares the activated item class.
virtual float DisplayMassUnits()
Gets the density mass units.
Declares a light manager object.
Declares the bounding box class.
virtual void ClearVelocityAverage()
Clears the velocity average circular queue.
Spring()
Default constructor.
A standard xml manipulation class.
Declares the line base class.
virtual bool InitEnabled()
Tells whether the spring is enabled at startup of the simulation.
bool m_bInitEnabled
Keeps track of the initial state of the enabled flag.
float m_fltDampingNotScaled
The damping of the spring.
CStdArray< Attachment * > m_aryAttachmentPoints
A pointer to the primary attachment part.
virtual float Stiffness()
Gets the stiffness of the spring.
bool m_bEnabled
Tells if this item is enabled or not. If it is not enabled then it is not run.
float m_fltEnergy
The current energy contained in the spring.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
float m_fltStiffnessNotScaled
The unscaled stiffness. This is used to calcuate the energy.
float m_fltLength
Current length of the line.
Declares the data chart manager class.
Declares the rigid body class.
virtual float Velocity()
Gets the velocity of the length change of the spring.
virtual ~Spring()
Destructor.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void CalculateTension()
Calculates the tension.
Declares the structure class.
Declares the odor type class.
virtual float InverseDistanceUnits()
Gets the inverse distance units.
Declares the simulator class.
float m_fltDisplacement
The current displacement of the spring from its natural length.
Declares the activated item manager class.
Declares the external stimuli manager class.
CStdArray< std::string > m_aryAttachmentPointIDs
The ID's of the attachment points for this muscle. This is used during the load/initialization proces...
float m_fltNaturalLengthNotScaled
The unscaled natural length. This is used to calcuate the tension and displacement.
CStdCircularArray< float > m_aryVelocityAvg
circular array for calculating the rolling average of the velocity.
virtual void AddExternalNodeInput(int iTargetDataType, float fltInput)
Adds an external node input.
Declares the receptive field class.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
Declares the spring class.
float m_fltTension
The current force being applied by the spring.