AnimatLab  2
Test
Structure.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "IMotorizedJoint.h"
9 #include "IMovableItemCallback.h"
10 #include "ISimGUICallback.h"
11 #include "AnimatBase.h"
12 
13 #include "Node.h"
14 #include "Link.h"
15 #include "IPhysicsMovableItem.h"
16 #include "IPhysicsBody.h"
17 #include "BoundingBox.h"
18 #include "MovableItem.h"
19 #include "BodyPart.h"
20 #include "Joint.h"
21 #include "MotorizedJoint.h"
22 #include "ReceptiveField.h"
23 #include "ContactSensor.h"
24 #include "RigidBody.h"
25 #include "Structure.h"
26 #include "NeuralModule.h"
27 #include "Adapter.h"
28 #include "NervousSystem.h"
29 #include "Organism.h"
30 #include "ActivatedItem.h"
31 #include "ActivatedItemMgr.h"
32 #include "DataChartMgr.h"
33 #include "ExternalStimuliMgr.h"
34 #include "KeyFrame.h"
35 #include "SimulationRecorder.h"
36 #include "OdorType.h"
37 #include "Odor.h"
38 #include "Light.h"
39 #include "LightManager.h"
40 #include "Simulator.h"
41 
42 namespace AnimatSim
43 {
44  namespace Environment
45  {
46 
54 {
55  m_lpSim = NULL;
56  m_lpBody = NULL;
58  m_fltSize = 0.02f;
59  m_lpScript = NULL;
60 }
61 
69 {
70 
71 try
72 {
73  m_aryRigidBodies.RemoveAll();
74  m_aryJoints.RemoveAll();
75  m_aryExcludeCollisionList.RemoveAll();
76  if(m_lpBody) delete m_lpBody;
77  if(m_lpScript) delete m_lpScript;
78 }
79 catch(...)
80 {Std_TraceMsg(0, "Caught Error in desctructor of Structure\r\n", "", -1, false, true);}
81 }
82 
92 {m_lpSim = lpSim;}
93 
103 void Structure::Body(RigidBody *lpBody) {m_lpBody = lpBody;}
104 
116 {return m_lpBody;}
117 
119 
120 void Structure::Position(CStdFPoint &oPoint, bool bUseScaling, bool bFireChangeEvent, bool bUpdateMatrix)
121 {
122  MovableItem::Position(oPoint, bUseScaling, bFireChangeEvent, bUpdateMatrix);
123 
126  {
127  if(bUpdateMatrix)
128  m_lpBody->PhysicsMovableItem()->Physics_PositionChanged();
129  else if(bFireChangeEvent)
131  }
132 }
133 
142 float Structure::Size() {return m_fltSize;};
143 
153 void Structure::Size(float fltVal, bool bUseScaling)
154 {
155  Std_IsAboveMin((float) 0, fltVal, true, "Structure.Size");
156  if(bUseScaling)
157  m_fltSize = fltVal * m_lpSim->InverseDistanceUnits();
158  else
159  m_fltSize = fltVal;
160 }
161 
162 void Structure::Selected(bool bValue, bool bSelectMultiple)
163 {
164  AnimatBase::Selected(bValue, bSelectMultiple);
165  MovableItem::Selected(bValue, bSelectMultiple);
166 }
167 
168 //The structure is not manipulated directly through the editor window. Instead, the root rigid body is moved/rotated.
169 bool Structure::AllowTranslateDragX() {return false;}
170 
171 bool Structure::AllowTranslateDragY() {return false;}
172 
173 bool Structure::AllowTranslateDragZ() {return false;}
174 
175 bool Structure::AllowRotateDragX() {return false;}
176 
177 bool Structure::AllowRotateDragY() {return false;}
178 
179 bool Structure::AllowRotateDragZ() {return false;}
180 
181 void Structure::Script(ScriptProcessor *lpScript)
182 {
183  if(m_lpScript)
184  {
185  delete m_lpScript;
186  m_lpScript = NULL;
187  }
188 
189  m_lpScript = lpScript;
190 }
191 
192 ScriptProcessor *Structure::Script() {return m_lpScript;}
193 
210 CStdPtrArray<CollisionPair> Structure::ExclusionList()
212 
224 {
226  m_lpPhysicsMovableItem->Physics_CollectData();
227 }
228 
229 void Structure::UpdatePhysicsPosFromGraphics()
230 {
231  if(m_lpBody)
233 }
234 
235 void Structure::Create()
236 {
237  if(m_lpBody)
238  {
239  //First create all of the model objects.
241 
242  //Then create all of the joints between the models.
244  }
245 
246  m_lpSim->DisableCollisions(this, m_aryExcludeCollisionList);
247 }
248 
250 {
252  m_lpPhysicsMovableItem->Physics_ResetSimulation();
253 
254  if(m_lpBody)
255  {
258 
259  UpdateData();
260 
261  //We have to call this after method because some objects (ie: muscles and spindles, etc.) depend on other items
262  //already being reset to their original positions. So they must be done first and then these items get reset.
264  }
265 
266  if(m_lpScript)
268 }
269 
270 void Structure::MinTimeStep(float &fltMin) {}
271 
272 
287 {
288  if(m_lpScript)
289  m_lpScript->BeforeStepPhysicsEngine();
290 
291  if(m_lpBody)
292  {
294  UpdateData();
295  }
296 
297  if(m_lpScript)
298  m_lpScript->AfterStepPhysicsEngine();
299 }
300 
302 {
304  if(m_lpScript)
306 }
307 
308 void Structure::Kill(bool bState)
309 {
310  if(m_lpScript)
311  m_lpScript->Kill(bState);
312 }
313 
315 {
316 }
317 
319 {
320 }
321 
323 {
324 }
325 
345 {
346  if(!lpJoint)
347  THROW_PARAM_ERROR(Al_Err_lJointNotDefined, Al_Err_strJointNotDefined, "StructureID", m_strName);
348 
349  try
350  {
351  m_aryJoints.Add(lpJoint->ID(), lpJoint);
352  }
353  catch(CStdErrorInfo oError)
354  {
355  oError.m_strError += " Duplicate joint Key: " + lpJoint->Name() + " in Structure: " + m_strName;
356  THROW_ERROR(oError.m_lError, oError.m_strError);
357  }
358 }
359 
369 void Structure::RemoveJoint(std::string strID)
370 {
371  try
372  {
373  m_aryJoints.Remove(strID);
374  }
375  catch(CStdErrorInfo oError)
376  {
377  oError.m_strError += " Joint not found Key: " + strID + " in Structure: " + m_strName;
378  THROW_ERROR(oError.m_lError, oError.m_strError);
379  }
380 }
381 
401 {
402  if(!lpBody)
403  THROW_PARAM_ERROR(Al_Err_lBodyNotDefined, Al_Err_strBodyNotDefined, "StructureID", m_strName);
404 
405  try
406  {
407  m_aryRigidBodies.Add(lpBody->ID(), lpBody);
408  }
409  catch(CStdErrorInfo oError)
410  {
411  oError.m_strError += " Duplicate rigid body Key: " + lpBody->Name() + " in Structure: " + m_strName;
412  THROW_ERROR(oError.m_lError, oError.m_strError);
413  }
414 }
415 
416 
426 void Structure::RemoveRigidBody(std::string strID)
427 {
428  try
429  {
430  m_aryRigidBodies.Remove(strID);
431  }
432  catch(CStdErrorInfo oError)
433  {
434  oError.m_strError += " RigidBody not found Key: " + strID + " in Structure: " + m_strName;
435  THROW_ERROR(oError.m_lError, oError.m_strError);
436  }
437 }
438 
439 
457 Joint *Structure::FindJoint(std::string strJointID, bool bThrowError)
458 {
459  Joint *lpJoint = NULL;
460  CStdMap<std::string, Joint *>::iterator oPos;
461  oPos = m_aryJoints.find(Std_CheckString(strJointID));
462 
463  if(oPos != m_aryJoints.end())
464  lpJoint = oPos->second;
465  else if(bThrowError)
466  THROW_TEXT_ERROR(Al_Err_lJointIDNotFound, Al_Err_strJointIDNotFound, " StructureID: " + m_strName + " JointID: " + strJointID);
467 
468  return lpJoint;
469 }
470 
471 
489 RigidBody *Structure::FindRigidBody(std::string strBodyID, bool bThrowError)
490 {
491  RigidBody *lpBody = NULL;
492  CStdMap<std::string, RigidBody *>::iterator oPos;
493  oPos = m_aryRigidBodies.find(Std_CheckString(strBodyID));
494 
495  if(oPos != m_aryRigidBodies.end())
496  lpBody = oPos->second;
497  else if(bThrowError)
498  THROW_TEXT_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound, " StructureID: " + m_strName + " BodyID: " + strBodyID);
499 
500  return lpBody;
501 }
502 
503 
515 Node *Structure::FindNode(std::string strID, bool bThrowError)
516 {
517  Node *lpNode = FindRigidBody(strID, false);
518 
519  if(lpNode)
520  return lpNode;
521 
522  lpNode = FindJoint(strID, false);
523 
524  if(lpNode)
525  return lpNode;
526 
527  if(bThrowError)
528  THROW_TEXT_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound, " StructureID: " + m_strName + " BodyID: " + strID);
529 
530  return NULL;
531 }
532 
533 #pragma region DataAccesMethods
534 
535 void Structure::SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
536 {
537  AnimatBase::SetSystemPointers(lpSim, lpStructure, lpModule, lpNode, bVerify);
538  m_lpMovableSim = lpSim;
539 }
540 
541 float *Structure::GetDataPointer(const std::string &strDataType)
542 {
543  float *lpData=NULL;
544  std::string strType = Std_CheckString(strDataType);
545 
546  lpData = MovableItem::GetDataPointer(strDataType);
547  if(lpData)
548  return lpData;
549 
550  THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Simulator DataType: " + strDataType);
551 
552  return lpData;
553 }
554 
555 bool Structure::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
556 {
557  std::string strType = Std_CheckString(strDataType);
558 
559  if(AnimatBase::SetData(strDataType, strValue, false))
560  return true;
561 
562  if(MovableItem::SetData(strDataType, strValue, false))
563  return true;
564 
565  //If it was not one of those above then we have a problem.
566  if(bThrowError)
567  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
568 
569  return false;
570 }
571 
572 void Structure::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
573 {
574  AnimatBase::QueryProperties(aryProperties);
575  MovableItem::QueryProperties(aryProperties);
576 }
577 
578 bool Structure::AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError, bool bDoNotInit)
579 {
580  std::string strType = Std_CheckString(strItemType);
581 
582  if(strType == "RIGIDBODY")
583  {
584  AddRoot(strXml);
585  return true;
586  }
587 
588  if(strType == "SCRIPT")
589  {
590  AddScript(strXml);
591  return true;
592  }
593 
594  //If it was not one of those above then we have a problem.
595  if(bThrowError)
596  THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType, "Item Type", strItemType);
597 
598  return false;
599 }
600 
601 bool Structure::RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError)
602 {
603  std::string strType = Std_CheckString(strItemType);
604 
605  if(strType == "RIGIDBODY")
606  {
607  RemoveRoot(strID);
608  return true;
609  }
610 
611  if(strType == "SCRIPT")
612  {
613  RemoveScript(strID);
614  return true;
615  }
616 
617  //If it was not one of those above then we have a problem.
618  if(bThrowError)
619  THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType, "Item Type", strItemType);
620 
621  return false;
622 }
623 
636 void Structure::AddRoot(std::string strXml)
637 {
638  CStdXml oXml;
639  oXml.Deserialize(strXml);
640  oXml.FindElement("Root");
641  oXml.FindChildElement("RigidBody");
642 
643  LoadRoot(oXml);
644  m_lpBody->Initialize();
645 
646  //First create all of the model objects.
648 
649  //Then create all of the joints between the models.
651 
652  if(m_lpSim && m_lpBody)
653  m_lpSim->NotifyRigidBodyAdded(m_lpBody->ID());
654 }
655 
670 void Structure::RemoveRoot(std::string strID, bool bThrowError)
671 {
672  if(m_lpBody && m_lpBody->ID() == strID)
673  {
674  delete m_lpBody;
675  m_lpBody = NULL;
676 
677  if(m_lpSim && m_lpBody)
678  m_lpSim->NotifyRigidBodyRemoved(strID);
679  }
680  else
681  THROW_PARAM_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound, "ID", strID);
682 }
683 
696 void Structure::AddScript(std::string strXml)
697 {
698  ScriptProcessor *lpScript = NULL;
699  try
700  {
701  CStdXml oXml;
702  oXml.Deserialize(strXml);
703  oXml.FindElement("Root");
704  oXml.FindChildElement("Script");
705 
706  lpScript = LoadScript(oXml);
707  lpScript->Initialize();
708  m_lpScript = lpScript;
709  }
710  catch(CStdErrorInfo oError)
711  {
712  if(lpScript) delete lpScript;
713  lpScript = NULL;
714  RELAY_ERROR(oError);
715  }
716  catch(...)
717  {
718  if(lpScript) delete lpScript;
719  lpScript = NULL;
720  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
721  }
722 }
723 
738 void Structure::RemoveScript(std::string strID, bool bThrowError)
739 {
740  if(m_lpScript && m_lpScript->ID() == strID)
741  {
742  delete m_lpScript;
743  m_lpScript = NULL;
744  }
745  else
746  THROW_PARAM_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound, "ID", strID);
747 }
748 
749 #pragma endregion
750 
760 void Structure::EnableMotor(std::string strJointID, bool bVal)
761 {
762  MotorizedJoint *lpJoint = dynamic_cast<MotorizedJoint *>(FindJoint(strJointID));
763  if(lpJoint)
764  lpJoint->EnableMotor(bVal);
765  else
766  THROW_PARAM_ERROR(Al_Err_lJointNotMotorized, Al_Err_strJointNotMotorized, "ID", strJointID);
767 }
768 
769 
782 void Structure::SetMotorInput(std::string strJointID, float fltInput)
783 {
784  MotorizedJoint *lpJoint = dynamic_cast<MotorizedJoint *>(FindJoint(strJointID));
785  if(lpJoint)
786  lpJoint->MotorInput(fltInput);
787  else
788  THROW_PARAM_ERROR(Al_Err_lJointNotMotorized, Al_Err_strJointNotMotorized, "ID", strJointID);
789 }
790 
802 void Structure::EnableCollision(RigidBody *lpCollisionBody)
803 {
804  CStdMap<std::string, RigidBody *>::iterator oPos;
805  RigidBody *lpBody = NULL;
806  for(oPos=m_aryRigidBodies.begin(); oPos!=m_aryRigidBodies.end(); ++oPos)
807  {
808  lpBody = oPos->second;
809  lpBody->EnableCollision(lpCollisionBody);
810  }
811 }
812 
826 {
827  CStdMap<std::string, RigidBody *>::iterator oPos;
828  RigidBody *lpBody = NULL;
829  for(oPos=m_aryRigidBodies.begin(); oPos!=m_aryRigidBodies.end(); ++oPos)
830  {
831  lpBody = oPos->second;
832  lpBody->DisableCollision(lpCollisionBody);
833  }
834 }
835 
836 
851 {return 0;}
852 
867 void Structure::SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
868 {}
869 
884 void Structure::LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
885 {}
886 
887 
888 void Structure::Load(CStdXml &oXml)
889 {
890  AnimatBase::Load(oXml);
891 
892  MovableItem::Load(oXml);
893 
894  oXml.IntoElem(); //Into Layout Element
895 
896  LoadLayout(oXml);
897 
898  if(oXml.FindChildElement("Script", false))
899  Script(LoadScript(oXml));
900 
901  oXml.OutOfElem(); //OutOf Layout Element
902 }
903 
904 
914 void Structure::AddCollisionPair(std::string strID1, std::string strID2)
915 {
916  CollisionPair *lpPair = new CollisionPair();
917  lpPair->m_strPart1ID = strID1;
918  lpPair->m_strPart2ID = strID2;
919 
920  m_aryExcludeCollisionList.Add(lpPair);
921 }
922 
932 {
933  CollisionPair *lpPair = NULL;
934  std::string strID1, strID2;
935 
936 try
937 {
938  oXml.IntoElem();
939  strID1 = oXml.GetChildString("Part1ID");
940  strID2 = oXml.GetChildString("Part2ID");
941  oXml.OutOfElem();
942 
943  lpPair = new CollisionPair();
944  lpPair->m_strPart1ID = strID1;
945  lpPair->m_strPart2ID = strID2;
946 
947  m_aryExcludeCollisionList.Add(lpPair);
948 }
949 catch(CStdErrorInfo oError)
950 {
951  if(lpPair) delete lpPair;
952  RELAY_ERROR(oError);
953 }
954 catch(...)
955 {
956  if(lpPair) delete lpPair;
957  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
958 }
959 }
960 
976 {
977  std::string strModule;
978  std::string strType;
979 
980  Size(oXml.GetChildFloat("Size", m_fltSize));
981 
982  bool bFound = false;
983  if(oXml.FindChildElement("Body", false))
984  bFound = true;
985  else if(oXml.FindChildElement("RigidBody", false))
986  bFound = true;
987 
988  if(bFound)
989  {
990  LoadRoot(oXml);
991 
992  if(oXml.FindChildElement("CollisionExclusionPairs", false))
993  {
994  oXml.IntoElem(); //Into CollisionExclusionPairs Element
995  int iChildCount = oXml.NumberOfChildren();
996  for(int iIndex=0; iIndex<iChildCount; iIndex++)
997  {
998  oXml.FindChildByIndex(iIndex);
999  LoadCollisionPair(oXml);
1000  }
1001  oXml.OutOfElem(); //OutOf CollisionExclusionPairs Element
1002  }
1003  }
1004  else
1005  m_lpBody = NULL;
1006 
1007 }
1008 
1009 
1021 {
1022  std::string strModule;
1023  std::string strType;
1024 
1025 try
1026 {
1027  oXml.IntoElem(); //Into Child Element
1028  strModule = oXml.GetChildString("ModuleName", "");
1029  strType = oXml.GetChildString("Type");
1030  oXml.OutOfElem(); //OutOf Child Element
1031 
1032  RigidBody *lpBody = dynamic_cast<RigidBody *>(m_lpSim->CreateObject(strModule, "RigidBody", strType));
1033  if(!lpBody)
1034  THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "RigidBody");
1035  Body(lpBody);
1036 
1037  m_lpBody->Parent(NULL);
1038  m_lpBody->SetSystemPointers(m_lpSim, this, NULL, NULL, true);
1039 
1040  m_lpBody->Load(oXml);
1042 
1043  return m_lpBody;
1044 }
1045 catch(CStdErrorInfo oError)
1046 {
1047  if(m_lpBody) delete m_lpBody;
1048  m_lpBody = NULL;
1049  RELAY_ERROR(oError);
1050  return NULL;
1051 }
1052 catch(...)
1053 {
1054  if(m_lpBody) delete m_lpBody;
1055  m_lpBody = NULL;
1056  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
1057  return NULL;
1058 }
1059 }
1060 
1061 
1073 {
1074  std::string strModule;
1075  std::string strType;
1076  ScriptProcessor *lpScript = NULL;
1077 
1078 try
1079 {
1080  oXml.IntoElem(); //Into Child Element
1081  strModule = oXml.GetChildString("ModuleName", "");
1082  strType = oXml.GetChildString("Type");
1083  oXml.OutOfElem(); //OutOf Child Element
1084 
1085  lpScript = dynamic_cast<ScriptProcessor *>(m_lpSim->CreateObject(strModule, "ScriptProcessor", strType));
1086  if(!lpScript)
1087  THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "Script");
1088 
1089  lpScript->SetSystemPointers(m_lpSim, this, NULL, NULL, true);
1090 
1091  lpScript->Load(oXml);
1092 
1093  return lpScript;
1094 }
1095 catch(CStdErrorInfo oError)
1096 {
1097  if(lpScript) delete lpScript;
1098  lpScript = NULL;
1099  RELAY_ERROR(oError);
1100  return NULL;
1101 }
1102 catch(...)
1103 {
1104  if(lpScript) delete lpScript;
1105  lpScript = NULL;
1106  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
1107  return NULL;
1108 }
1109 }
1110 
1111  } // Environment
1112 } //AnimatSim
void Sim(Simulator *lpSim)
Sets the simulator object.
Definition: Structure.cpp:91
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: AnimatBase.cpp:587
virtual void SimPausing()
Called just before the simulation pauses.
Definition: Structure.cpp:318
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
Definition: StdXml.cpp:162
The base class for all of the joint type of objects.
Definition: Joint.h:40
void AddRigidBody(RigidBody *lpBody)
Adds a new rigid body to the list of all bodies for this structure.
Definition: Structure.cpp:400
Base class file for all Animat simulation objects.
Declares the nervous system class.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
Definition: Structure.cpp:541
virtual void Initialize()
Initializes this object.
Definition: BodyPart.cpp:400
Declares the simulation recorder class.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Definition: Structure.cpp:572
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
Definition: Structure.cpp:578
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
virtual Node * FindNode(std::string strID, bool bThrowError=true)
Searches for a Node with the given ID.
Definition: Structure.cpp:515
Simulates the entire environment.
Definition: Simulator.h:31
virtual void DisableCollision(RigidBody *lpBody)
Disables collision between the past-in object and this object.
Definition: RigidBody.cpp:1374
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
Definition: StdXml.cpp:256
Simulator * m_lpMovableSim
The pointer to a Simulation.
Definition: MovableItem.h:23
virtual void CreateParts()
Allows the rigid body to create its parts using the chosen physics engine.
Definition: RigidBody.cpp:1531
Root namespace for the base simulation library for AnimatLab.
virtual void EnableCollision(RigidBody *lpBody)
Enables collision between the past-in object and this object.
Definition: RigidBody.cpp:1343
CStdMap< std::string, RigidBody * > m_aryRigidBodies
Definition: Structure.h:95
virtual bool AllowTranslateDragY()
Gets whether this body part can be translated along the y-axis by the user with the drag handlers...
Definition: Structure.cpp:171
virtual bool AllowRotateDragZ()
Gets whether this body part can be rotated along the z-axis by the user with the drag handlers...
Definition: Structure.cpp:179
virtual void SimStarting()
Called just before the simulation starts.
Definition: Structure.cpp:314
Declares the body part class.
void RemoveRigidBody(std::string strID)
Removes the rigid body with the specified ID.
Definition: Structure.cpp:426
virtual void Kill(bool bState=true)
Kills.
Definition: AnimatBase.cpp:627
std::string m_strError
The error message.
Definition: StdErrorInfo.h:26
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: RigidBody.cpp:1473
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
Definition: StdXml.cpp:179
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
virtual float Size()
Gets the size of the graphical representation of this joint.
Definition: Structure.cpp:142
Information about the standard error.
Definition: StdErrorInfo.h:19
virtual std::string ID()
Gets the unique GUID ID of this object.
Definition: AnimatBase.cpp:167
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
void AddJoint(Joint *lpJoint)
Adds a new joint to the list of all joints for this structure.
Definition: Structure.cpp:344
virtual ~Structure()
Destructor.
Definition: Structure.cpp:68
std::string m_strPart2ID
GUID ID of the second part of the collision pair.
Definition: Structure.h:44
virtual bool AllowTranslateDragX()
Gets whether this body part can be translated along the x-axis by the user with the drag handlers...
Definition: Structure.cpp:169
void RemoveJoint(std::string strID)
Removes the joint with the specified ID.
Definition: Structure.cpp:369
virtual void SimStopping()
Called just before the simulation stops.
Definition: Structure.cpp:322
virtual void LoadCollisionPair(CStdXml &oXml)
Loads a collision pair.
Definition: Structure.cpp:931
long m_lError
The error number.
Definition: StdErrorInfo.h:23
virtual void Initialize()
Initializes this object.
Definition: AnimatBase.cpp:573
virtual RigidBody * LoadRoot(CStdXml &oXml)
Loads the root rigid body.
Definition: Structure.cpp:1020
Declares the key frame class.
virtual void Initialize()
Initializes this object.
Definition: Structure.cpp:301
virtual void SetMotorInput(std::string strJointID, float fltInput)
Sets the velocity for the specified joint.
Definition: Structure.cpp:782
RigidBody * m_lpBody
The root rigid body object of this structure.
Definition: Structure.h:88
Declares the joint class.
Declares the organism class.
virtual void PositionChanged()=0
Called to signal to the GUI that the position of the body part changed.
virtual RigidBody * Body()
Gets the root body.
Definition: Structure.cpp:115
virtual bool AllowTranslateDragZ()
Gets whether this body part can be translated along the z-axis by the user with the drag handlers...
Definition: Structure.cpp:173
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
Definition: Structure.cpp:601
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
Declares a light object.
Declares the activated item class.
CStdPtrArray< CollisionPair > m_aryExcludeCollisionList
This is the list of other body part ID's to exclude from collision tests.
Definition: Structure.h:105
virtual CStdSerialize * CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError=true)
Creates an object using a class factory.
Definition: Simulator.cpp:3440
virtual void UpdatePhysicsPosFromGraphics()
Updates the physics position from graphics.
Definition: RigidBody.cpp:2100
Declares a light manager object.
IPhysicsMovableItem * m_lpPhysicsMovableItem
Definition: MovableItem.h:103
Declares the bounding box class.
virtual std::string Name()
Gets the name of this object.
Definition: AnimatBase.cpp:195
virtual IMovableItemCallback * Callback()
Gets the callback interface pointer. This is an interface pointer to a callback class that allows us ...
virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Loads a key frame snapshot.
Definition: Structure.cpp:884
virtual CStdFPoint Position()
Gets the local position. (m_oPosition)
Definition: Structure.cpp:118
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: Structure.cpp:249
virtual long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
Definition: Structure.cpp:850
A standard xml manipulation class.
Definition: StdXml.h:19
virtual bool Selected()
Tells if this items is selected or not.
Definition: AnimatBase.cpp:248
A "static" structure in the simulation.
Definition: Structure.h:84
virtual void CreateJoints()
Allows the rigid body to create its joints using the chosen physics engine.
Definition: RigidBody.cpp:1572
virtual bool EnableMotor()
Tells if the motor is enabled.
Declares the node class.
virtual void DisableCollision(RigidBody *lpCollisionBody)
Disables collision between the past-in object and all rigid bodies of this structure.
Definition: Structure.cpp:825
virtual IPhysicsMovableItem * PhysicsMovableItem()
Gets the physics body interface pointer. This is an interface reference to the Vs version of this obj...
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Definition: AnimatBase.cpp:447
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
Definition: StdXml.cpp:307
float m_fltSize
The radius of the graphical sphere shown for the structure position.
Definition: Structure.h:114
virtual Joint * FindJoint(std::string strJointID, bool bThrowError=true)
Finds a joint with a specified ID within this structure.
Definition: Structure.cpp:457
virtual void AddCollisionPair(std::string strID1, std::string strID2)
Adds a collision pair to m_aryExcludeCollisionList.
Definition: Structure.cpp:914
RigidBody * Parent()
Gets the parent RigidBody of this part.
Definition: MovableItem.cpp:90
virtual void EnableCollision(RigidBody *lpCollisionBody)
Enables collision between the past-in object and all rigid bodies of this structure.
Definition: Structure.cpp:802
virtual void StepPhysicsEngine()
Allows the organism and its parts to update at each time slice.
Definition: Structure.cpp:286
virtual void Load(StdUtils::CStdXml &oXml)
Loads the item using an XML data packet.
Definition: AnimatBase.cpp:771
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.
virtual CStdFPoint Position()
Gets the local position. (m_oPosition)
Structure()
Default constructor.
Definition: Structure.cpp:53
virtual bool AllowRotateDragX()
Gets whether this body part can be rotated along the x-axis by the user with the drag handlers...
Definition: Structure.cpp:175
virtual void Kill(bool bState=true)
Kills.
Definition: Structure.cpp:308
virtual void AddRoot(std::string strXml)
Creates and adds a root body part.
Definition: Structure.cpp:636
ScriptProcessor * m_lpScript
Script processor for running python or other scripting systems related to this structure.
Definition: Structure.h:117
virtual int NumberOfChildren()
Gets the number of children of the current element.
Definition: StdXml.cpp:202
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Definition: Structure.cpp:555
Base class for body parts and neural network nodes.
Definition: Node.h:25
virtual void LoadLayout(CStdXml &oXml)
Loads the layout for this structure from an asl configuration file.
Definition: Structure.cpp:975
virtual void RemoveScript(std::string strID, bool bThrowError=true)
Removes the script based on ID.
Definition: Structure.cpp:738
CStdMap< std::string, Joint * > m_aryJoints
Definition: Structure.h:102
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
virtual void RemoveRoot(std::string strID, bool bThrowError=true)
Removes the root based on ID.
Definition: Structure.cpp:670
Declares the data chart manager class.
virtual bool AllowRotateDragY()
Gets whether this body part can be rotated along the y-axis by the user with the drag handlers...
Definition: Structure.cpp:177
std::string m_strPart1ID
GUID ID of the first part of the collision pair.
Definition: Structure.h:42
Declares the rigid body class.
virtual void StepSimulation()
Step the simulation for this object.
Definition: RigidBody.cpp:1630
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
Declares the structure class.
Declares the odor type class.
virtual void UpdateData()
Collects reporting data for the structure at each time step.
Definition: Structure.cpp:223
virtual float InverseDistanceUnits()
Gets the inverse distance units.
Definition: Simulator.cpp:1742
virtual ScriptProcessor * LoadScript(CStdXml &oXml)
Loads the script.
Definition: Structure.cpp:1072
virtual void EnableMotor(std::string strJointID, bool bVal)
Enables the given joints motor.
Definition: Structure.cpp:760
Declares the odor class.
Declares the simulator class.
Declares the neural module class.
virtual bool FindChildByIndex(int iIndex, bool bThrowError=true)
Finds a child element by index.
Definition: StdXml.cpp:225
virtual CStdPtrArray< CollisionPair > ExclusionList()
Gets the collision exclusion list as an array.
Definition: Structure.cpp:210
Declares the activated item manager class.
virtual void MotorInput(float fltInput)
Sets the desired velocity.
Declares the contact sensor class.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
Definition: Structure.cpp:867
Declares the external stimuli manager class.
virtual RigidBody * FindRigidBody(std::string strBodyID, bool bThrowError=true)
Finds a rigid body with a specified ID within this structure.
Definition: Structure.cpp:489
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
Definition: AnimatBase.cpp:371
The base class for all of the basic rigid body type of objects.
Definition: RigidBody.h:66
virtual void AddScript(std::string strXml)
Creates and adds a scripting object to this structure.
Definition: Structure.cpp:696
Declares the receptive field class.
virtual void AfterResetSimulation()
Called after a simulation reset for some objects.
Definition: RigidBody.cpp:1503
std::string m_strName
The name for this object.
Definition: AnimatBase.h:61
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
Definition: StdXml.cpp:617