AnimatLab  2
Test
RigidBody.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
10 #include "AnimatBase.h"
11 
12 #include "Node.h"
13 #include "IPhysicsMovableItem.h"
14 #include "IPhysicsBody.h"
15 #include "BoundingBox.h"
16 #include "MovableItem.h"
17 #include "BodyPart.h"
18 #include "Joint.h"
19 #include "ReceptiveField.h"
20 #include "ContactSensor.h"
21 #include "RigidBody.h"
22 #include "Structure.h"
23 #include "Organism.h"
24 #include "ActivatedItem.h"
25 #include "ActivatedItemMgr.h"
26 #include "DataChartMgr.h"
27 #include "ExternalStimuliMgr.h"
28 #include "KeyFrame.h"
29 #include "SimulationRecorder.h"
30 #include "OdorType.h"
31 #include "Odor.h"
32 #include "Light.h"
33 #include "LightManager.h"
34 #include "Simulator.h"
35 
36 namespace AnimatSim
37 {
38  namespace Environment
39  {
40 
48 {
49  m_bUsesJoint = true;
50  m_lpParent = NULL;
51  m_lpStructure = NULL;
52  m_fltDensity = 1.0;
54 
55  m_lpJointToParent = NULL;
56  m_bFreeze = false;
57  m_bIsContactSensor = false;
58  m_bIsCollisionObject = false;
62  m_lpContactSensor = NULL;
63  m_bFoodSource = false;
64  m_fltFoodEaten = 0;
65  m_lEatTime = 0;
68  m_fltMaxFoodQuantity = 10000;
71 
72  m_fltMaxHydroForce = 1000;
73  m_fltMaxHydroTorque = 1000;
75  m_fltMagnus = 0;
76  m_bEnableFluids = false;
77 
78  m_fltMass = 0;
79  m_fltReportMass = 0;
81 
82  m_bIsStickyPart = false;
83  m_fltStickyOn = 0;
84  m_lpStickyChild = NULL;
85 
86  m_strMaterialID = "DEFAULTMATERIAL";
87 
89 }
90 
98 {
99 
100 try
101 {
102  m_lpParent = NULL;
103 
104  if(m_lpJointToParent)
105  {
106  //Set the reference to this object within the joint to NULL.
107  //This ensures that the joint does not attempt to make any calls back to this
108  //object which is already being deleted.
109  m_lpJointToParent->Child(NULL);
110  delete m_lpJointToParent;
111  }
112 
113  m_lpStickyChild = NULL;
114 
116  m_aryChildParts.RemoveAll();
117 
118  //Remove this from the list of extra data parts if it is on it.
119  m_lpSim->RemoveFromExtractExtraData(this);
120 
121  //If we are not shutting down then we need to remove any references to this object
122  //that are located in other parts collision exclusion lists. If we are shutting down
123  // then it does not matter, so skip it to prevent potential exceptions.
124  if(!m_lpSim->ShuttingDown())
126 }
127 catch(...)
128 {Std_TraceMsg(0, "Caught Error in desctructor of Body\r\n", "", -1, false, true);}
129 }
130 
132 {
133  if(IsRoot())
134  return m_lpStructure->Position();
135  else
136  return BodyPart::Position();
137 }
138 
142 void RigidBody::Position(CStdFPoint &oPoint, bool bUseScaling, bool bFireChangeEvent, bool bUpdateMatrix)
143 {
144  if(IsRoot())
145  m_lpStructure->Position(oPoint, bUseScaling, bFireChangeEvent, bUpdateMatrix);
146  else
147  BodyPart::Position(oPoint, bUseScaling, bFireChangeEvent, bUpdateMatrix);
148 }
149 
151 {
152  if(IsCollisionObject())
153  return COLLISION_SELECTION_MODE;
154  else
155  return GRAPHICS_SELECTION_MODE;
156 }
157 
170 
180 {
181  if(HasStaticChildren())
182  {
183  float fltTotalMass = Mass();
184  CStdFPoint vMass = m_vCenterOfMass * Mass();
185 
186  int iCount = m_aryChildParts.GetSize();
187  for(int iIndex=0; iIndex<iCount; iIndex++)
188  {
189  RigidBody *lpChild = m_aryChildParts[iIndex];
190  if(lpChild->HasStaticJoint())
191  {
192  vMass += ( (lpChild->Position() + lpChild->CenterOfMass()) * lpChild->Mass());
193  fltTotalMass += lpChild->Mass();
194  }
195  }
196 
197  if(fltTotalMass)
198  vMass /= fltTotalMass;
199 
200  vMass.ClearNearZero();
201 
202  return vMass;
203  }
204  else
205  return m_vCenterOfMass;
206 }
207 
216 void RigidBody::CenterOfMass(CStdFPoint &vPoint, bool bUseScaling)
217 {
218  CenterOfMass(vPoint, bUseScaling, true);
219 }
220 
221 void RigidBody::CenterOfMass(CStdFPoint &vPoint, bool bUseScaling, bool bPhysicsCallback)
222 {
223  if(bUseScaling)
225  else
226  m_vCenterOfMass = vPoint;
227 
228  if(m_lpPhysicsBody && bPhysicsCallback)
229  m_lpPhysicsBody->Physics_SetCenterOfMass(m_vCenterOfMass.x, m_vCenterOfMass.y, m_vCenterOfMass.z);
230 }
231 
232 
245 void RigidBody::CenterOfMass(float fltX, float fltY, float fltZ, bool bUseScaling)
246 {
247  CStdFPoint vPos(fltX, fltY, fltZ);
248  CenterOfMass(vPos, bUseScaling);
249 }
250 
262 void RigidBody::CenterOfMass(std::string strXml, bool bUseScaling)
263 {
264  CStdXml oXml;
265  oXml.Deserialize(strXml);
266  oXml.FindElement("Root");
267  oXml.FindChildElement("COM");
268 
269  CStdFPoint vPos;
270  Std_LoadPoint(oXml, "COM", vPos);
271  CenterOfMass(vPos, bUseScaling);
272 }
273 
274 
283 CStdPtrArray<RigidBody> *RigidBody::ChildParts() {return &m_aryChildParts;}
284 
294 
304 
314 
324 
334 void RigidBody::Density(float fltVal, bool bUseScaling)
335 {
336  Std_IsAboveMin((float) 0, fltVal, true, "Density", true);
337 
338  m_fltDensity = fltVal;
339  if(bUseScaling)
340  {
341  m_fltDensity /= m_lpSim->DisplayMassUnits(); //Scale the mass units down to one. If we are using Kg then the editor will save it out as 1000. We need this to be 1 Kg though.
342  m_fltDensity *= pow(m_lpSim->DenominatorDistanceUnits(), 3); //Perform a conversion if necessary because we may be using different units in the denominator.
343  }
344 
347 
348  if(m_lpPhysicsBody)
349  m_lpPhysicsBody->Physics_SetDensity(m_fltDensity);
350 };
351 
352 
353 float RigidBody::Mass() {return m_fltMass;}
354 
355 void RigidBody::Mass(float fltVal, bool bUseScaling)
356 {
357  Mass(fltVal, bUseScaling, true);
358 }
359 
360 void RigidBody::Mass(float fltVal, bool bUseScaling, bool bPhysicsCallback)
361 {
362  Std_IsAboveMin((float) 0, fltVal, true, "Mass", true);
363 
364  m_fltMass = fltVal;
365  if(bUseScaling)
366  m_fltMass /= m_lpSim->DisplayMassUnits(); //Scale the mass units down to one. If we are using Kg then the editor will save it out as 1000. We need this to be 1 Kg though.
367 
369 
370  if(m_lpPhysicsBody && bPhysicsCallback)
371  m_lpPhysicsBody->Physics_SetMass(m_fltMass);
372 }
373 
374 float RigidBody::MassWithChildren()
375 {
376  float fltTotalMass = Mass();
377  int iCount = m_aryChildParts.GetSize();
378  for(int iIndex=0; iIndex<iCount; iIndex++)
379  {
380  RigidBody *lpChild = m_aryChildParts[iIndex];
381  fltTotalMass += lpChild->MassWithChildren();
382  }
383 
384  return fltTotalMass;
385 }
386 
387 float RigidBody::Volume() {return m_fltVolume;}
388 
389 void RigidBody::Volume(float fltVal, bool bUseScaling)
390 {
391  Std_IsAboveMin((float) 0, fltVal, true, "Volume");
392 
393  m_fltVolume = fltVal;
394  //if(bUseScaling)
395  // m_fltMass /= m_lpSim->DisplayMassUnits(); //Scale the mass units down to one. If we are using Kg then the editor will save it out as 1000. We need this to be 1 Kg though.
396 
397  m_fltReportVolume = m_fltVolume*pow(m_lpSim->DistanceUnits(), (float) 3.0);
398 }
399 
400 
413 bool RigidBody::Freeze() {return m_bFreeze;}
414 
427 void RigidBody::Freeze(bool bVal)
428 {
429  Freeze(bVal, true);
430 }
431 
432 void RigidBody::Freeze(bool bVal, bool bPhysicsCallback)
433 {
434  m_bFreeze = bVal;
435 
436  if(m_lpPhysicsBody && bPhysicsCallback)
437  m_lpPhysicsBody->Physics_SetFreeze(bVal);
438 }
439 
449 
459 
469 
479 
492 
501 void RigidBody::IsStickyPart(bool bVal)
502 {
503  m_bIsStickyPart = bVal;
504  StickyOn(false);
505 
506  //If we are disabling stick parts then make sure to remove the sticky lock
508  m_lpPhysicsBody->Physics_DeleteStickyLock();
509 }
510 
521 
530 void RigidBody::StickyOn(float fltVal)
531 {
532  if(m_bIsStickyPart)
533  if(fltVal)
534  m_fltStickyOn = 1;
535  else
536  m_fltStickyOn = 0;
537 }
538 
548 
558 {
559  if(m_bIsStickyPart)
560  m_lpStickyChild = lpChild;
561 }
562 
572 {
573  if(m_lpStructure)
574  return (m_lpStructure->Body() == this);
575  else
576  return false;
577 }
578 
588 {
589  if(!IsRoot() && !IsContactSensor() && IsCollisionObject() && !JointToParent())
590  return true;
591  return false;
592 }
593 
608 {
609  int iCount = m_aryChildParts.GetSize();
610  for(int iIndex=0; iIndex<iCount; iIndex++)
611  if(m_aryChildParts[iIndex]->HasStaticJoint())
612  return true;
613 
614  return false;
615 }
616 
627 {
628  float fltMass = 0;
629  int iCount = m_aryChildParts.GetSize();
630  for(int iIndex=0; iIndex<iCount; iIndex++)
631  if(m_aryChildParts[iIndex]->HasStaticJoint())
632  fltMass += m_aryChildParts[iIndex]->Mass();
633 
634  return fltMass;
635 }
636 
646 
655 void RigidBody::IsFoodSource(bool bVal)
656 {
657  m_bFoodSource = bVal;
658 
659  if(m_lpSim)
660  {
661  if(m_bFoodSource)
662  m_lpSim->AddFoodSource(this);
663  else
664  m_lpSim->RemoveFoodSource(this);
665  }
666 }
667 
677 
687 void RigidBody::FoodQuantity(float fltVal)
688 {
689  Std_InValidRange((float) 0, (float) 100000, fltVal, true, "FoodQuantity");
690  m_fltFoodQuantity = fltVal;
691 
692  //If the sim is running then we do not set the init Qty. Only set it if changed while the sim is not running.
693  if(!m_lpSim->SimRunning())
695 }
696 
706 
715 void RigidBody::FoodEaten(float fltVal) {m_fltFoodEaten = fltVal;}
716 
726 
735 void RigidBody::FoodReplenishRate(float fltVal)
736 {
737  Std_InValidRange((float) 0, (float) 100000, fltVal, true, "FoodReplenishRate");
738  m_fltFoodReplenishRate = fltVal;
739 }
740 
750 
760 void RigidBody::FoodEnergyContent(float fltVal)
761 {
762  Std_InValidRange((float) 0, (float) 100000, fltVal, true, "FoodEnergyContent");
763  m_fltFoodEnergyContent = fltVal;
764 }
774 
784 void RigidBody::MaxFoodQuantity(float fltVal)
785 {
786  Std_InValidRange((float) 0, (float) 100000, fltVal, true, "MaxFoodQuantity");
787  m_fltMaxFoodQuantity = fltVal;
788 }
789 
799 
809 void RigidBody::LinearVelocityDamping(float fltVal, bool bUseScaling)
810 {
811  Std_InValidRange((float) 0, (float) 1000, fltVal, true, "RigidBody::LinearVelocityDamping");
812 
813  if(bUseScaling)
814  fltVal = fltVal/m_lpSim->DisplayMassUnits();
816 
817  if(m_lpPhysicsBody)
819 }
820 
830 
840 void RigidBody::AngularVelocityDamping(float fltVal, bool bUseScaling)
841 {
842  Std_InValidRange((float) 0, (float) 1000, fltVal, true, "RigidBody::AngularVelocityDamping");
843 
844  if(bUseScaling)
845  fltVal = fltVal/m_lpSim->DisplayMassUnits();
847 
848  if(m_lpPhysicsBody)
850 }
851 
865 std::string RigidBody::MaterialID() {return m_strMaterialID;}
866 
880 void RigidBody::MaterialID(std::string strID)
881 {
882  m_strMaterialID = Std_ToUpper(strID);
883 
884  if(m_lpPhysicsBody)
885  m_lpPhysicsBody->Physics_SetMaterialID(m_strMaterialID);
886 }
887 
897 
908 void RigidBody::BuoyancyCenter(CStdFPoint &oPoint, bool bUseScaling)
909 {
910  if(bUseScaling)
912  else
913  m_vBuoyancyCenter = oPoint;
914 
915  if(m_lpPhysicsBody)
916  m_lpPhysicsBody->Physics_FluidDataChanged();
917 }
918 
931 void RigidBody::BuoyancyCenter(float fltX, float fltY, float fltZ, bool bUseScaling)
932 {
933  CStdFPoint vPos(fltX, fltY, fltZ);
934  BuoyancyCenter(vPos, bUseScaling);
935 }
936 
948 void RigidBody::BuoyancyCenter(std::string strXml, bool bUseScaling)
949 {
950  CStdXml oXml;
951  oXml.Deserialize(strXml);
952  oXml.FindElement("Root");
953  oXml.FindChildElement("BuoyancyCenter");
954 
955  CStdFPoint vPos;
956  Std_LoadPoint(oXml, "BuoyancyCenter", vPos);
957  BuoyancyCenter(vPos, bUseScaling);
958 }
959 
969 
979 void RigidBody::BuoyancyScale(float fltVal)
980 {
981  Std_IsAboveMin((float) 0, fltVal, true, "BuoyancyScale", true);
982 
983  m_fltBuoyancyScale = fltVal;
984 
985  if(m_lpPhysicsBody)
986  m_lpPhysicsBody->Physics_FluidDataChanged();
987 }
988 
997 CStdFPoint RigidBody::LinearDrag() {return m_vLinearDrag;}
998 
1007 void RigidBody::LinearDrag(CStdFPoint &oPoint)
1008 {
1009  m_vLinearDrag = oPoint;
1010 
1011  if(m_lpPhysicsBody)
1012  m_lpPhysicsBody->Physics_FluidDataChanged();
1013 }
1014 
1025 void RigidBody::LinearDrag(float fltX, float fltY, float fltZ)
1026 {
1027  CStdFPoint vPos(fltX, fltY, fltZ);
1028  LinearDrag(vPos);
1029 }
1030 
1040 void RigidBody::LinearDrag(std::string strXml)
1041 {
1042  CStdXml oXml;
1043  oXml.Deserialize(strXml);
1044  oXml.FindElement("Root");
1045  oXml.FindChildElement("LinearDrag");
1046 
1047  CStdFPoint vPos;
1048  Std_LoadPoint(oXml, "LinearDrag", vPos);
1049  LinearDrag(vPos);
1050 }
1051 
1061 
1070 void RigidBody::AngularDrag(CStdFPoint &oPoint)
1071 {
1072  m_vAngularDrag = oPoint;
1073 
1074  if(m_lpPhysicsBody)
1075  m_lpPhysicsBody->Physics_FluidDataChanged();
1076 }
1077 
1088 void RigidBody::AngularDrag(float fltX, float fltY, float fltZ)
1089 {
1090  CStdFPoint vPos(fltX, fltY, fltZ);
1091  AngularDrag(vPos);
1092 }
1093 
1103 void RigidBody::AngularDrag(std::string strXml)
1104 {
1105  CStdXml oXml;
1106  oXml.Deserialize(strXml);
1107  oXml.FindElement("Root");
1108  oXml.FindChildElement("AngularDrag");
1109 
1110  CStdFPoint vPos;
1111  Std_LoadPoint(oXml, "AngularDrag", vPos);
1112  AngularDrag(vPos);
1113 }
1114 
1124 
1134 void RigidBody::MaxHydroForce(float fltVal, bool bUseScaling)
1135 {
1136  Std_IsAboveMin((float) 0, fltVal, true, "MaxHydroForce", true);
1137 
1138  if(bUseScaling)
1139  fltVal *= (m_lpSim->InverseMassUnits() * m_lpSim->InverseDistanceUnits()); //This is a force.
1140 
1141  m_fltMaxHydroForce = fltVal;
1142 }
1143 
1153 
1163 void RigidBody::MaxHydroTorque(float fltVal, bool bUseScaling)
1164 {
1165  Std_IsAboveMin((float) 0, fltVal, true, "MaxHydroTorque", true);
1166 
1167  if(bUseScaling)
1169 
1170  m_fltMaxHydroTorque = fltVal;
1171 }
1172 
1182 
1192 void RigidBody::Magnus(float fltVal)
1193 {
1194  Std_IsAboveMin((float) 0, fltVal, true, "Magnus", true);
1195 
1196  m_fltMagnus = fltVal;
1197 
1198  if(m_lpPhysicsBody)
1199  m_lpPhysicsBody->Physics_FluidDataChanged();
1200 }
1201 
1211 
1220 void RigidBody::EnableFluids(bool bVal)
1221 {
1222  m_bEnableFluids = bVal;
1223 
1224  if(m_lpPhysicsBody)
1225  m_lpPhysicsBody->Physics_FluidDataChanged();
1226 }
1227 
1228 bool RigidBody::HasCollisionGeometry()
1229 {
1230  if(m_lpPhysicsBody)
1231  return m_lpPhysicsBody->Physics_HasCollisionGeometry();
1232  else
1233  return false;
1234 }
1235 
1245 
1246 
1261 void RigidBody::AddSurfaceContact(RigidBody *lpContactedSurface)
1262 {
1264 }
1265 
1281 {
1284 }
1285 
1286 
1301 {
1302  if(iCount >= 0)
1303  m_fltSurfaceContactCount = iCount;
1304 
1306  //if(iCount > 0)
1307  // iCount = iCount;
1308 }
1309 
1310 
1320 void RigidBody::Eat(float fltBiteSize, long lTimeSlice)
1321 {
1322  if(m_lEatTime != lTimeSlice)
1323  m_fltFoodEaten = 0;
1324 
1325  m_fltFoodQuantity -= fltBiteSize;
1326  m_fltFoodEaten += fltBiteSize;
1327  m_lEatTime = lTimeSlice;
1328 }
1329 
1344 {
1345  if(!lpBody)
1346  THROW_TEXT_ERROR(Al_Err_lBodyNotDefined, Al_Err_strBodyNotDefined, "EnableCollision");
1347 
1348  if(FindCollisionExclusionBody(lpBody, false))
1349  m_aryExcludeCollisionSet.erase(lpBody);
1350 
1351  if(lpBody->FindCollisionExclusionBody(this, false))
1352  lpBody->m_aryExcludeCollisionSet.erase(this);
1353 
1354  if(m_lpPhysicsBody)
1355  m_lpPhysicsBody->Physics_EnableCollision(lpBody);
1356 
1357  if(lpBody->m_lpPhysicsBody)
1358  lpBody->m_lpPhysicsBody->Physics_EnableCollision(this);
1359 }
1360 
1375 {
1376  if(!lpBody)
1377  THROW_TEXT_ERROR(Al_Err_lBodyNotDefined, Al_Err_strBodyNotDefined, "DisableCollision");
1378 
1379  if(!FindCollisionExclusionBody(lpBody, false))
1380  m_aryExcludeCollisionSet.insert(lpBody);
1381 
1382  if(!lpBody->FindCollisionExclusionBody(this, false))
1383  lpBody->m_aryExcludeCollisionSet.insert(this);
1384 
1385  if(m_lpPhysicsBody)
1386  m_lpPhysicsBody->Physics_DisableCollision(lpBody);
1387 
1388  if(lpBody->m_lpPhysicsBody)
1389  lpBody->m_lpPhysicsBody->Physics_DisableCollision(this);
1390 }
1391 
1404 bool RigidBody::FindCollisionExclusionBody(RigidBody *lpBody, bool bThrowError)
1405 {
1406  std::unordered_set<RigidBody *>::iterator oPos;
1407  oPos = m_aryExcludeCollisionSet.find(lpBody);
1408 
1409  if(oPos != m_aryExcludeCollisionSet.end())
1410  return true;
1411  else if(bThrowError)
1412  THROW_TEXT_ERROR(Al_Err_lItemNotFound, Al_Err_strItemNotFound, "Exclusion List Body Part: " + lpBody->ID());
1413 
1414  return false;
1415 }
1416 
1425 {
1426  for (std::unordered_set<RigidBody *>::iterator itr = m_aryExcludeCollisionSet.begin(); itr != m_aryExcludeCollisionSet.end(); ++itr)
1427  {
1428  RigidBody *lpBody = *(itr);
1429 
1430  if(lpBody->FindCollisionExclusionBody(this, false))
1431  {
1432  lpBody->m_aryExcludeCollisionSet.erase(this);
1433 
1434  if(lpBody->m_lpPhysicsBody)
1435  lpBody->m_lpPhysicsBody->Physics_DisableCollision(this);
1436  }
1437  }
1438 }
1439 
1452 {
1453  if(HasCollisionGeometry())
1454  return this;
1455  else if(m_lpParent)
1457  else
1458  return false;
1459 }
1460 
1461 void RigidBody::Kill(bool bState)
1462 {
1463  BodyPart::Kill(bState);
1464 
1465  int iCount = m_aryChildParts.GetSize();
1466  for(int iIndex=0; iIndex<iCount; iIndex++)
1467  m_aryChildParts[iIndex]->Kill(bState);
1468 
1469  if(m_lpJointToParent)
1470  m_lpJointToParent->Kill(bState);
1471 }
1472 
1474 {
1476 
1478  //int i=5;
1479  //if(Std_ToLower(m_strID) == "b42f968f-0639-4a69-9974-9e0f411d40d8") // && m_lpSim->Time() > 1.8
1480  // i=6;
1481 
1488  m_lpPhysicsMovableItem->Physics_ResetSimulation();
1489 
1490  if(m_lpJointToParent)
1492 
1493  int iCount = m_aryChildParts.GetSize();
1494  for(int iIndex=0; iIndex<iCount; iIndex++)
1495  m_aryChildParts[iIndex]->ResetSimulation();
1496 
1498  m_fltFoodEaten = 0;
1500  StickyOn(false);
1501 }
1502 
1504 {
1505  int iCount = m_aryChildParts.GetSize();
1506  for(int iIndex=0; iIndex<iCount; iIndex++)
1508 
1509  if(m_lpJointToParent)
1511 }
1512 
1532 {
1533  //We have the replenish rate in Quantity/s, but we need it in Quantity/timeslice. Lets recalculate it here.
1534  if(m_bFoodSource)
1536 
1537  CreateChildParts();
1538 }
1539 
1549 {
1550  int iCount = m_aryChildParts.GetSize();
1551  for(int iIndex=0; iIndex<iCount; iIndex++)
1552  m_aryChildParts[iIndex]->CreateParts();
1553 }
1554 
1573 {
1575 }
1576 
1586 {
1587  int iCount = m_aryChildParts.GetSize();
1588  for(int iIndex=0; iIndex<iCount; iIndex++)
1589  m_aryChildParts[iIndex]->CreateJoints();
1590 }
1591 
1593 {
1594  //If the simulation is pausing then we need to remove any sticky locks
1596  m_lpPhysicsBody->Physics_DeleteStickyLock();
1597 }
1598 
1599 int RigidBody::GetTargetDataTypeIndex(const std::string &strDataType)
1600 {
1601  std::string strType = Std_CheckString(strDataType);
1602 
1603  if(strType == "BODYFORCEX")
1604  return BODY_FORCE_X_TYPE;
1605  else if(strType == "BODYFORCEY")
1606  return BODY_FORCE_Y_TYPE;
1607  else if(strType == "BODYFORCEZ")
1608  return BODY_FORCE_Z_TYPE;
1609  else if(strType == "STICKYON")
1610  return STICKY_ON_TYPE;
1611  else if(strType == "STICKYOFF")
1612  return STICKY_OFF_TYPE;
1613  else
1614  return -1;
1615 
1616 }
1617 
1618 void RigidBody::AddExternalNodeInput(int iTargetDataType, float fltInput)
1619 {
1620  if(iTargetDataType == STICKY_ON_TYPE && fltInput > 0.5)
1621  m_fltStickyOn = 1;
1622  else if(iTargetDataType == STICKY_OFF_TYPE && fltInput > 0.5)
1623  m_fltStickyOn = 0;
1624 
1626  //if(m_fltStickyOn > 0.8)
1627  // fltInput = fltInput;
1628 }
1629 
1631 {
1633 
1634  if(m_bFoodSource)
1635  {
1639 
1640  //Clear the food eaten variable if it has been around for too long.
1642  m_fltFoodEaten = 0;
1643  }
1644 
1646  m_lpPhysicsBody->Physics_StepHydrodynamicSimulation();
1647 
1648  //Must update the data before calling step sim on children because they may depend on
1649  //some of the data that is collected, like the world matrix for this object.
1650  UpdateData();
1651 
1652  int iCount = m_aryChildParts.GetSize();
1653  for(int iIndex=0; iIndex<iCount; iIndex++)
1654  m_aryChildParts[iIndex]->StepSimulation();
1655 
1656  if(m_lpJointToParent)
1658 }
1659 
1660 #pragma region DataAccesMethods
1661 
1662 float *RigidBody::GetDataPointer(const std::string &strDataType)
1663 {
1664  std::string strType = Std_CheckString(strDataType);
1665 
1666  if(strType == "FOODQUANTITY")
1667  return &m_fltFoodQuantity;
1668  if(strType == "FOODEATEN")
1669  return &m_fltFoodEaten;
1670  if(strType == "ENABLE")
1671  return &m_fltEnabled;
1672  if(strType == "CONTACTCOUNT")
1673  return &m_fltSurfaceContactCount;
1674  if(strType == "DENSITY")
1675  {
1676  GetDensity();
1677  return &m_fltReportDensity;
1678  }
1679  if(strType == "MASS")
1680  {
1681  GetMass();
1682  return &m_fltReportMass;
1683  }
1684  if(strType == "VOLUME")
1685  {
1686  GetVolume();
1687  return &m_fltReportVolume;
1688  }
1689  if(strType == "STICKYON")
1690  {
1691  return &m_fltStickyOn;
1692  }
1693 
1694  float *lpData = NULL;
1696  {
1697  float *lpData = NULL;
1698  lpData = m_lpPhysicsMovableItem->Physics_GetDataPointer(strDataType);
1699  if(lpData) return lpData;
1700  }
1701 
1702  return BodyPart::GetDataPointer(strDataType);
1703 }
1704 
1705 
1706 bool RigidBody::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
1707 {
1708  std::string strType = Std_CheckString(strDataType);
1709 
1710  if(BodyPart::SetData(strType, strValue, false))
1711  return true;
1712 
1713  if(strType == "FREEZE")
1714  {
1715  Freeze(Std_ToBool(strValue));
1716  return true;
1717  }
1718 
1719  if(strType == "DENSITY")
1720  {
1721  Density((float) atof(strValue.c_str()));
1722  return true;
1723  }
1724 
1725  if(strType == "MASS")
1726  {
1727  Mass((float) atof(strValue.c_str()));
1728  return true;
1729  }
1730 
1731  if(strType == "COM")
1732  {
1733  CenterOfMass(strValue);
1734  return true;
1735  }
1736 
1737  if(strType == "FOODSOURCE")
1738  {
1739  IsFoodSource(Std_ToBool(strValue));
1740  return true;
1741  }
1742 
1743  if(strType == "FOODQUANTITY")
1744  {
1745  FoodQuantity((float) atof(strValue.c_str()));
1746  return true;
1747  }
1748 
1749  if(strType == "MAXFOODQUANTITY")
1750  {
1751  MaxFoodQuantity((float) atof(strValue.c_str()));
1752  return true;
1753  }
1754 
1755  if(strType == "FOODREPLENISHRATE")
1756  {
1757  FoodReplenishRate((float) atof(strValue.c_str()));
1758  return true;
1759  }
1760 
1761  if(strType == "FOODENERGYCONTENT")
1762  {
1763  FoodEnergyContent((float) atof(strValue.c_str()));
1764  return true;
1765  }
1766 
1767  if(strDataType == "BUOYANCYCENTER")
1768  {
1769  BuoyancyCenter(strValue);
1770  return true;
1771  }
1772 
1773  if(strType == "BUOYANCYSCALE")
1774  {
1775  BuoyancyScale((float) atof(strValue.c_str()));
1776  return true;
1777  }
1778 
1779  if(strDataType == "LINEARDRAG")
1780  {
1781  LinearDrag(strValue);
1782  return true;
1783  }
1784 
1785  if(strDataType == "LINEARDRAG.X")
1786  {
1787  LinearDrag(atof(strValue.c_str()), m_vLinearDrag.y, m_vLinearDrag.z);
1788  return true;
1789  }
1790 
1791  if(strDataType == "LINEARDRAG.Y")
1792  {
1793  LinearDrag(m_vLinearDrag.x, atof(strValue.c_str()), m_vLinearDrag.z);
1794  return true;
1795  }
1796 
1797  if(strDataType == "LINEARDRAG.Z")
1798  {
1799  LinearDrag(m_vLinearDrag.x, m_vLinearDrag.y, atof(strValue.c_str()));
1800  return true;
1801  }
1802 
1803  if(strDataType == "ANGULARDRAG")
1804  {
1805  AngularDrag(strValue);
1806  return true;
1807  }
1808 
1809  if(strDataType == "ANGULARDRAG.X")
1810  {
1811  AngularDrag(atof(strValue.c_str()), m_vAngularDrag.y, m_vAngularDrag.z);
1812  return true;
1813  }
1814 
1815  if(strDataType == "ANGULARDRAG.Y")
1816  {
1817  AngularDrag(m_vAngularDrag.x, atof(strValue.c_str()), m_vAngularDrag.z);
1818  return true;
1819  }
1820 
1821  if(strDataType == "ANGULARDRAG.Z")
1822  {
1823  AngularDrag(m_vAngularDrag.x, m_vAngularDrag.y, atof(strValue.c_str()));
1824  return true;
1825  }
1826 
1827  if(strType == "MAXHYDROFORCE")
1828  {
1829  MaxHydroForce((float) atof(strValue.c_str()));
1830  return true;
1831  }
1832 
1833  if(strType == "MAXHYDROTORQUE")
1834  {
1835  MaxHydroTorque((float) atof(strValue.c_str()));
1836  return true;
1837  }
1838 
1839  if(strType == "MAGNUS")
1840  {
1841  Magnus((float) atof(strValue.c_str()));
1842  return true;
1843  }
1844 
1845  if(strDataType == "ENABLEFLUIDS")
1846  {
1847  EnableFluids(Std_ToBool(strValue));
1848  return true;
1849  }
1850 
1851  if(strDataType == "MATERIALTYPEID")
1852  {
1853  MaterialID(strValue);
1854  return true;
1855  }
1856 
1857  if(strDataType == "ISSTICKYPART")
1858  {
1859  IsStickyPart(Std_ToBool(strValue));
1860  return true;
1861  }
1862 
1863  //If it was not one of those above then we have a problem.
1864  if(bThrowError)
1865  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
1866 
1867  return false;
1868 }
1869 
1870 void RigidBody::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
1871 {
1872  BodyPart::QueryProperties(aryProperties);
1873 
1874  aryProperties.Add(new TypeProperty("FoodEaten", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1875  aryProperties.Add(new TypeProperty("Enable", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1876  aryProperties.Add(new TypeProperty("ContactCount", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1877  aryProperties.Add(new TypeProperty("Volume", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1878  aryProperties.Add(new TypeProperty("StickyOn", AnimatPropertyType::Boolean, AnimatPropertyDirection::Get));
1879 
1880  aryProperties.Add(new TypeProperty("Freeze", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1881  aryProperties.Add(new TypeProperty("Density", AnimatPropertyType::Float, AnimatPropertyDirection::Both));
1882  aryProperties.Add(new TypeProperty("Mass", AnimatPropertyType::Float, AnimatPropertyDirection::Both));
1883  aryProperties.Add(new TypeProperty("CenterOfMass", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1884  aryProperties.Add(new TypeProperty("FoodSource", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1885  aryProperties.Add(new TypeProperty("FoodQuantity", AnimatPropertyType::Float, AnimatPropertyDirection::Both));
1886  aryProperties.Add(new TypeProperty("MaxFoodQuantity", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1887  aryProperties.Add(new TypeProperty("FoodReplenishRate", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1888  aryProperties.Add(new TypeProperty("FoodEnergyContent", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1889  aryProperties.Add(new TypeProperty("BuoyancyCenter", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1890  aryProperties.Add(new TypeProperty("BuoyancyScale", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1891  aryProperties.Add(new TypeProperty("LinearDrag", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1892  aryProperties.Add(new TypeProperty("LinearDrag.X", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1893  aryProperties.Add(new TypeProperty("LinearDrag.Y", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1894  aryProperties.Add(new TypeProperty("LinearDrag.Z", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1895  aryProperties.Add(new TypeProperty("AngularDrag", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1896  aryProperties.Add(new TypeProperty("AngularDrag.X", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1897  aryProperties.Add(new TypeProperty("AngularDrag.Y", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1898  aryProperties.Add(new TypeProperty("AngularDrag.Z", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1899  aryProperties.Add(new TypeProperty("MaxHydroForce", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1900  aryProperties.Add(new TypeProperty("MaxHydroTorque", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1901  aryProperties.Add(new TypeProperty("Magnus", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1902  aryProperties.Add(new TypeProperty("EnableFluids", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1903  aryProperties.Add(new TypeProperty("MaterialTypeID", AnimatPropertyType::String, AnimatPropertyDirection::Set));
1904  aryProperties.Add(new TypeProperty("IsStickyPart", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
1905 }
1906 
1907 bool RigidBody::AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError, bool bDoNotInit)
1908 {
1909  std::string strType = Std_CheckString(strItemType);
1910 
1911  if(strType == "RIGIDBODY")
1912  {
1913  AddRigidBody(strXml);
1914  return true;
1915  }
1916 
1917  if(strType == "CONTACTSENSOR")
1918  {
1919  AddContactSensor(strXml);
1920  return true;
1921  }
1922 
1923  if(strType == "ODOR")
1924  {
1925  AddOdor(strXml, bDoNotInit);
1926  return true;
1927  }
1928 
1929  //If it was not one of those above then we have a problem.
1930  if(bThrowError)
1931  THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType, "Item Type", strItemType);
1932 
1933  return false;
1934 }
1935 
1936 bool RigidBody::RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError)
1937 {
1938  std::string strType = Std_CheckString(strItemType);
1939 
1940  if(strType == "RIGIDBODY")
1941  {
1942  RemoveRigidBody(strID);
1943  return true;
1944  }
1945 
1946  if(strType == "CONTACTSENSOR")
1947  {
1948  RemoveContactSensor(strID);
1949  return true;
1950  }
1951 
1952  if(strType == "ODOR")
1953  {
1954  RemoveOdor(strID);
1955  return true;
1956  }
1957 
1958  //If it was not one of those above then we have a problem.
1959  if(bThrowError)
1960  THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType, "Item Type", strItemType);
1961 
1962  return false;
1963 }
1964 
1974 {
1975  CStdXml oXml;
1976  oXml.Deserialize(strXml);
1977  oXml.FindElement("Root");
1978  oXml.FindChildElement("RigidBody");
1979 
1980  RigidBody *lpBody = LoadRigidBody(oXml);
1981 
1982  lpBody->Initialize();
1983 
1984  //First create all of the model objects.
1985  lpBody->CreateParts();
1986 
1987  //Then create all of the joints between the models.
1988  lpBody->CreateJoints();
1989 
1990  //Inform the physics object that we have added a child body.
1991  if(m_lpPhysicsBody)
1992  m_lpPhysicsBody->Physics_ChildBodyAdded(lpBody);
1993 
1994  if(m_lpSim && lpBody)
1995  m_lpSim->NotifyRigidBodyAdded(lpBody->ID());
1996 
1997  return lpBody;
1998 }
1999 
2010 void RigidBody::RemoveRigidBody(std::string strID, bool bThrowError)
2011 {
2012  int iPos = FindChildListPos(strID, bThrowError);
2013 
2014  RigidBody *lpChild = m_aryChildParts[iPos];
2015  bool bHasStaticJoint = bHasStaticJoint = lpChild->HasStaticJoint();
2016 
2017  m_aryChildParts.RemoveAt(iPos);
2019 
2020  //Inform the physics object that we are removing a child body.
2021  if(m_lpPhysicsBody)
2022  m_lpPhysicsBody->Physics_ChildBodyRemoved(bHasStaticJoint);
2023 
2024  if(m_lpSim)
2025  m_lpSim->NotifyRigidBodyRemoved(strID);
2026 }
2027 
2028 
2042 int RigidBody::FindChildListPos(std::string strID, bool bThrowError)
2043 {
2044  std::string sID = Std_ToUpper(Std_Trim(strID));
2045 
2046  int iCount = m_aryChildParts.GetSize();
2047  for(int iIndex=0; iIndex<iCount; iIndex++)
2048  if(m_aryChildParts[iIndex]->ID() == sID)
2049  return iIndex;
2050 
2051  if(bThrowError)
2052  THROW_TEXT_ERROR(Al_Err_lBodyOrJointIDNotFound, Al_Err_strBodyOrJointIDNotFound, "ID");
2053 
2054  return -1;
2055 }
2056 
2065 void RigidBody::AddContactSensor(std::string strXml)
2066 {
2067  CStdXml oXml;
2068  oXml.Deserialize(strXml);
2069  oXml.FindElement("Root");
2070  oXml.FindChildElement("ContactSensor");
2071 
2072  LoadContactSensor(oXml);
2073 
2075  m_lpPhysicsBody->Physics_ContactSensorAdded(m_lpContactSensor);
2076 }
2077 
2088 void RigidBody::RemoveContactSensor(std::string strID, bool bThrowError)
2089 {
2090  if(m_lpContactSensor)
2091  {
2092  delete m_lpContactSensor;
2093  m_lpContactSensor = NULL;
2094 
2095  if(m_lpPhysicsBody)
2096  m_lpPhysicsBody->Physics_ContactSensorRemoved();
2097  }
2098 }
2099 
2101 {
2102  if(m_lpPhysicsBody)
2103  m_lpPhysicsBody->Physics_UpdateNode();
2104 
2105  UpdateChildPhysicsPosFromGraphics();
2106 }
2107 
2108 void RigidBody::UpdateChildPhysicsPosFromGraphics()
2109 {
2110  if(m_lpJointToParent)
2112 
2113  int iCount = m_aryChildParts.GetSize();
2114  for(int iIndex=0; iIndex<iCount; iIndex++)
2116 }
2117 
2118 #pragma endregion
2119 
2121 {
2122  CStdFPoint vTemp;
2123 
2124  Std_LoadPoint(oXml, "Position", vTemp);
2125 
2126  if(!IsRoot())
2127  {
2128  Position(vTemp, true, false, false);
2129  //AbsolutePosition(m_lpParent->AbsolutePosition() + m_oPosition);
2130  }
2131  else
2132  {
2133  CStdFPoint oPos = m_lpStructure->Position();
2134  BodyPart::Position(oPos, false, false, false);
2135  }
2136 }
2137 
2138 void RigidBody::Load(CStdXml &oXml)
2139 {
2140  CStdFPoint vPoint;
2141 
2143  m_aryChildParts.RemoveAll();
2144 
2145  m_lpSim->IncrementPhysicsBodyCount();
2146 
2147  BodyPart::Load(oXml);
2148 
2149  oXml.IntoElem(); //Into RigidBody Element
2150 
2151  vPoint.Set(0, 0, 0);
2152  if(oXml.FindChildElement("COM", false))
2153  {
2154  Std_LoadPoint(oXml, "COM", vPoint);
2155  CenterOfMass(vPoint, true, false);
2156  }
2157  else
2158  CenterOfMass(vPoint, true, false);
2159 
2160  Density(oXml.GetChildFloat("Density", m_fltDensity));
2161 
2162  //Get Mass first and only set it if it is >= 0. If it is less than this
2163  //Then we need to calculate it during initialization instead of using the loaded value.
2164  m_fltMass = oXml.GetChildFloat("Mass", m_fltMass);
2165  if(m_fltMass >= 0)
2166  Mass(m_fltMass, true, false);
2167 
2168  MaterialID(oXml.GetChildString("MaterialTypeID", m_strMaterialID));
2169  Freeze(oXml.GetChildBool("Freeze", m_bFreeze), false);
2170  IsContactSensor(oXml.GetChildBool("IsContactSensor", m_bIsContactSensor));
2171  IsCollisionObject(oXml.GetChildBool("IsCollisionObject", m_bIsCollisionObject));
2172  IsStickyPart(oXml.GetChildBool("IsStickyPart", m_bIsStickyPart));
2173 
2174  IsFoodSource(oXml.GetChildBool("FoodSource", m_bFoodSource));
2175  FoodQuantity(oXml.GetChildFloat("FoodQuantity", m_fltFoodQuantity));
2176  MaxFoodQuantity(oXml.GetChildFloat("MaxFoodQuantity", m_fltMaxFoodQuantity));
2177  FoodReplenishRate(oXml.GetChildFloat("FoodReplenishRate", m_fltFoodReplenishRate));
2178  FoodEnergyContent(oXml.GetChildFloat("FoodEnergyContent", m_fltFoodEnergyContent));
2179 
2180  LinearVelocityDamping(oXml.GetChildFloat("LinearVelocityDamping", m_fltLinearVelocityDamping));
2181  AngularVelocityDamping(oXml.GetChildFloat("AngularVelocityDamping", m_fltAngularVelocityDamping));
2182 
2183  vPoint.Set(0, 0, 0);
2184  Std_LoadPoint(oXml, "BuoyancyCenter", vPoint, false);
2185  BuoyancyCenter(vPoint);
2186 
2187  vPoint.Set(0, 0, 0);
2188  Std_LoadPoint(oXml, "LinearDrag", vPoint, false);
2189  LinearDrag(vPoint);
2190 
2191  Std_LoadPoint(oXml, "AngularDrag", vPoint, false);
2192  AngularDrag(vPoint);
2193 
2194  MaxHydroForce(oXml.GetChildFloat("MaxHydroForce", m_fltMaxHydroForce));
2195  MaxHydroTorque(oXml.GetChildFloat("MaxHydroTorque", m_fltMaxHydroTorque));
2196 
2197  BuoyancyScale(oXml.GetChildFloat("BuoyancyScale", m_fltBuoyancyScale));
2198  Magnus(oXml.GetChildFloat("Magnus", m_fltMagnus));
2199  EnableFluids(oXml.GetChildBool("EnableFluids", m_bEnableFluids));
2200 
2201 
2202  //Only load the joint if there is a parent object and this body uses joints.
2203  if(m_lpParent && m_bUsesJoint)
2204  {
2205  //Static joints do not have joints specified. Any time that there is a parent but not joint defined
2206  //then this signals that we need to statically add that part to the parent object geometry.
2207  if(oXml.FindChildElement("Joint", false))
2208  LoadJoint(oXml);
2209  else
2210  m_lpJointToParent = NULL;
2211  }
2212 
2213  if(oXml.FindChildElement("ChildBodies", false))
2214  {
2215  oXml.IntoElem(); //Into ChildBodies Element
2216  int iChildCount = oXml.NumberOfChildren();
2217 
2218  for(int iIndex=0; iIndex<iChildCount; iIndex++)
2219  {
2220  oXml.FindChildByIndex(iIndex);
2221  LoadRigidBody(oXml);
2222  }
2223  oXml.OutOfElem(); //OutOf ChildBodies Element
2224  }
2225 
2226  LoadContactSensor(oXml);
2227 
2228  if(oXml.FindChildElement("OdorSources", false))
2229  {
2230  oXml.IntoElem(); //Into OdorSources Element
2231  int iChildCount = oXml.NumberOfChildren();
2232 
2233  for(int iIndex=0; iIndex<iChildCount; iIndex++)
2234  {
2235  oXml.FindChildByIndex(iIndex);
2236  LoadOdor(oXml);
2237  }
2238  oXml.OutOfElem(); //OutOf OdorSources Element
2239  }
2240 
2241  oXml.OutOfElem(); //OutOf RigidBody Element
2242 }
2243 
2244 void RigidBody::LoadContactSensor(CStdXml &oXml)
2245 {
2246  if(m_lpContactSensor)
2247  THROW_TEXT_ERROR(Al_Err_lContactSensorExists, Al_Err_strContactSensorExists, " RigidBodyID: " + m_strID);
2248 
2249  if(oXml.FindChildElement("ContactSensor", false))
2250  {
2253  m_lpContactSensor->Load(oXml);
2254  }
2255 }
2256 
2269 {
2270  RigidBody *lpChild = NULL;
2271  std::string strType;
2272 
2273 try
2274 {
2275  oXml.IntoElem(); //Into Child Element
2276  std::string strModule = oXml.GetChildString("ModuleName", "");
2277  strType = oXml.GetChildString("Type");
2278  oXml.OutOfElem(); //OutOf Child Element
2279 
2280  lpChild = dynamic_cast<RigidBody *>(m_lpSim->CreateObject(strModule, "RigidBody", strType));
2281  if(!lpChild)
2282  THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType, "RigidBody");
2283 
2284  lpChild->Parent(this);
2285  lpChild->SetSystemPointers(m_lpSim, m_lpStructure, NULL, this, true);
2286 
2287  lpChild->Load(oXml);
2288 
2289  m_aryChildParts.Add(lpChild);
2290  m_lpStructure->AddRigidBody(lpChild);
2291 
2292  return lpChild;
2293 }
2294 catch(CStdErrorInfo oError)
2295 {
2296  if(lpChild) delete lpChild;
2297  RELAY_ERROR(oError);
2298  return NULL;
2299 }
2300 catch(...)
2301 {
2302  if(lpChild) delete lpChild;
2303  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
2304  return NULL;
2305 }
2306 }
2307 
2320 {
2321  std::string strType;
2322 
2323 try
2324 {
2325  oXml.IntoChildElement("Joint"); //Into Joint Element
2326  std::string strModule = oXml.GetChildString("ModuleName", "");
2327  std::string strJointType = oXml.GetChildString("Type");
2328  oXml.OutOfElem(); //OutOf Joint Element
2329 
2330  m_lpJointToParent = dynamic_cast<Joint *>(m_lpSim->CreateObject(strModule, "Joint", strJointType));
2331  if(m_lpJointToParent)
2332  {
2334  m_lpJointToParent->Child(this);
2335 
2336  m_lpJointToParent->SetSystemPointers(m_lpSim, m_lpStructure, NULL, this, true);
2337 
2338  m_lpJointToParent->Load(oXml);
2339 
2341  }
2342 
2343  return m_lpJointToParent;
2344 }
2345 catch(CStdErrorInfo oError)
2346 {
2348  m_lpJointToParent = NULL;
2349  RELAY_ERROR(oError);
2350  return NULL;
2351 }
2352 catch(...)
2353 {
2355  m_lpJointToParent = NULL;
2356  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
2357  return NULL;
2358 }
2359 }
2360 
2371 {
2372  if(!lpOdor)
2373  THROW_ERROR(Al_Err_lOdorNotDefined, Al_Err_strOdorNotDefined);
2374 
2375  try
2376  {
2377  m_aryOdorSources.Add(lpOdor->ID(), lpOdor);
2378  }
2379  catch(CStdErrorInfo oError)
2380  {
2381  oError.m_strError += " Duplicate odor type Key: " + lpOdor->ID();
2382  RELAY_ERROR(oError);
2383  }
2384 }
2385 
2386 
2387 void RigidBody::AddOdor(std::string strXml, bool bDoNotInit)
2388 {
2389  CStdXml oXml;
2390  oXml.Deserialize(strXml);
2391  oXml.FindElement("Root");
2392  oXml.FindChildElement("Odor");
2393 
2394  Odor *lpOdor = LoadOdor(oXml);
2395 
2396  if(!bDoNotInit)
2397  lpOdor->Initialize();
2398 }
2399 
2400 void RigidBody::RemoveOdor(std::string strID, bool bThrowError)
2401 {
2402  m_aryOdorSources.Remove(strID);
2403 }
2404 
2417 {
2418  Odor *lpOdor = NULL;
2419 
2420 try
2421 {
2422  lpOdor = new Odor(this);
2423 
2424  lpOdor->SetSystemPointers(m_lpSim, m_lpStructure, NULL, this, true);
2425  lpOdor->Load(oXml);
2426 
2427  AddOdor(lpOdor);
2428 
2429  return lpOdor;
2430 }
2431 catch(CStdErrorInfo oError)
2432 {
2433  if(lpOdor) delete lpOdor;
2434  RELAY_ERROR(oError);
2435  return NULL;
2436 }
2437 catch(...)
2438 {
2439  if(lpOdor) delete lpOdor;
2440  THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
2441  return NULL;
2442 }
2443 }
2444 
2461 void RigidBody::AddForceAtLocalPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits)
2462 {
2463  if(m_lpPhysicsBody)
2464  m_lpPhysicsBody->Physics_AddBodyForceAtLocalPos(fltPx, fltPy, fltPz, fltFx, fltFy, fltFz, bScaleUnits);
2465 }
2466 
2483 void RigidBody::AddForceAtWorldPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits)
2484 {
2485  if(m_lpPhysicsBody)
2486  m_lpPhysicsBody->Physics_AddBodyForceAtWorldPos(fltPx, fltPy, fltPz, fltFx, fltFy, fltFz, bScaleUnits);
2487 }
2488 
2501 void RigidBody::AddTorque(float fltTx, float fltTy, float fltTz, bool bScaleUnits)
2502 {
2503  if(m_lpPhysicsBody)
2504  m_lpPhysicsBody->Physics_AddBodyTorque(fltTx, fltTy, fltTz, bScaleUnits);
2505 }
2506 
2519 CStdFPoint RigidBody::GetVelocityAtPoint(float x, float y, float z)
2520 {
2521  CStdFPoint vLoc(0, 0, 0);
2522 
2523  if(m_lpPhysicsBody)
2524  vLoc = m_lpPhysicsBody->Physics_GetVelocityAtPoint(x, y, z);
2525 
2526  return vLoc;
2527 }
2528 
2538 {
2539  if(m_lpPhysicsBody)
2540  m_fltMass = m_lpPhysicsBody->Physics_GetMass();
2541 
2542  m_fltReportMass = m_fltMass*m_lpSim->DisplayMassUnits();
2543 
2544  return m_fltMass;
2545 }
2546 
2556 {
2557  if(m_lpPhysicsBody)
2558  m_fltDensity = m_lpPhysicsBody->Physics_GetDensity();
2559 
2562 
2563  return m_fltDensity;
2564 }
2565 
2576 {
2577  if(HasStaticChildren())
2578  return m_fltMass + StaticChildrenMass();
2579  else
2580  return m_fltMass;
2581 }
2582 
2583 
2593 {
2594  if(m_lpPhysicsBody)
2595  m_fltMass = m_lpPhysicsBody->Physics_GetMass();
2596 
2597  float fltVolume = 0;
2598 
2599  if(m_fltDensity)
2600  fltVolume = m_fltMass/m_fltDensity;
2601 
2602  m_fltReportVolume = fltVolume*pow(m_lpSim->DistanceUnits(), (float) 3.0);
2603 
2604  return fltVolume;
2605 }
2606 
2607  } //Environment
2608 } //AnimatSim
virtual float Magnus()
Gets the Magnus coefficient for the body.
Definition: RigidBody.cpp:1181
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
virtual float FoodEnergyContent()
Gets the food energy content.
Definition: RigidBody.cpp:749
IPhysicsBody * m_lpPhysicsBody
Definition: BodyPart.h:31
ContactSensor * m_lpContactSensor
Definition: RigidBody.h:133
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: Joint.cpp:722
Base class file for all Animat simulation objects.
virtual CStdFPoint BuoyancyCenter()
Gets the relative position to the center of the buoyancy in the body.
Definition: RigidBody.cpp:896
virtual void PhysicsTimeStep(float fltVal)
Sets the integration time step for the physics engine.
Definition: Simulator.cpp:1126
virtual float StaticChildrenMass()
Gets the mass of all static children.
Definition: RigidBody.cpp:626
virtual void Initialize()
Initializes this object.
Definition: BodyPart.cpp:400
Declares the simulation recorder class.
float m_fltAngularVelocityDamping
The angular velocity damping for this part.
Definition: RigidBody.h:139
virtual bool IsCollisionObject()
Query if this object is collision object.
Definition: RigidBody.cpp:468
std::string m_strMaterialID
Identifier for the material type this part will use.
Definition: RigidBody.h:169
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
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
virtual void Kill(bool bState=true)
Kills.
Definition: Node.cpp:115
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
virtual float InverseMassUnits()
Gets the inverse mass units.
Definition: Simulator.cpp:1797
virtual void CreateChildJoints()
Loops through all the child parts of this rigid body and call CreateJoints.
Definition: RigidBody.cpp:1585
virtual RigidBody * AddRigidBody(std::string strXml)
Creates and adds a rigid body.
Definition: RigidBody.cpp:1973
virtual float FoodEaten()
Gets the amount of food eaten.
Definition: RigidBody.cpp:705
CStdFPoint m_vBuoyancyCenter
This is the relative position to the center of the buoyancy in the body.
Definition: RigidBody.h:173
virtual void AfterResetSimulation()
Called after a simulation reset for some objects.
Definition: Joint.cpp:734
virtual void ResetSimulation()
Resets the simulation back to time 0.
Definition: BodyPart.cpp:393
virtual CStdFPoint LinearDrag()
Gets the linear drag coefficients for the three axises for the body.
Definition: RigidBody.cpp:997
virtual void UpdateData()
Called to collect any body data for this part.
Definition: BodyPart.cpp:80
virtual float LinearVelocityDamping()
Gets the linear velocity damping for this body part.
Definition: RigidBody.cpp:798
Declares the body part class.
void RemoveRigidBody(std::string strID)
Removes the rigid body with the specified ID.
Definition: Structure.cpp:426
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
Definition: RigidBody.cpp:1936
virtual void RemoveContactSensor(std::string strID, bool bThrowError=true)
Removes the ContactSensor.
Definition: RigidBody.cpp:2088
virtual float FoodQuantity()
Gets the food quantity.
Definition: RigidBody.cpp:676
virtual void UpdatePhysicsPosFromGraphics()
Updates the physics position from graphics.
Definition: Joint.cpp:740
std::string m_strError
The error message.
Definition: StdErrorInfo.h:26
virtual void AddTorque(float fltTx, float fltTy, float fltTz, bool bScaleUnits)
Adds a torque to this body about its center.
Definition: RigidBody.cpp:2501
virtual void LoadPosition(CStdXml &oXml)
Loads the items position.
Definition: RigidBody.cpp:2120
virtual RigidBody * LoadRigidBody(CStdXml &oXml)
Loads a child rigid body.
Definition: RigidBody.cpp:2268
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
float m_fltEnabled
This is used for reporting the enabled state in a GetDataPointer call.
Definition: Node.h:35
virtual bool HasStaticJoint()
Query if this object has a static joint.
Definition: RigidBody.cpp:587
virtual CStdFPoint Position()
Gets the local position. (m_oPosition)
Definition: RigidBody.cpp:131
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 float BuoyancyScale()
Gets the scale used to calculate the buoyancy value.
Definition: RigidBody.cpp:968
virtual bool EnableFluids()
Query if this object has fluid interactions turned on.
Definition: RigidBody.cpp:1210
virtual float GetMassValueWithStaticChildren()
Gets the mass of this part and all static children.
Definition: RigidBody.cpp:2575
virtual float DenominatorDistanceUnits()
Gets the denominator distance units.
Definition: Simulator.cpp:1756
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
float m_fltMass
The mass of the object.
Definition: RigidBody.h:85
virtual bool FindCollisionExclusionBody(RigidBody *lpBody, bool bThrowError=true)
Searches the exclusion collision list to see if the specified part is already present.
Definition: RigidBody.cpp:1404
virtual void Initialize()
Initializes this object.
Definition: AnimatBase.cpp:573
virtual void Eat(float fltBiteSize, long lTimeSlice)
This item is eating the specified amount of food.
Definition: RigidBody.cpp:1320
virtual float AngularVelocityDamping()
Gets the angular velocity damping.
Definition: RigidBody.cpp:829
virtual void DistanceUnits(std::string strUnits)
Sets the distance units.
Definition: Simulator.cpp:1717
virtual float GetDensity()
Gets the density of this part.
Definition: RigidBody.cpp:2555
float m_fltVolume
The volume for the rigid body.
Definition: RigidBody.h:91
Declares the key frame class.
virtual void RemoveSurfaceContact(RigidBody *lpContactedSurface)
Decrements the surface contact count when this part stops colliding with something in the virtual wor...
Definition: RigidBody.cpp:1280
virtual ~RigidBody()
Destructor.
Definition: RigidBody.cpp:97
float m_fltStickyOn
If this is a suction part then this controls when stickness is on.
Definition: RigidBody.h:126
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
bool m_bFoodSource
Tells if this body is considered a food source.
Definition: RigidBody.h:145
long m_lEatTime
Keeps track of how many time slices this part can eat.
Definition: RigidBody.h:166
virtual int VisualSelectionType()
Gets the visual selection type for this part.
Definition: RigidBody.cpp:150
virtual int GetTargetDataTypeIndex(const std::string &strDataType)
Used to convert a string target data type into an integer index.
Definition: RigidBody.cpp:1599
virtual CStdFPoint CenterOfMassWithStaticChildren()
Gets the center of mass of this part with any static children added.
Definition: RigidBody.cpp:179
virtual bool ShuttingDown()
Tells whether the simulation is shutting down or not.
Definition: Simulator.cpp:685
Declares the joint class.
virtual void AddSurfaceContact(RigidBody *lpContactedSurface)
Increments the surface contact count when this part collides with something in the virtual world...
Definition: RigidBody.cpp:1261
Declares the organism class.
virtual bool SimRunning()
Gets whether the simulation is running.
Definition: Simulator.cpp:673
virtual void RemoveCollisionExclusions()
Called by the desctructor. It removes this object from all other collision exclusion lists...
Definition: RigidBody.cpp:1424
float m_fltFoodEnergyContent
The energy content of the food in calories.
Definition: RigidBody.h:163
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
AnimatSim::Environment::Structure * m_lpStructure
The pointer to this items parent Structure. If this is not relevant for this object then this is NULL...
Definition: AnimatBase.h:46
std::string m_strID
The unique Id for this object.
Definition: AnimatBase.h:55
std::string Std_Trim(std::string strVal)
Trims a string.
Declares a light object.
CStdFPoint m_vLinearDrag
This is the drag coefficients for the three axises for the body.
Definition: RigidBody.h:181
virtual float Density()
Gets the uniform density.
Definition: RigidBody.cpp:323
Declares the activated item class.
float m_fltMaxHydroForce
The maximum hyrdodynamic force that can be applied.
Definition: RigidBody.h:187
float m_fltReportVolume
The volume of the object to report to GUI.
Definition: RigidBody.h:94
virtual float DisplayMassUnits()
Gets the density mass units.
Definition: Simulator.cpp:1810
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
bool m_bEnableFluids
true to enable fluid interactions.
Definition: RigidBody.h:196
Declares a light manager object.
virtual RigidBody * Child()
Gets the child RigidBody part for this joint.
Definition: Joint.cpp:507
virtual Odor * LoadOdor(CStdXml &oXml)
Loads an odor source.
Definition: RigidBody.cpp:2416
IPhysicsMovableItem * m_lpPhysicsMovableItem
Definition: MovableItem.h:103
virtual float MaxHydroTorque()
Gets the maximum angular hydrodynamic torque that can be applied to this part.
Definition: RigidBody.cpp:1152
float m_fltMaxHydroTorque
The maximum hyrdodynamic torque that can be applied.
Definition: RigidBody.h:190
float m_fltDensity
Uniform density for the rigid body.
Definition: RigidBody.h:79
Declares the bounding box class.
virtual bool HasStaticChildren()
Query if this rigid body has any static children.
Definition: RigidBody.cpp:607
float m_fltFoodReplenishRate
The rate at which food is replenished.
Definition: RigidBody.h:160
virtual CStdFPoint Position()
Gets the local position. (m_oPosition)
Definition: Structure.cpp:118
float m_fltReportDensity
The density value reported to the GUI.
Definition: RigidBody.h:82
virtual int FindChildListPos(std::string strID, bool bThrowError=true)
Finds the array index for the child part with the specified ID.
Definition: RigidBody.cpp:2042
A standard xml manipulation class.
Definition: StdXml.h:19
float m_fltMagnus
The Magnus coefficient for the body. This is defaulted to zero because it almost always negligble for...
Definition: RigidBody.h:193
virtual void StepSimulation()
Step the simulation for this object.
Definition: AnimatBase.cpp:643
float m_fltReportMass
The mass of the object to report to GUI.
Definition: RigidBody.h:88
virtual CStdPtrArray< RigidBody > * ChildParts()
Gets the array of child parts.
Definition: RigidBody.cpp:283
virtual void CreateJoints()
Allows the rigid body to create its joints using the chosen physics engine.
Definition: RigidBody.cpp:1572
Declares the node class.
virtual void AddOdor(Odor *lpOdor)
Adds an odor source to this body part.
Definition: RigidBody.cpp:2370
virtual bool IsRoot()
Query if this is the root rigid body of the structure or not.
Definition: RigidBody.cpp:571
virtual bool Freeze()
Tells if this part is frozen or not.
Definition: RigidBody.cpp:413
virtual float GetVolume()
Gets the volume of this part.
Definition: RigidBody.cpp:2592
virtual CStdFPoint GetVelocityAtPoint(float x, float y, float z)
Gets a velocity of this body at specified point in the body.
Definition: RigidBody.cpp:2519
CStdPtrArray< RigidBody > m_aryChildParts
Definition: RigidBody.h:98
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
Definition: StdXml.cpp:307
virtual void Body(RigidBody *lpBody)
Sets the root body.
Definition: Structure.cpp:103
virtual void AddExternalNodeInput(int iTargetDataType, float fltInput)
Adds an external node input.
Definition: RigidBody.cpp:1618
virtual bool SimulateHydrodynamics()
Gets whether the simulation uses hydrodynamics.
Definition: Simulator.cpp:1402
RigidBody * Parent()
Gets the parent RigidBody of this part.
Definition: MovableItem.cpp:90
virtual ContactSensor * GetContactSensor()
Gets the receptive field contact sensor.
Definition: RigidBody.cpp:313
bool Std_ToBool(int iVal)
Converts a value toa bool.
virtual void RemoveRigidBody(std::string strID, bool bThrowError=true)
Removes the rigid body with the specified ID.
Definition: RigidBody.cpp:2010
virtual Joint * LoadJoint(CStdXml &oXml)
Loads a child joint.
Definition: RigidBody.cpp:2319
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.
RigidBody * m_lpStickyChild
If we are doing a sticky lock then this is the child part that was locked on.
Definition: RigidBody.h:129
virtual bool GetChildBool(std::string strElementName)
Gets a bool value from the element with the specified name.
Definition: StdXml.cpp:699
virtual CStdFPoint Position()
Gets the local position. (m_oPosition)
virtual float GetMass()
Gets the mass of this part.
Definition: RigidBody.cpp:2537
virtual void AddForceAtLocalPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits)
Adds a world-coordinate based force vector to this body at a specified local body position...
Definition: RigidBody.cpp:2461
virtual void CreateChildParts()
Loops through all the child parts of this rigid body and call CreateParts.
Definition: RigidBody.cpp:1548
virtual bool IsContactSensor()
Query if this object is contact sensor.
Definition: RigidBody.cpp:448
virtual bool IsStickyPart()
Query if this object acts as a sticky part. This only applies to contact sensors. If it is set to tru...
Definition: RigidBody.cpp:491
virtual int NumberOfChildren()
Gets the number of children of the current element.
Definition: StdXml.cpp:202
float m_fltFoodQuantityInit
The initial food quantity to use when simulation is reset.
Definition: RigidBody.h:151
virtual CStdFPoint CenterOfMass()
Gets the user specified center of mass.
Definition: RigidBody.cpp:169
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
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: RigidBody.cpp:1907
virtual void StepSimulation()
Step the simulation for this object.
Definition: Joint.cpp:616
float m_fltLinearVelocityDamping
The linear velocity damping for this body part.
Definition: RigidBody.h:136
CStdFPoint m_vAngularDrag
This is the drag coefficients for the three axises for the body.
Definition: RigidBody.h:184
float m_fltFoodQuantity
The quantity of food that this part contains.
Definition: RigidBody.h:148
virtual RigidBody * ParentWithCollisionGeometry()
Gets a parent that has collision geometry.
Definition: RigidBody.cpp:1451
Declares the data chart manager class.
virtual Joint * JointToParent()
Gets the joint to parent.
Definition: RigidBody.cpp:293
Declares the rigid body class.
virtual float FoodReplenishRate()
Gets the food replenish rate.
Definition: RigidBody.cpp:725
virtual bool IntoChildElement(std::string strElementName, bool bThrowError=true)
Goes into the child element with the specified name.
Definition: StdXml.cpp:278
virtual void StepSimulation()
Step the simulation for this object.
Definition: RigidBody.cpp:1630
virtual float SurfaceContactCount()
Gets the surface contact count.
Definition: RigidBody.cpp:1244
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void SimPausing()
Called just before the simulation pauses.
Definition: RigidBody.cpp:1592
bool Std_LoadPoint(CStdXml &oXml, std::string strName, CStdIPoint &oPoint, bool bThrowError)
Standard load point.
std::unordered_set< RigidBody * > m_aryExcludeCollisionSet
This is the list of other parts that this part is excluded from colliding with.
Definition: RigidBody.h:203
virtual long TimeSlice()
Gets the current time slice.
Definition: Simulator.cpp:613
Declares the structure class.
virtual void SetSurfaceContactCount(int iCount)
Direclty sets the surface contact count for when this part is contacting another rigid body part...
Definition: RigidBody.cpp:1300
Declares the odor type class.
virtual void AddContactSensor(std::string strXml)
Creates and adds a ContactSensor.
Definition: RigidBody.cpp:2065
virtual void AddForceAtWorldPos(float fltPx, float fltPy, float fltPz, float fltFx, float fltFy, float fltFz, bool bScaleUnits)
Adds a world-coordinate based force vector to this body at a specified world-coordinate body position...
Definition: RigidBody.cpp:2483
virtual RigidBody * StickyChild()
Gets the child body part we are stuck to for a sticky part.
Definition: RigidBody.cpp:547
virtual std::string MaterialID()
Gets the material ID for this part.
Definition: RigidBody.cpp:865
virtual bool IsFoodSource()
Query if this object is food source.
Definition: RigidBody.cpp:645
virtual float InverseDistanceUnits()
Gets the inverse distance units.
Definition: Simulator.cpp:1742
virtual float StickyOn()
Query if this stickyness is turned on or not. This only applies to contact sensors that also have IsS...
Definition: RigidBody.cpp:520
Declares the odor class.
Declares the simulator class.
CStdPtrMap< std::string, Odor > m_aryOdorSources
The array odor sources attached to this part.
Definition: RigidBody.h:142
virtual bool FindChildByIndex(int iIndex, bool bThrowError=true)
Finds a child element by index.
Definition: StdXml.cpp:225
float m_fltMaxFoodQuantity
The maximum food quantity that this part can contain.
Definition: RigidBody.h:157
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
float m_fltFoodEaten
Tells how much food is being eaten.
Definition: RigidBody.h:154
Contact sensor for detecting receptive field contacts.
Definition: ContactSensor.h:25
virtual float MaxFoodQuantity()
Gets the maximum food quantity.
Definition: RigidBody.cpp:773
Declares the activated item manager class.
virtual CStdFPoint AngularDrag()
Gets the angular drag coefficients for the three axises for the body.
Definition: RigidBody.cpp:1060
Declares the contact sensor class.
Declares the external stimuli manager class.
bool m_bIsCollisionObject
This determines whether the object is a collision geometry object.
Definition: RigidBody.h:114
virtual float MaxHydroForce()
Gets the maximum linear hydrodynamic force that can be applied to this part.
Definition: RigidBody.cpp:1123
The base class for all of the basic rigid body type of objects.
Definition: RigidBody.h:66
Declares the receptive field class.
virtual void Kill(bool bState=true)
Kills.
Definition: RigidBody.cpp:1461
virtual void AfterResetSimulation()
Called after a simulation reset for some objects.
Definition: RigidBody.cpp:1503
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
Definition: StdXml.cpp:617
RigidBody()
Default constructor.
Definition: RigidBody.cpp:47