AnimatLab  2
Test
MovableItem.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  {
47 {
48  m_bIsVisible = true;
49  m_fltReportIsVisible = 1;
50  m_lpCallback = NULL;
51  m_lpParent = NULL;
53  m_lpMovableSim = NULL;
54 
57  m_fltJointsAlpha = 1;
60  m_fltAlpha = 1;
61 
62  m_vAmbient.Set(0.1f, 0.1f, 0.1f, 1);
63  m_vDiffuse.Set(1, 0, 0, 1);
64  m_vSpecular.Set(0.25f, 0.25f, 0.25f, 1);
65  m_fltShininess = 64;
67  m_bIsSelected = false;
68 }
69 
77 {
78 }
79 
80 #pragma region AccessorMutators
81 
91 
101 {
102  m_lpParent = lpValue;
104  m_lpPhysicsMovableItem->Physics_SetParent(lpValue);
105 }
106 
124 
134 
143 CStdFPoint MovableItem::Position() {return m_oPosition;}
144 
161 void MovableItem::Position(CStdFPoint &oPoint, bool bUseScaling, bool bFireChangeEvent, bool bUpdateMatrix)
162 {
163  if(bUseScaling)
165  else
166  m_oPosition = oPoint;
168 
169  if(m_lpPhysicsMovableItem && bUpdateMatrix)
170  m_lpPhysicsMovableItem->Physics_PositionChanged();
171 
172  if(m_lpCallback && bFireChangeEvent)
174 
176  m_lpPhysicsMovableItem->Physics_UpdateAbsolutePosition();
177 }
178 
197 void MovableItem::Position(float fltX, float fltY, float fltZ, bool bUseScaling, bool bFireChangeEvent, bool bUpdateMatrix)
198 {
199  CStdFPoint vPos(fltX, fltY, fltZ);
200  Position(vPos, bUseScaling, bFireChangeEvent);
201 }
202 
220 void MovableItem::Position(std::string strXml, bool bUseScaling, bool bFireChangeEvent, bool bUpdateMatrix)
221 {
222  CStdXml oXml;
223  oXml.Deserialize(strXml);
224  oXml.FindElement("Root");
225  oXml.FindChildElement("Position");
226 
227  CStdFPoint vPos;
228  Std_LoadPoint(oXml, "Position", vPos);
229  Position(vPos, bUseScaling, bFireChangeEvent);
230 }
231 
241 {
243  THROW_ERROR(Al_Err_lAttempedToReadAbsPosBeforeDefined, Al_Err_strAttempedToReadAbsPosBeforeDefined);
244 
245  return m_oAbsPosition;
246 }
247 
256 void MovableItem::AbsolutePosition(CStdFPoint &oPoint)
257 {
258  m_oAbsPosition = oPoint;
260 }
261 
272 void MovableItem::AbsolutePosition(float fltX, float fltY, float fltZ)
273 {
274  m_oAbsPosition.Set(fltX, fltY, fltZ);
276 }
277 
287 
288 CStdFPoint MovableItem::UpdateAbsolutePosition()
289 {
291  THROW_ERROR(Al_Err_lAttempedToReadAbsPosBeforeDefined, Al_Err_strAttempedToReadAbsPosBeforeDefined);
292 
293  m_lpPhysicsMovableItem->Physics_UpdateAbsolutePosition();
294 
295  return AbsolutePosition();
296 }
297 
307 
316 void MovableItem::ReportPosition(CStdFPoint &oPoint) {m_oReportPosition = oPoint;}
317 
328 void MovableItem::ReportPosition(float fltX, float fltY, float fltZ) {m_oReportPosition.Set(fltX, fltY, fltZ);}
329 
339 
348 void MovableItem::ReportWorldPosition(CStdFPoint &oPoint) {m_oReportWorldPosition = oPoint;}
349 
360 void MovableItem::ReportWorldPosition(float fltX, float fltY, float fltZ) {m_oReportWorldPosition.Set(fltX, fltY, fltZ);}
361 
370 CStdFPoint MovableItem::Rotation() {return m_oRotation;}
371 
386 void MovableItem::Rotation(CStdFPoint &oPoint, bool bFireChangeEvent, bool bUpdateMatrix)
387 {
388  m_oRotation = oPoint;
390 
391  if(m_lpPhysicsMovableItem && bUpdateMatrix)
392  m_lpPhysicsMovableItem->Physics_RotationChanged();
393 
394  if(m_lpCallback && bFireChangeEvent)
396 }
397 
414 void MovableItem::Rotation(float fltX, float fltY, float fltZ, bool bFireChangeEvent, bool bUpdateMatrix)
415 {
416  CStdFPoint vPos(fltX, fltY, fltZ);
417  Rotation(vPos, bFireChangeEvent);
418 }
419 
435 void MovableItem::Rotation(std::string strXml, bool bFireChangeEvent, bool bUpdateMatrix)
436 {
437  CStdXml oXml;
438  oXml.Deserialize(strXml);
439  oXml.FindElement("Root");
440  oXml.FindChildElement("Rotation");
441 
442  CStdFPoint vPos;
443  Std_LoadPoint(oXml, "Rotation", vPos);
444  Rotation(vPos, bFireChangeEvent);
445 }
446 
456 
465 void MovableItem::ReportRotation(CStdFPoint &oPoint) {m_oReportRotation = oPoint;}
466 
477 void MovableItem::ReportRotation(float fltX, float fltY, float fltZ) {m_oReportRotation.Set(fltX, fltY, fltZ);}
478 
489 {
491  return m_lpPhysicsMovableItem->Physics_GetLocalTransformMatrixString();
492  else
493  return "";
494 }
495 
505 
514 void MovableItem::IsVisible(bool bVal)
515 {
516  m_bIsVisible = bVal;
517  m_fltReportIsVisible = (float) bVal;
518 
521 }
522 
532 
542 void MovableItem::GraphicsAlpha(float fltVal)
543 {
544  Std_InValidRange((float) 0, (float) 1, fltVal, true, "GraphicsAlpha");
545 
546  m_fltGraphicsAlpha = fltVal;
547 
549  m_lpPhysicsMovableItem->SetAlpha();
550 }
551 
561 
571 void MovableItem::CollisionsAlpha(float fltVal)
572 {
573  Std_InValidRange((float) 0, (float) 1, fltVal, true, "CollisionsAlpha");
574 
575  m_fltCollisionsAlpha = fltVal;
576 
578  m_lpPhysicsMovableItem->SetAlpha();
579 }
580 
590 
600 void MovableItem::JointsAlpha(float fltVal)
601 {
602  Std_InValidRange((float) 0, (float) 1, fltVal, true, "JointsAlpha");
603 
604  m_fltJointsAlpha = fltVal;
605 
607  m_lpPhysicsMovableItem->SetAlpha();
608 }
609 
619 
630 {
631  Std_InValidRange((float) 0, (float) 1, fltVal, true, "ReceptiveFieldsAlpha");
632 
633  m_fltReceptiveFieldsAlpha = fltVal;
634 
636  m_lpPhysicsMovableItem->SetAlpha();
637 }
638 
648 
658 void MovableItem::SimulationAlpha(float fltVal)
659 {
660  Std_InValidRange((float) 0, (float) 1, fltVal, true, "SimulationAlpha");
661 
662  m_fltSimulationAlpha = fltVal;
663 
665  m_lpPhysicsMovableItem->SetAlpha();
666 }
667 
680 
690 void MovableItem::Alpha(float fltAlpha)
691 {
692  Std_InValidRange((float) 0, (float) 1, fltAlpha, true, "Alpha");
693 
694  m_fltAlpha = fltAlpha;
695 }
696 
706 
715 void MovableItem::Ambient(CStdColor &aryColor)
716 {
717  m_vAmbient = aryColor;
718  if(m_lpPhysicsMovableItem) m_lpPhysicsMovableItem->Physics_SetColor();
719 }
720 
729 void MovableItem::Ambient(float *aryColor)
730 {
731  CStdColor vColor(aryColor[0], aryColor[1], aryColor[2], aryColor[3], 1);
732  Ambient(vColor);
733 }
734 
744 void MovableItem::Ambient(std::string strXml)
745 {
746  CStdColor vColor(1);
747  vColor.Load(strXml, "Color");
748  Ambient(vColor);
749 }
750 
760 
769 void MovableItem::Diffuse(CStdColor &aryColor)
770 {
771  m_vDiffuse = aryColor;
772  if(m_lpPhysicsMovableItem) m_lpPhysicsMovableItem->Physics_SetColor();
773 }
774 
783 void MovableItem::Diffuse(float *aryColor)
784 {
785  CStdColor vColor(aryColor[0], aryColor[1], aryColor[2], aryColor[3], 1);
786  Diffuse(vColor);
787 }
788 
797 void MovableItem::Diffuse(std::string strXml)
798 {
799  CStdColor vColor(1);
800  vColor.Load(strXml, "Color");
801  Diffuse(vColor);
802 }
803 
813 
822 void MovableItem::Specular(CStdColor &aryColor)
823 {
824  m_vSpecular = aryColor;
825  if(m_lpPhysicsMovableItem) m_lpPhysicsMovableItem->Physics_SetColor();
826 }
827 
836 void MovableItem::Specular(float *aryColor)
837 {
838  CStdColor vColor(aryColor[0], aryColor[1], aryColor[2], aryColor[3], 1);
839  Specular(vColor);
840 }
841 
850 void MovableItem::Specular(std::string strXml)
851 {
852  CStdColor vColor(1);
853  vColor.Load(strXml, "Color");
854  Specular(vColor);
855 }
856 
867 
876 void MovableItem::Shininess(float fltVal)
877 {
878  Std_InValidRange((float) 0, (float) 128, fltVal, true, "Shininess");
879  m_fltShininess = fltVal;
880  if(m_lpPhysicsMovableItem) m_lpPhysicsMovableItem->Physics_SetColor();
881 }
882 
891 std::string MovableItem::Texture() {return m_strTexture;}
892 
901 void MovableItem::Texture(std::string strValue)
902 {
903  m_strTexture = strValue;
904  if(m_lpPhysicsMovableItem) m_lpPhysicsMovableItem->Physics_TextureChanged();
905 }
906 
916 
929 void MovableItem::SelectedVertex(CStdFPoint &vPoint, bool bFireChangeEvent, bool bUpdatePhysics)
930 {
931  m_vSelectedVertex = vPoint;
932 
934  m_lpPhysicsMovableItem->Physics_SelectedVertex(vPoint.x, vPoint.y, vPoint.z);
935 
936  if(m_lpCallback && bFireChangeEvent)
937  m_lpCallback->SelectedVertexChanged(vPoint.x, vPoint.y, vPoint.z);
938 }
939 
954 void MovableItem::SelectedVertex(float fltX, float fltY, float fltZ, bool bFireChangeEvent, bool bUpdatePhysics)
955 {
956  CStdFPoint vPos(fltX, fltY, fltZ);
957  SelectedVertex(vPos, bFireChangeEvent, bUpdatePhysics);
958 }
959 
970 
980 void MovableItem::Callback(IMovableItemCallback *lpCallback) {m_lpCallback = lpCallback;}
981 
993 
1005 
1015 {
1017  return m_lpPhysicsMovableItem->Physics_GetBoundingRadius();
1018  else
1019  return 1;
1020 }
1021 
1031 {
1032  BoundingBox bb;
1033 
1035  return m_lpPhysicsMovableItem->Physics_GetBoundingBox();
1036  else
1037  return bb;
1038 }
1039 
1048 void MovableItem::SetBoundingBox(int iIdx, float fltVal)
1049 {
1050 }
1051 
1052 
1062 
1063 
1073 
1083 
1092 bool MovableItem::AllowRotateDragX() {return true;}
1093 
1102 bool MovableItem::AllowRotateDragY() {return true;}
1103 
1112 bool MovableItem::AllowRotateDragZ() {return true;}
1113 
1123 {
1124  if(fltRadius <= 0)
1126  else
1127  m_fltUserDefinedDraggerRadius = fltRadius;
1128 
1130  m_lpPhysicsMovableItem->Physics_ResizeDragHandler(m_fltUserDefinedDraggerRadius);
1131 }
1132 
1143 
1153 {return m_bIsSelected;}
1154 
1155 #pragma endregion
1156 
1157 void MovableItem::Selected(bool bValue, bool bSelectMultiple)
1158 {
1159  m_bIsSelected = bValue;
1160 
1162  m_lpPhysicsMovableItem->Physics_Selected(bValue, bSelectMultiple);
1163 
1164  if(m_lpCallback)
1165  m_lpCallback->SelectionChanged(bValue, bSelectMultiple);
1166 }
1167 
1181 {
1183  m_lpPhysicsMovableItem->SetAlpha();
1184 }
1204 void MovableItem::AddBodyClicked(float fltPosX, float fltPosY, float fltPosZ, float fltNormX, float fltNormY, float fltNormZ)
1205 {
1206  //Do nothing here in the base. This could be a strucutre, and we do not want to do anything for that class.
1207  //You need to implmenent this in the derived bodypart class.
1208 }
1209 
1223 void MovableItem::OrientNewPart(float fltXPos, float fltYPos, float fltZPos, float fltXNorm, float fltYNorm, float fltZNorm)
1224 {
1226  m_lpPhysicsMovableItem->Physics_OrientNewPart(fltXPos, fltYPos, fltZPos, fltXNorm, fltYNorm, fltZNorm);
1227 }
1228 
1241 bool MovableItem::CalculateLocalPosForWorldPos(float fltWorldX, float fltWorldY, float fltWorldZ, CStdFPoint &vLocalPos)
1242 {
1244  return m_lpPhysicsMovableItem->Physics_CalculateLocalPosForWorldPos(fltWorldX, fltWorldY, fltWorldZ, vLocalPos);
1245  return false;
1246 }
1247 
1248 #pragma region DataAccesMethods
1249 
1250 float *MovableItem::GetDataPointer(const std::string &strDataType)
1251 {
1252  std::string strType = Std_CheckString(strDataType);
1253 
1254  if(strType == "WORLDPOSITIONX")
1255  return &m_oReportWorldPosition.x;
1256 
1257  if(strType == "WORLDPOSITIONY")
1258  return &m_oReportWorldPosition.y;
1259 
1260  if(strType == "WORLDPOSITIONZ")
1261  return &m_oReportWorldPosition.z;
1262 
1263  if(strType == "POSITIONX")
1264  return &m_oReportPosition.x;
1265 
1266  if(strType == "POSITIONY")
1267  return &m_oReportPosition.y;
1268 
1269  if(strType == "POSITIONZ")
1270  return &m_oReportPosition.z;
1271 
1272  if(strType == "ROTATIONX")
1273  return &m_oReportRotation.x;
1274 
1275  if(strType == "ROTATIONY")
1276  return &m_oReportRotation.y;
1277 
1278  if(strType == "ROTATIONZ")
1279  return &m_oReportRotation.z;
1280 
1281  if(strType == "VISIBLE")
1282  return &m_fltReportIsVisible;
1283 
1284  return 0;
1285 }
1286 
1287 bool MovableItem::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
1288 {
1289  if(strDataType == "POSITION")
1290  {
1291  Position(strValue);
1292  return true;
1293  }
1294 
1295  if(strDataType == "POSITION.X")
1296  {
1297  Position(atof(strValue.c_str()), m_oReportPosition.y, m_oReportPosition.z);
1298  return true;
1299  }
1300 
1301  if(strDataType == "POSITION.Y")
1302  {
1303  Position(m_oReportPosition.x, atof(strValue.c_str()), m_oReportPosition.z);
1304  return true;
1305  }
1306 
1307  if(strDataType == "POSITION.Z")
1308  {
1309  Position(m_oReportPosition.x, m_oReportPosition.y, atof(strValue.c_str()));
1310  return true;
1311  }
1312 
1313  if(strDataType == "ROTATION")
1314  {
1315  Rotation(strValue);
1316  return true;
1317  }
1318 
1319  if(strDataType == "ROTATION.X")
1320  {
1321  Rotation(atof(strValue.c_str()), m_oReportRotation.y, m_oReportRotation.z);
1322  return true;
1323  }
1324 
1325  if(strDataType == "ROTATION.Y")
1326  {
1327  Rotation(m_oReportRotation.x, atof(strValue.c_str()), m_oReportRotation.z);
1328  return true;
1329  }
1330 
1331  if(strDataType == "ROTATION.Z")
1332  {
1333  Rotation(m_oReportRotation.x, m_oReportRotation.y, atof(strValue.c_str()));
1334  return true;
1335  }
1336 
1337  if(strDataType == "BOUNDINGBOX.X")
1338  {
1339  SetBoundingBox(0, atof(strValue.c_str()));
1340  return true;
1341  }
1342 
1343  if(strDataType == "BOUNDINGBOX.Y")
1344  {
1345  SetBoundingBox(1, atof(strValue.c_str()));
1346  return true;
1347  }
1348 
1349  if(strDataType == "BOUNDINGBOX.Z")
1350  {
1351  SetBoundingBox(2, atof(strValue.c_str()));
1352  return true;
1353  }
1354 
1355  if(strDataType == "VISIBLE")
1356  {
1357  IsVisible(Std_ToBool(strValue));
1358  return true;
1359  }
1360 
1361  if(strDataType == "GRAPHICSALPHA")
1362  {
1363  GraphicsAlpha((float) atof(strValue.c_str()));
1364  return true;
1365  }
1366 
1367  if(strDataType == "COLLISIONALPHA")
1368  {
1369  CollisionsAlpha((float) atof(strValue.c_str()));
1370  return true;
1371  }
1372 
1373  if(strDataType == "JOINTSALPHA")
1374  {
1375  JointsAlpha((float) atof(strValue.c_str()));
1376  return true;
1377  }
1378 
1379  if(strDataType == "RECEPTIVEFIELDSALPHA")
1380  {
1381  ReceptiveFieldsAlpha((float) atof(strValue.c_str()));
1382  return true;
1383  }
1384 
1385  if(strDataType == "SIMULATIONALPHA")
1386  {
1387  SimulationAlpha((float) atof(strValue.c_str()));
1388  return true;
1389  }
1390 
1391  if(strDataType == "AMBIENT")
1392  {
1393  Ambient(strValue);
1394  return true;
1395  }
1396 
1397  if(strDataType == "AMBIENT.RED")
1398  {
1399  float aryVal[4] = {(float) atof(strValue.c_str()), m_vAmbient.g(), m_vAmbient.b(), m_vAmbient.a()};
1400  Ambient(aryVal);
1401  return true;
1402  }
1403 
1404  if(strDataType == "AMBIENT.GREEN")
1405  {
1406  float aryVal[4] = {m_vAmbient.r(), (float) atof(strValue.c_str()), m_vAmbient.b(), m_vAmbient.a()};
1407  Ambient(aryVal);
1408  return true;
1409  }
1410 
1411  if(strDataType == "AMBIENT.BLUE")
1412  {
1413  float aryVal[4] = {m_vAmbient.r(), m_vAmbient.g(), (float) atof(strValue.c_str()), m_vAmbient.a()};
1414  Ambient(aryVal);
1415  return true;
1416  }
1417 
1418  if(strDataType == "AMBIENT.ALPHA")
1419  {
1420  float aryVal[4] = {m_vAmbient.r(), m_vAmbient.g(), m_vAmbient.b(), (float) atof(strValue.c_str())};
1421  Ambient(aryVal);
1422  return true;
1423  }
1424 
1425  if(strDataType == "DIFFUSE")
1426  {
1427  Diffuse(strValue);
1428  return true;
1429  }
1430 
1431  if(strDataType == "DIFFUSE.RED")
1432  {
1433  float aryVal[4] = {(float) atof(strValue.c_str()), m_vDiffuse.g(), m_vDiffuse.b(), m_vDiffuse.a()};
1434  Diffuse(aryVal);
1435  return true;
1436  }
1437 
1438  if(strDataType == "DIFFUSE.GREEN")
1439  {
1440  float aryVal[4] = {m_vDiffuse.r(), (float) atof(strValue.c_str()), m_vDiffuse.b(), m_vDiffuse.a()};
1441  Diffuse(aryVal);
1442  return true;
1443  }
1444 
1445  if(strDataType == "DIFFUSE.BLUE")
1446  {
1447  float aryVal[4] = {m_vDiffuse.r(), m_vDiffuse.g(), (float) atof(strValue.c_str()), m_vDiffuse.a()};
1448  Diffuse(aryVal);
1449  return true;
1450  }
1451 
1452  if(strDataType == "DIFFUSE.ALPHA")
1453  {
1454  float aryVal[4] = {m_vDiffuse.r(), m_vDiffuse.g(), m_vDiffuse.b(), (float) atof(strValue.c_str())};
1455  Diffuse(aryVal);
1456  return true;
1457  }
1458 
1459  if(strDataType == "SPECULAR")
1460  {
1461  Specular(strValue);
1462  return true;
1463  }
1464 
1465  if(strDataType == "SPECULAR.RED")
1466  {
1467  float aryVal[4] = {(float) atof(strValue.c_str()), m_vSpecular.g(), m_vSpecular.b(), m_vSpecular.a()};
1468  Specular(aryVal);
1469  return true;
1470  }
1471 
1472  if(strDataType == "SPECULAR.GREEN")
1473  {
1474  float aryVal[4] = {m_vSpecular.r(), (float) atof(strValue.c_str()), m_vSpecular.b(), m_vSpecular.a()};
1475  Specular(aryVal);
1476  return true;
1477  }
1478 
1479  if(strDataType == "SPECULAR.BLUE")
1480  {
1481  float aryVal[4] = {m_vSpecular.r(), m_vSpecular.g(), (float) atof(strValue.c_str()), m_vSpecular.a()};
1482  Specular(aryVal);
1483  return true;
1484  }
1485 
1486  if(strDataType == "SPECULAR.ALPHA")
1487  {
1488  float aryVal[4] = {m_vSpecular.r(), m_vSpecular.g(), m_vSpecular.b(), (float) atof(strValue.c_str())};
1489  Specular(aryVal);
1490  return true;
1491  }
1492 
1493  if(strDataType == "SHININESS")
1494  {
1495  Shininess((float) atof(strValue.c_str()));
1496  return true;
1497  }
1498 
1499  if(strDataType == "TEXTURE")
1500  {
1501  Texture(strValue);
1502  return true;
1503  }
1504 
1505  if(strDataType == "DRAGGERRADIUS")
1506  {
1507  UserDefinedDraggerRadius((float) atof(strValue.c_str()));
1508  return true;
1509  }
1510 
1511  //If it was not one of those above then we have a problem.
1512  if(bThrowError)
1513  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
1514 
1515  return false;
1516 }
1517 
1518 void MovableItem::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
1519 {
1520  aryProperties.Add(new TypeProperty("WorldPositionX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1521  aryProperties.Add(new TypeProperty("WorldPositionY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1522  aryProperties.Add(new TypeProperty("WorldPositionZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1523  aryProperties.Add(new TypeProperty("PositionX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1524  aryProperties.Add(new TypeProperty("PositionY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1525  aryProperties.Add(new TypeProperty("PositionZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1526  aryProperties.Add(new TypeProperty("RotationX", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1527  aryProperties.Add(new TypeProperty("RotationY", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1528  aryProperties.Add(new TypeProperty("RotationZ", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
1529 
1530  aryProperties.Add(new TypeProperty("Position", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1531  aryProperties.Add(new TypeProperty("Position.X", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1532  aryProperties.Add(new TypeProperty("Position.Y", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1533  aryProperties.Add(new TypeProperty("Position.Z", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1534  aryProperties.Add(new TypeProperty("Rotation", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1535  aryProperties.Add(new TypeProperty("Rotation.X", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1536  aryProperties.Add(new TypeProperty("Rotation.Y", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1537  aryProperties.Add(new TypeProperty("Rotation.Z", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1538  aryProperties.Add(new TypeProperty("BoundingBox.X", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1539  aryProperties.Add(new TypeProperty("BoundingBox.Y", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1540  aryProperties.Add(new TypeProperty("BoundingBox.Z", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1541  aryProperties.Add(new TypeProperty("Visible", AnimatPropertyType::Boolean, AnimatPropertyDirection::Both));
1542  aryProperties.Add(new TypeProperty("GraphicsAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1543  aryProperties.Add(new TypeProperty("CollisionAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1544  aryProperties.Add(new TypeProperty("JointsAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1545  aryProperties.Add(new TypeProperty("ReceptiveFieldsAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1546  aryProperties.Add(new TypeProperty("SimulationAlpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1547  aryProperties.Add(new TypeProperty("Ambient", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1548  aryProperties.Add(new TypeProperty("Ambient.Red", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1549  aryProperties.Add(new TypeProperty("Ambient.Green", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1550  aryProperties.Add(new TypeProperty("Ambient.Blue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1551  aryProperties.Add(new TypeProperty("Ambient.Alpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1552  aryProperties.Add(new TypeProperty("Diffuse", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1553  aryProperties.Add(new TypeProperty("Diffuse.Red", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1554  aryProperties.Add(new TypeProperty("Diffuse.Green", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1555  aryProperties.Add(new TypeProperty("Diffuse.Blue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1556  aryProperties.Add(new TypeProperty("Diffuse.Alpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1557  aryProperties.Add(new TypeProperty("Specular", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
1558  aryProperties.Add(new TypeProperty("Specular.Red", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1559  aryProperties.Add(new TypeProperty("Specular.Green", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1560  aryProperties.Add(new TypeProperty("Specular.Blue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1561  aryProperties.Add(new TypeProperty("Specular.Alpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1562  aryProperties.Add(new TypeProperty("Shininess", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1563  aryProperties.Add(new TypeProperty("Texture", AnimatPropertyType::String, AnimatPropertyDirection::Set));
1564  aryProperties.Add(new TypeProperty("DraggerRadius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
1565 }
1566 
1567 #pragma endregion
1568 
1581 {
1582  CStdFPoint vTemp;
1583 
1584  Std_LoadPoint(oXml, "Position", vTemp);
1585  Position(vTemp, true, false, false);
1586 }
1587 
1599 {
1600  CStdFPoint vTemp;
1601  Std_LoadPoint(oXml, "Rotation", vTemp);
1602  Rotation(vTemp, false, false);
1603 }
1604 
1605 void MovableItem::Load(CStdXml &oXml)
1606 {
1607  oXml.IntoElem(); //Into Element
1608 
1609  LoadPosition(oXml);
1610  LoadRotation(oXml);
1611 
1612  IsVisible(oXml.GetChildBool("IsVisible", m_bIsVisible));
1613  GraphicsAlpha(oXml.GetChildFloat("GraphicsAlpha", m_fltGraphicsAlpha));
1614  CollisionsAlpha(oXml.GetChildFloat("CollisionsAlpha", m_fltCollisionsAlpha));
1615  JointsAlpha(oXml.GetChildFloat("JointsAlpha", m_fltJointsAlpha));
1616  ReceptiveFieldsAlpha(oXml.GetChildFloat("ReceptiveFieldsAlpha", m_fltReceptiveFieldsAlpha));
1617  SimulationAlpha(oXml.GetChildFloat("SimulationAlpha", m_fltSimulationAlpha));
1618 
1619  m_vDiffuse.Load(oXml, "Diffuse", false);
1620  m_vAmbient.Load(oXml, "Ambient", false);
1621  m_vSpecular.Load(oXml, "Specular", false);
1622  m_fltShininess = oXml.GetChildFloat("Shininess", m_fltShininess);
1623 
1624  m_strTexture = oXml.GetChildString("Texture", "");
1625 
1627 
1628  oXml.OutOfElem(); //OutOf Element
1629 }
1630 
1631  } //Environment
1632 } //AnimatSim
Movable Item callback to the GUI.
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
Definition: StdXml.cpp:162
Base class file for all Animat simulation objects.
Standard color class.
Definition: StdColor.h:22
Declares the simulation recorder class.
virtual bool IsSelected()
Query if this object is selected.
virtual float Alpha()
Gets the current alpha.
virtual CStdFPoint ReportWorldPosition()
Gets the reported world position. (m_oReportWorldPosition)
float m_fltSimulationAlpha
The alpha transparency used in the Simulation VisualSelectionMode.
Definition: MovableItem.h:73
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 LoadRotation(CStdXml &oXml)
Loads the items rotation.
Root namespace for the base simulation library for AnimatLab.
void Set(float R, float G, float B, float A)
Sets the color values.
Definition: StdColor.cpp:153
CStdFPoint m_oReportWorldPosition
This is used for reporting the position back to the GUI. It is the world position scaled for distance...
Definition: MovableItem.h:42
float m_fltReceptiveFieldsAlpha
The alpha transparency used in the Receptive Fields VisualSelectionMode.
Definition: MovableItem.h:70
Declares the body part class.
CStdColor m_vAmbient
The ambient color to apply to this part. It is specified as red, green, blue, and alpha...
Definition: MovableItem.h:79
void Load(CStdXml &oXml, std::string strParamName, bool bThrowError=true)
Loads the color.
Definition: StdColor.cpp:540
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
Definition: StdXml.cpp:179
float m_fltJointsAlpha
The alpha transparency used in the Joints VisualSelectionMode.
Definition: MovableItem.h:67
virtual CStdFPoint SelectedVertex()
Gets the relative position of the selected vertex. (m_vSelectedVertex)
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
virtual void LoadPosition(CStdXml &oXml)
Loads the items position.
virtual bool CalculateLocalPosForWorldPos(float fltWorldX, float fltWorldY, float fltWorldZ, CStdFPoint &vLocalPos)
Calculates the local position values for matrix transform for the part to be in a specific world posi...
virtual float Shininess()
Gets the shininess.
virtual bool AllowTranslateDragY()
Gets whether this body part can be translated along the y-axis by the user with the drag handlers...
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
IMovableItemCallback * m_lpCallback
Definition: MovableItem.h:98
virtual void DistanceUnits(std::string strUnits)
Sets the distance units.
Definition: Simulator.cpp:1717
Declares the key frame class.
virtual CStdColor * Ambient()
Gets the ambient color value.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
Declares the joint class.
virtual CStdFPoint ReportPosition()
Gets the reported local position. (m_oReportPosition).
Declares the organism class.
virtual void PositionChanged()=0
Called to signal to the GUI that the position of the body part changed.
virtual std::string Texture()
Gets the texture filename.
Declares a light object.
virtual bool AllowTranslateDragX()
Gets whether this body part can be translated along the x-axis by the user with the drag handlers...
Declares the activated item class.
virtual float UserDefinedDraggerRadius()
Gets the user defined dragger radius.
virtual CStdColor * Specular()
Gets the specular color.
Declares a light manager object.
virtual bool AllowRotateDragX()
Gets whether this body part can be rotated along the x-axis by the user with the drag handlers...
virtual float GetBoundingRadius()
Gets the bounding radius of this part.
IPhysicsMovableItem * m_lpPhysicsMovableItem
Definition: MovableItem.h:103
virtual bool IsVisible()
Query if this object is visible.
virtual BoundingBox GetBoundingBox()
Gets the bounding box for this part.
Declares the bounding box class.
float m_fltShininess
The shininess of the part. A value between 0 and 128.
Definition: MovableItem.h:88
virtual IMovableItemCallback * Callback()
Gets the callback interface pointer. This is an interface pointer to a callback class that allows us ...
virtual CStdFPoint GetCurrentPosition()
Gets the current position of this part.
A standard xml manipulation class.
Definition: StdXml.h:19
virtual bool AllowRotateDragY()
Gets whether this body part can be rotated along the y-axis by the user with the drag handlers...
virtual CStdFPoint AbsolutePosition()
Gets the absolute position of this body part.
virtual CStdFPoint Rotation()
Gets the rotation of this body in radians.
Declares the node class.
Bounding box class for geometric objects.
Definition: BoundingBox.h:17
virtual void SelectionChanged(bool bSelected, bool bSelectMultiple)=0
Called to signal to the GUI that the selected body part changed.
virtual IPhysicsMovableItem * PhysicsMovableItem()
Gets the physics body interface pointer. This is an interface reference to the Vs version of this obj...
void r(float fltR, bool bThrowError=true)
Sets the red value of the color.
Definition: StdColor.cpp:51
virtual CStdFPoint ReportRotation()
Gets the reported rotation of this part. (m_oReportRotation)
virtual float ReceptiveFieldsAlpha()
Gets the receptive fields alpha.
CStdColor m_vDiffuse
The diffuse color to apply to this part. It is specified as red, green, blue, and alpha...
Definition: MovableItem.h:82
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
Definition: StdXml.cpp:307
virtual void OrientNewPart(float fltXPos, float fltYPos, float fltZPos, float fltXNorm, float fltYNorm, float fltZNorm)
Orients a new part based on where the parent was clicked and the normal of the surface face...
float m_fltUserDefinedDraggerRadius
User defined drag handle radius. If this is -1 then the user has not set the value and the default is...
Definition: MovableItem.h:106
float m_fltGraphicsAlpha
The alpha transparency used in the Graphics VisualSelectionMode.
Definition: MovableItem.h:61
RigidBody * Parent()
Gets the parent RigidBody of this part.
Definition: MovableItem.cpp:90
bool Std_ToBool(int iVal)
Converts a value toa bool.
MovableItem(void)
Default constructor.
Definition: MovableItem.cpp:46
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)
CStdColor m_vSpecular
The specular color to apply to this part. It is specified as red, green, blue, and alpha...
Definition: MovableItem.h:85
virtual ~MovableItem(void)
Destructor.
Definition: MovableItem.cpp:76
bool m_bIsSelected
Keeps track of whether this movable item has been selected or not.
Definition: MovableItem.h:109
float m_fltCollisionsAlpha
The alpha transparency used in the Collisions VisualSelectionMode.
Definition: MovableItem.h:64
virtual bool AllowRotateDragZ()
Gets whether this body part can be rotated along the z-axis by the user with the drag handlers...
virtual void AddBodyClicked(float fltPosX, float fltPosY, float fltPosZ, float fltNormX, float fltNormY, float fltNormZ)
Called when the user clicks on this object while the AddBody mode is active.
CStdFPoint m_oPosition
These are rotation and position coords relative to the parent if this is a body part.
Definition: MovableItem.h:36
virtual void VisualSelectionModeChanged(int iNewMode)
Called when the visual selection mode changed in GUI.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
float m_fltAlpha
The current alpha transparency for this body part.
Definition: MovableItem.h:76
virtual CStdColor * Diffuse()
Gets the diffuse color.
Declares the data chart manager class.
Declares the rigid body class.
virtual void SelectedVertexChanged(float fltPosX, float fltPosY, float fltPosZ)=0
Called to signal when the selected vertex has changed.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual float JointsAlpha()
Gets the joints alpha.
bool Std_LoadPoint(CStdXml &oXml, std::string strName, CStdIPoint &oPoint, bool bThrowError)
Standard load point.
virtual float SimulationAlpha()
Gets the simulation alpha.
virtual float GraphicsAlpha()
Gets the graphics alpha.
Declares the structure class.
virtual void RotationChanged()=0
Called to signal to the GUI that the rotation of the body part changed.
virtual int VisualSelectionType()
Gets the visual selection type for this part.
Declares the odor type class.
virtual std::string LocalTransformationMatrixString()
Returns a string representation of the transformation matrix of this object. This is primarily used t...
virtual void SetBoundingBox(int iIdx, float fltVal)
Sets one dimension of the bounding box. This does nothing for all parts except a mesh.
virtual float InverseDistanceUnits()
Gets the inverse distance units.
Definition: Simulator.cpp:1742
void g(float fltG, bool bThrowError=true)
Sets the green value of the color.
Definition: StdColor.cpp:76
Declares the odor class.
Declares the simulator class.
CStdFPoint m_vSelectedVertex
The relative position of the selected vertex.
Definition: MovableItem.h:94
CStdFPoint m_oReportPosition
This is used for reporting the position back to the GUI. It is the position scaled for distance units...
Definition: MovableItem.h:39
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
void a(float fltA, bool bThrowError=true)
Sets the alpha value of the color.
Definition: StdColor.cpp:126
The base class for all of the basic rigid body type of objects.
Definition: RigidBody.h:66
Declares the receptive field class.
std::string m_strTexture
An optional texture to apply to the rigid body.
Definition: MovableItem.h:91
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
Definition: StdXml.cpp:617
virtual bool AllowTranslateDragZ()
Gets whether this body part can be translated along the z-axis by the user with the drag handlers...
virtual float CollisionsAlpha()
Gets the collisions alpha.
virtual bool AllowMouseManipulation()
Tells if a given part can be manipulated using the mouse and draggers.
void b(float fltB, bool bThrowError=true)
Sets the blue value of the color.
Definition: StdColor.cpp:101