8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
13 #include "IPhysicsMovableItem.h"
14 #include "IPhysicsBody.h"
16 #include "MovableItem.h"
49 m_fltReportIsVisible = 1;
80 #pragma region AccessorMutators
197 void MovableItem::Position(
float fltX,
float fltY,
float fltZ,
bool bUseScaling,
bool bFireChangeEvent,
bool bUpdateMatrix)
199 CStdFPoint vPos(fltX, fltY, fltZ);
200 Position(vPos, bUseScaling, bFireChangeEvent);
229 Position(vPos, bUseScaling, bFireChangeEvent);
243 THROW_ERROR(Al_Err_lAttempedToReadAbsPosBeforeDefined, Al_Err_strAttempedToReadAbsPosBeforeDefined);
288 CStdFPoint MovableItem::UpdateAbsolutePosition()
291 THROW_ERROR(Al_Err_lAttempedToReadAbsPosBeforeDefined, Al_Err_strAttempedToReadAbsPosBeforeDefined);
416 CStdFPoint vPos(fltX, fltY, fltZ);
517 m_fltReportIsVisible = (float) bVal;
631 Std_InValidRange((
float) 0, (
float) 1, fltVal,
true,
"ReceptiveFieldsAlpha");
731 CStdColor vColor(aryColor[0], aryColor[1], aryColor[2], aryColor[3], 1);
747 vColor.
Load(strXml,
"Color");
785 CStdColor vColor(aryColor[0], aryColor[1], aryColor[2], aryColor[3], 1);
800 vColor.
Load(strXml,
"Color");
838 CStdColor vColor(aryColor[0], aryColor[1], aryColor[2], aryColor[3], 1);
853 vColor.
Load(strXml,
"Color");
956 CStdFPoint vPos(fltX, fltY, fltZ);
1157 void MovableItem::Selected(
bool bValue,
bool bSelectMultiple)
1244 return m_lpPhysicsMovableItem->Physics_CalculateLocalPosForWorldPos(fltWorldX, fltWorldY, fltWorldZ, vLocalPos);
1248 #pragma region DataAccesMethods
1250 float *MovableItem::GetDataPointer(
const std::string &strDataType)
1254 if(strType ==
"WORLDPOSITIONX")
1257 if(strType ==
"WORLDPOSITIONY")
1260 if(strType ==
"WORLDPOSITIONZ")
1263 if(strType ==
"POSITIONX")
1266 if(strType ==
"POSITIONY")
1269 if(strType ==
"POSITIONZ")
1272 if(strType ==
"ROTATIONX")
1275 if(strType ==
"ROTATIONY")
1278 if(strType ==
"ROTATIONZ")
1281 if(strType ==
"VISIBLE")
1282 return &m_fltReportIsVisible;
1287 bool MovableItem::SetData(
const std::string &strDataType,
const std::string &strValue,
bool bThrowError)
1289 if(strDataType ==
"POSITION")
1295 if(strDataType ==
"POSITION.X")
1301 if(strDataType ==
"POSITION.Y")
1307 if(strDataType ==
"POSITION.Z")
1313 if(strDataType ==
"ROTATION")
1319 if(strDataType ==
"ROTATION.X")
1325 if(strDataType ==
"ROTATION.Y")
1331 if(strDataType ==
"ROTATION.Z")
1337 if(strDataType ==
"BOUNDINGBOX.X")
1343 if(strDataType ==
"BOUNDINGBOX.Y")
1349 if(strDataType ==
"BOUNDINGBOX.Z")
1355 if(strDataType ==
"VISIBLE")
1361 if(strDataType ==
"GRAPHICSALPHA")
1367 if(strDataType ==
"COLLISIONALPHA")
1373 if(strDataType ==
"JOINTSALPHA")
1379 if(strDataType ==
"RECEPTIVEFIELDSALPHA")
1385 if(strDataType ==
"SIMULATIONALPHA")
1391 if(strDataType ==
"AMBIENT")
1397 if(strDataType ==
"AMBIENT.RED")
1404 if(strDataType ==
"AMBIENT.GREEN")
1411 if(strDataType ==
"AMBIENT.BLUE")
1418 if(strDataType ==
"AMBIENT.ALPHA")
1425 if(strDataType ==
"DIFFUSE")
1431 if(strDataType ==
"DIFFUSE.RED")
1438 if(strDataType ==
"DIFFUSE.GREEN")
1445 if(strDataType ==
"DIFFUSE.BLUE")
1452 if(strDataType ==
"DIFFUSE.ALPHA")
1459 if(strDataType ==
"SPECULAR")
1465 if(strDataType ==
"SPECULAR.RED")
1472 if(strDataType ==
"SPECULAR.GREEN")
1479 if(strDataType ==
"SPECULAR.BLUE")
1486 if(strDataType ==
"SPECULAR.ALPHA")
1493 if(strDataType ==
"SHININESS")
1495 Shininess((
float) atof(strValue.c_str()));
1499 if(strDataType ==
"TEXTURE")
1505 if(strDataType ==
"DRAGGERRADIUS")
1513 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
1518 void MovableItem::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
1520 aryProperties.Add(
new TypeProperty(
"WorldPositionX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1521 aryProperties.Add(
new TypeProperty(
"WorldPositionY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1522 aryProperties.Add(
new TypeProperty(
"WorldPositionZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1523 aryProperties.Add(
new TypeProperty(
"PositionX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1524 aryProperties.Add(
new TypeProperty(
"PositionY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1525 aryProperties.Add(
new TypeProperty(
"PositionZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1526 aryProperties.Add(
new TypeProperty(
"RotationX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1527 aryProperties.Add(
new TypeProperty(
"RotationY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1528 aryProperties.Add(
new TypeProperty(
"RotationZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1530 aryProperties.Add(
new TypeProperty(
"Position", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1531 aryProperties.Add(
new TypeProperty(
"Position.X", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1532 aryProperties.Add(
new TypeProperty(
"Position.Y", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1533 aryProperties.Add(
new TypeProperty(
"Position.Z", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1534 aryProperties.Add(
new TypeProperty(
"Rotation", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1535 aryProperties.Add(
new TypeProperty(
"Rotation.X", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1536 aryProperties.Add(
new TypeProperty(
"Rotation.Y", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1537 aryProperties.Add(
new TypeProperty(
"Rotation.Z", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1538 aryProperties.Add(
new TypeProperty(
"BoundingBox.X", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1539 aryProperties.Add(
new TypeProperty(
"BoundingBox.Y", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1540 aryProperties.Add(
new TypeProperty(
"BoundingBox.Z", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1541 aryProperties.Add(
new TypeProperty(
"Visible", AnimatPropertyType::Boolean, AnimatPropertyDirection::Both));
1542 aryProperties.Add(
new TypeProperty(
"GraphicsAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1543 aryProperties.Add(
new TypeProperty(
"CollisionAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1544 aryProperties.Add(
new TypeProperty(
"JointsAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1545 aryProperties.Add(
new TypeProperty(
"ReceptiveFieldsAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1546 aryProperties.Add(
new TypeProperty(
"SimulationAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1547 aryProperties.Add(
new TypeProperty(
"Ambient", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1548 aryProperties.Add(
new TypeProperty(
"Ambient.Red", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1549 aryProperties.Add(
new TypeProperty(
"Ambient.Green", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1550 aryProperties.Add(
new TypeProperty(
"Ambient.Blue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1551 aryProperties.Add(
new TypeProperty(
"Ambient.Alpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1552 aryProperties.Add(
new TypeProperty(
"Diffuse", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1553 aryProperties.Add(
new TypeProperty(
"Diffuse.Red", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1554 aryProperties.Add(
new TypeProperty(
"Diffuse.Green", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1555 aryProperties.Add(
new TypeProperty(
"Diffuse.Blue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1556 aryProperties.Add(
new TypeProperty(
"Diffuse.Alpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1557 aryProperties.Add(
new TypeProperty(
"Specular", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1558 aryProperties.Add(
new TypeProperty(
"Specular.Red", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1559 aryProperties.Add(
new TypeProperty(
"Specular.Green", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1560 aryProperties.Add(
new TypeProperty(
"Specular.Blue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1561 aryProperties.Add(
new TypeProperty(
"Specular.Alpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1562 aryProperties.Add(
new TypeProperty(
"Shininess", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1563 aryProperties.Add(
new TypeProperty(
"Texture", AnimatPropertyType::String, AnimatPropertyDirection::Set));
1564 aryProperties.Add(
new TypeProperty(
"DraggerRadius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1585 Position(vTemp,
true,
false,
false);
1605 void MovableItem::Load(
CStdXml &oXml)
Movable Item callback to the GUI.
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
Base class file for all Animat simulation objects.
Declares the simulation recorder class.
virtual bool IsSelected()
Query if this object is selected.
virtual float Alpha()
Gets the current alpha.
virtual CStdFPoint ReportWorldPosition()
Gets the reported world position. (m_oReportWorldPosition)
float m_fltSimulationAlpha
The alpha transparency used in the Simulation VisualSelectionMode.
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
Simulator * m_lpMovableSim
The pointer to a Simulation.
virtual void LoadRotation(CStdXml &oXml)
Loads the items rotation.
Root namespace for the base simulation library for AnimatLab.
void Set(float R, float G, float B, float A)
Sets the color values.
CStdFPoint m_oReportWorldPosition
This is used for reporting the position back to the GUI. It is the world position scaled for distance...
float m_fltReceptiveFieldsAlpha
The alpha transparency used in the Receptive Fields VisualSelectionMode.
Declares the body part class.
CStdColor m_vAmbient
The ambient color to apply to this part. It is specified as red, green, blue, and alpha...
void Load(CStdXml &oXml, std::string strParamName, bool bThrowError=true)
Loads the color.
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
float m_fltJointsAlpha
The alpha transparency used in the Joints VisualSelectionMode.
virtual CStdFPoint SelectedVertex()
Gets the relative position of the selected vertex. (m_vSelectedVertex)
virtual bool IntoElem()
Goes into the next element where the cursor is located.
virtual void LoadPosition(CStdXml &oXml)
Loads the items position.
virtual bool CalculateLocalPosForWorldPos(float fltWorldX, float fltWorldY, float fltWorldZ, CStdFPoint &vLocalPos)
Calculates the local position values for matrix transform for the part to be in a specific world posi...
virtual float Shininess()
Gets the shininess.
virtual bool AllowTranslateDragY()
Gets whether this body part can be translated along the y-axis by the user with the drag handlers...
Class that stores information about types for QueryProperty information.
IMovableItemCallback * m_lpCallback
virtual void DistanceUnits(std::string strUnits)
Sets the distance units.
Declares the key frame class.
virtual CStdColor * Ambient()
Gets the ambient color value.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
Declares the joint class.
virtual CStdFPoint ReportPosition()
Gets the reported local position. (m_oReportPosition).
Declares the organism class.
virtual void PositionChanged()=0
Called to signal to the GUI that the position of the body part changed.
virtual std::string Texture()
Gets the texture filename.
virtual bool AllowTranslateDragX()
Gets whether this body part can be translated along the x-axis by the user with the drag handlers...
Declares the activated item class.
virtual float UserDefinedDraggerRadius()
Gets the user defined dragger radius.
virtual CStdColor * Specular()
Gets the specular color.
Declares a light manager object.
virtual bool AllowRotateDragX()
Gets whether this body part can be rotated along the x-axis by the user with the drag handlers...
virtual float GetBoundingRadius()
Gets the bounding radius of this part.
IPhysicsMovableItem * m_lpPhysicsMovableItem
virtual bool IsVisible()
Query if this object is visible.
virtual BoundingBox GetBoundingBox()
Gets the bounding box for this part.
Declares the bounding box class.
float m_fltShininess
The shininess of the part. A value between 0 and 128.
virtual IMovableItemCallback * Callback()
Gets the callback interface pointer. This is an interface pointer to a callback class that allows us ...
virtual CStdFPoint GetCurrentPosition()
Gets the current position of this part.
A standard xml manipulation class.
virtual bool AllowRotateDragY()
Gets whether this body part can be rotated along the y-axis by the user with the drag handlers...
CStdFPoint m_oReportRotation
virtual CStdFPoint AbsolutePosition()
Gets the absolute position of this body part.
virtual CStdFPoint Rotation()
Gets the rotation of this body in radians.
Bounding box class for geometric objects.
CStdFPoint m_oAbsPosition
virtual void SelectionChanged(bool bSelected, bool bSelectMultiple)=0
Called to signal to the GUI that the selected body part changed.
virtual IPhysicsMovableItem * PhysicsMovableItem()
Gets the physics body interface pointer. This is an interface reference to the Vs version of this obj...
void r(float fltR, bool bThrowError=true)
Sets the red value of the color.
virtual CStdFPoint ReportRotation()
Gets the reported rotation of this part. (m_oReportRotation)
virtual float ReceptiveFieldsAlpha()
Gets the receptive fields alpha.
CStdColor m_vDiffuse
The diffuse color to apply to this part. It is specified as red, green, blue, and alpha...
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
virtual void OrientNewPart(float fltXPos, float fltYPos, float fltZPos, float fltXNorm, float fltYNorm, float fltZNorm)
Orients a new part based on where the parent was clicked and the normal of the surface face...
float m_fltUserDefinedDraggerRadius
User defined drag handle radius. If this is -1 then the user has not set the value and the default is...
float m_fltGraphicsAlpha
The alpha transparency used in the Graphics VisualSelectionMode.
RigidBody * Parent()
Gets the parent RigidBody of this part.
bool Std_ToBool(int iVal)
Converts a value toa bool.
MovableItem(void)
Default constructor.
virtual bool GetChildBool(std::string strElementName)
Gets a bool value from the element with the specified name.
virtual CStdFPoint Position()
Gets the local position. (m_oPosition)
CStdColor m_vSpecular
The specular color to apply to this part. It is specified as red, green, blue, and alpha...
virtual ~MovableItem(void)
Destructor.
bool m_bIsSelected
Keeps track of whether this movable item has been selected or not.
float m_fltCollisionsAlpha
The alpha transparency used in the Collisions VisualSelectionMode.
virtual bool AllowRotateDragZ()
Gets whether this body part can be rotated along the z-axis by the user with the drag handlers...
virtual void AddBodyClicked(float fltPosX, float fltPosY, float fltPosZ, float fltNormX, float fltNormY, float fltNormZ)
Called when the user clicks on this object while the AddBody mode is active.
CStdFPoint m_oPosition
These are rotation and position coords relative to the parent if this is a body part.
virtual void VisualSelectionModeChanged(int iNewMode)
Called when the visual selection mode changed in GUI.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
float m_fltAlpha
The current alpha transparency for this body part.
virtual CStdColor * Diffuse()
Gets the diffuse color.
Declares the data chart manager class.
Declares the rigid body class.
virtual void SelectedVertexChanged(float fltPosX, float fltPosY, float fltPosZ)=0
Called to signal when the selected vertex has changed.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual float JointsAlpha()
Gets the joints alpha.
bool Std_LoadPoint(CStdXml &oXml, std::string strName, CStdIPoint &oPoint, bool bThrowError)
Standard load point.
virtual float SimulationAlpha()
Gets the simulation alpha.
virtual float GraphicsAlpha()
Gets the graphics alpha.
Declares the structure class.
virtual void RotationChanged()=0
Called to signal to the GUI that the rotation of the body part changed.
virtual int VisualSelectionType()
Gets the visual selection type for this part.
Declares the odor type class.
virtual std::string LocalTransformationMatrixString()
Returns a string representation of the transformation matrix of this object. This is primarily used t...
virtual void SetBoundingBox(int iIdx, float fltVal)
Sets one dimension of the bounding box. This does nothing for all parts except a mesh.
virtual float InverseDistanceUnits()
Gets the inverse distance units.
void g(float fltG, bool bThrowError=true)
Sets the green value of the color.
Declares the simulator class.
CStdFPoint m_vSelectedVertex
The relative position of the selected vertex.
CStdFPoint m_oReportPosition
This is used for reporting the position back to the GUI. It is the position scaled for distance units...
Declares the activated item manager class.
Declares the external stimuli manager class.
void a(float fltA, bool bThrowError=true)
Sets the alpha value of the color.
The base class for all of the basic rigid body type of objects.
Declares the receptive field class.
std::string m_strTexture
An optional texture to apply to the rigid body.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
virtual bool AllowTranslateDragZ()
Gets whether this body part can be translated along the z-axis by the user with the drag handlers...
virtual float CollisionsAlpha()
Gets the collisions alpha.
virtual bool AllowMouseManipulation()
Tells if a given part can be manipulated using the mouse and draggers.
void b(float fltB, bool bThrowError=true)
Sets the blue value of the color.