AnimatLab  2
Test
Simulator.h
Go to the documentation of this file.
1 
7 #pragma once
8 using namespace StdUtils;
9 
10 #include "MaterialType.h"
11 #include "Materials.h"
12 #include "SimulationWindow.h"
13 #include "HudItem.h"
14 #include "Hud.h"
15 #include "SimulationWindowMgr.h"
16 #include "ThreadProcessor.h"
17 #include "ModuleThreadProcessor.h"
18 #include "ScriptProcessor.h"
19 
20 namespace AnimatSim
21 {
31  class ANIMAT_PORT Simulator : public AnimatBase
32  {
33  protected:
34 
35 #pragma region Variables
36 
37 #pragma region ProjectVariables
38 
40  std::string m_strProjectPath;
41 
43  std::string m_strExecutablePath;
44 
46  std::string m_strSimulationFile;
47 
50  CStdPtrMap<std::string, Organism> m_aryOrganisms;
51 
55  CStdPtrMap<std::string, Structure> m_aryStructures;
56 
59  CStdMap<std::string, Structure *> m_aryAllStructures;
60 
63  CStdPtrMap<std::string, OdorType> m_aryOdorTypes;
64 
66  CStdArray<RigidBody *> m_aryFoodSources;
67 
71  CStdMap<std::string, IStdClassFactory *> m_aryNeuralModuleFactories;
72 
79 
81  CStdMap<std::string, AnimatBase *> m_aryObjectList;
82 
84  CStdArray<Adapter *> m_arySourcePhysicsAdapters;
85 
87  CStdArray<Adapter *> m_aryTargetPhysicsAdapters;
88 
91  CStdArray<BodyPart *> m_aryExtraDataParts;
92 
95 
98 
100  DataChartMgr m_oDataChartMgr;
101 
103  ExternalStimuliMgr m_oExternalStimuliMgr;
104 
106  SimulationRecorder *m_lpSimRecorder;
107 
109  Materials m_oMaterialMgr;
110 
113 
115  LightManager m_oLightMgr;
116 
119 
122 
125 
128 
132 
135 
138 
141 
143  bool m_bPaused;
144 
147 
150 
153 
156 
159 
161  bool m_bInDrag;
162 
165 
168 
171 
174 
175  //Script processor for running python or other scripting systems related to the simulation.
176  ScriptProcessor *m_lpScript;
177 
178 #pragma endregion
179 
180 #pragma region UnitScalingVariables
181 
184 
187 
192 
195 
198 
201 
202 #pragma endregion
203 
204 #pragma region EnvironmentVariables
205 
208 
211 
214 
217 
220 
223 
226 
229 
235 
238  double m_dblTimeStep;
239 
245 
249 
252 
254  float m_fltTime;
255  double m_dblTime;
256 
259 
262 
265 
267  unsigned long long m_lStartSimTick;
268 
271 
276 
279 
284 
288 
292 
295 
298 
301 
304 
307 
310 
313 
318 
322 
326 
327 #pragma endregion
328 
329 #pragma region TimingVariables
330 
333 
337 
339  unsigned long long m_lStepStartTick;
340 
342  unsigned long long m_lStepSimEndTick;
343 
347 
350 
353 
356 
359 
364 
367 
370 
372  unsigned long long m_lVideoFrameStartTick;
373 
376 
378  unsigned long long m_lLastTickTaken;
379 
382 
387 
390 
393 
396 
399 
403 
406 
409 
412 
415 
418 
421 
424 
425 #pragma endregion
426 
427 #pragma region RecordingVariables
428 
431 
434 
437 
440 
442  KeyFrame *m_lpVideoRecorder;
443 
445  KeyFrame *m_lpVideoPlayback;
446 
448  KeyFrame *m_lpSimStopPoint;
449 
450  //Video variables
453 
455  std::string m_strVideoFilename;
456 
459 
462 
465 
468 
471 
474 
477 
480 
483 
484 #pragma endregion
485 
486 #pragma region TempVariables
487  //These variables are just used on and off. They are defined here so we do not have to keep redefining them.
488 
490  CStdMap<std::string, Organism *>::iterator m_oOrganismIterator;
491 
493  CStdMap<std::string, Structure *>::iterator m_oStructureIterator;
494 
496  Organism *m_lpSelOrganism;
497 
499  Structure *m_lpSelStructure;
500 
501 #pragma endregion
502 
503 #pragma endregion
504 
505 #pragma region ProtectedMethods
506 
507 #pragma region LoadMethods
508 
509  virtual void LoadEnvironment(CStdXml &oXml);
510  Structure *LoadStructure(CStdXml &oXml);
511  Organism *LoadOrganism(CStdXml &oXml);
512  OdorType *LoadOdorType(CStdXml &oXml);
513 
514  static void LoadAnimatModuleName(std::string strFile, std::string &strAnimatModule);
515  static void LoadAnimatModuleName(CStdXml &oXml, std::string &strAnimatModule);
516 
517  virtual ScriptProcessor *LoadScript(CStdXml &oXml);
518 
519 #pragma endregion
520 
521 #pragma region AddRemoveMethods
522 
542  virtual void AddOrganism(Organism *lpOrganism);
543  virtual void AddOrganism(std::string strXml);
544  virtual void RemoveOrganism(std::string strID, bool bThrowError = true);
545 
554  virtual void AddStructure(Structure *lpStructure);
555  virtual void AddStructure(std::string strXml);
556  virtual void RemoveStructure(std::string strID, bool bThrowError = true);
557 
558  virtual int FindAdapterListIndex(CStdArray<Adapter *> aryAdapters, std::string strID, bool bThrowError = true);
559  virtual int FindFoodSourceIndex(RigidBody *lpFood);
560  virtual int FindExtraDataIndex(BodyPart *lpPart);
561 
562  virtual void AddOdorType(OdorType *lpOdorType);
563  virtual void AddOdorType(std::string strXml, bool bDoNotInit);
564  virtual void RemoveOdorType(std::string strID, bool bThrowError = true);
565 
566  virtual void AddScript(std::string strXml);
567  virtual void RemoveScript(std::string strID, bool bThrowError = true);
568 
569 #pragma endregion
570 
571 #pragma region UnitScaleMethods
572 
573  float ConvertDistanceUnits(std::string strUnits);
574  float ConvertDenominatorDistanceUnits(std::string strUnits);
575  float ConvertMassUnits(std::string strUnits);
576  float ConvertDisplayMassUnits(std::string strUnits);
577 
578 #pragma endregion
579 
580 #pragma region SimulationMethods
581 
582  virtual void InitializeRandomNumbers();
583  virtual void InitializeStructures();
584 
585  virtual void NotifyTimeStepModified();
586 
587  virtual bool CheckSimulationBlock();
588  virtual void CheckEndSimulationTime();
589 
590  virtual void StepNeuralEngine();
591  virtual void StepPhysicsEngine();
592  virtual void StepExternalStimuli();
593  virtual void StepDataCharts();
594  virtual void StepSimRecorder();
595  virtual void AfterStepSimulation();
596  virtual void Step();
597  virtual void ResetSimulationTimingParams();
598 
599  virtual void ProcessSimulationStep();
600  virtual void StepSimulation();
601  virtual void StepVideoFrame();
602  virtual void StepPlaybackControl();
603  virtual void SimulateBegin();
604  virtual void SimulateEnd();
605 
606  //These functions are called internally when the simulation is about to start up or pause.
607  virtual void SimStarting();
608  virtual void SimPausing();
609  virtual void SimStopping();
610 
611  virtual void GenerateAutoSeed();
612 
613  virtual void HandleCriticalError(std::string strError);
614  virtual void HandleNonCriticalError(std::string strError);
615 
616  virtual void UpdateSimulationWindows() = 0;
617 
618  //Timing Methods
619  virtual void StartSimulationStepTimer();
620  virtual void RecordSimulationStepTimer();
621  virtual void RecordSimulationTotalStepTimer();
622  virtual double CurrentRealTimeForStep_n();
623  virtual double CurrentRealTimeForStep_s();
624  virtual double CalculateRemainingPlaybackTime();
625  virtual void RecordAddedPlaybackTime();
626  virtual void StartVideoFrameTimer();
627  virtual double TimeBetweenVideoFrames();
628  virtual double RemainingVideoFrameTime();
629 
630 #pragma endregion
631 
632 #pragma region RecorderMethods
633 
642  virtual SimulationRecorder *CreateSimulationRecorder() = 0;
643 
644  virtual long CalculateSnapshotByteSize();
645 
652  virtual void SnapshotStopFrame() = 0;
653 
654  virtual void RecordVideoFrame();
655 
656 #pragma endregion
657 
658 #pragma endregion
659 
660  public:
661  Simulator();
662  virtual ~Simulator();
663 
664  static Simulator *CastToDerived(AnimatBase *lpBase) {return static_cast<Simulator*>(lpBase);}
665 
666 #pragma region AccessorMutators
667 
668 #pragma region ProjectVariables
669 
670  virtual std::string ProjectPath();
671  virtual void ProjectPath(std::string strPath);
672 
673  virtual std::string ExecutablePath();
674  virtual void ExecutablePath(std::string strPath);
675 
676  virtual std::string SimulationFile();
677  virtual void SimulationFile(std::string strFile);
678 
679  virtual bool Paused();
680  virtual void Paused(bool bVal);
681 
682  virtual bool Initialized();
683  virtual void Initialized(bool bVal);
684 
685  virtual CStdMap<std::string, AnimatBase *> *ObjectList();
686 
687  virtual DataChartMgr *GetDataChartMgr();
688  virtual ExternalStimuliMgr *GetExternalStimuliMgr();
689  virtual SimulationRecorder *GetSimulationRecorder();
690  virtual Materials *GetMaterialMgr();
691  virtual SimulationWindowMgr *GetWindowMgr();
692  virtual LightManager *GetLightMgr();
693 
694  virtual int VisualSelectionMode();
695  virtual void VisualSelectionMode(int iVal);
696 
697  virtual bool AddBodiesMode();
698  virtual void AddBodiesMode(bool bVal);
699 
700  virtual ISimGUICallback *SimCallback();
701  virtual void SimCallBack(ISimGUICallback *lpCallback);
702 
703  virtual bool IsResetting();
704 
705 #pragma endregion
706 
707 #pragma region EnvironmentVariables
708 
709  virtual float Time();
710  virtual long Millisecond();
711  virtual long MillisecondToSlice(long lMillisecond);
712  virtual long SliceToMillisecond(long lSlice);
713  virtual unsigned long long StartSimTick();
714 
715  virtual float MinTimeStep();
716  virtual float TimeStep();
717 
718  virtual bool SetEndSimTime();
719  virtual void SetEndSimTime(bool bVal);
720 
721  virtual float EndSimTime();
722  virtual void EndSimTime(float fltVal);
723 
724  virtual long EndSimTimeSlice();
725  virtual void EndSimTimeSlice(long lVal);
726 
727  virtual long TimeSlice();
728  virtual void TimeSlice(long lVal);
729 
730  virtual long PhysicsSliceCount();
731  virtual void PhysicsSliceCount(long lVal);
732 
733  virtual bool ManualStepSimulation();
734  virtual void ManualStepSimulation(bool bVal);
735 
736  virtual bool SimRunning();
737 
738  virtual bool ShuttingDown();
739 
740  virtual bool ForceFastMoving();
741  virtual void ForceFastMoving(bool bVal);
742 
743  virtual bool AutoGenerateRandomSeed();
744  virtual void AutoGenerateRandomSeed(bool bVal);
745 
746  virtual int ManualRandomSeed();
747  virtual void ManualRandomSeed(int iSeed);
748 
749  virtual float StabilityScale();
750  virtual void StabilityScale(float fltVal);
751 
752  virtual float LinearCompliance();
753  virtual void LinearCompliance(float fltVal, bool bUseScaling = true);
754 
755  virtual float AngularCompliance();
756  virtual void AngularCompliance(float fltVal, bool bUseScaling = true);
757 
758  virtual float LinearDamping();
759  virtual void LinearDamping(float fltVal, bool bUseScaling = true);
760 
761  virtual float AngularDamping();
762  virtual void AngularDamping(float fltVal, bool bUseScaling = true);
763 
764  virtual float LinearKineticLoss();
765  virtual void LinearKineticLoss(float fltVal, bool bUseScaling = true);
766 
767  virtual float AngularKineticLoss();
768  virtual void AngularKineticLoss(float fltVal, bool bUseScaling = true);
769 
770  virtual bool Stopped();
771 
772  virtual short PhysicsStepInterval();
773  virtual void PhysicsStepInterval(short iVal);
774 
775  virtual void PhysicsTimeStep(float fltVal);
776  virtual float PhysicsTimeStep();
777  virtual long PhysicsStepCount();
778 
779  virtual void PhysicsSubsteps(int iVal);
780  virtual int PhysicsSubsteps();
781  virtual float PhysicsSubstepTime();
782 
783  virtual float Gravity();
784  virtual void Gravity(float fltVal, bool bUseScaling = true);
785 
786  virtual float MouseSpringStiffness();
787  virtual void MouseSpringStiffness(float fltVal, bool bUseScaling = true);
788 
789  virtual float MouseSpringDamping();
790  virtual void MouseSpringDamping(float fltVal, bool bUseScaling = true);
791 
792  virtual float MouseSpringForceMagnitude();
793  virtual void MouseSpringForceMagnitude(float fltVal, bool bUseScaling = true);
794 
795  virtual float MouseSpringDampingForceMagnitude();
796  virtual void MouseSpringDampingForceMagnitude(float fltVal, bool bUseScaling = true);
797 
798  virtual float MouseSpringLengthMagnitude();
799  virtual void MouseSpringLengthMagnitude(float fltVal, bool bUseScaling = true);
800 
801  virtual bool SimulateHydrodynamics();
802  virtual void SimulateHydrodynamics(bool bVal);
803 
804  virtual int GetMaterialID(std::string strID);
805 
806  virtual bool IsPhysicsBeingUpdated();
807 
808  virtual CStdColor *BackgroundColor();
809  virtual void BackgroundColor(CStdColor &aryColor);
810  virtual void BackgroundColor(float *aryColor);
811  virtual void BackgroundColor(std::string strXml);
812 
813  virtual float AlphaThreshold();
814  virtual void AlphaThreshold(float fltValue);
815 
816  virtual float RecFieldSelRadius();
817  virtual void RecFieldSelRadius(float fltValue, bool bUseScaling = true, bool bUpdateAllBodies = true);
818 
819  virtual int PlaybackControlMode();
820  virtual void PlaybackControlMode(int iMode);
821 
822  virtual float PresetPlaybackTimeStep();
823  virtual void PresetPlaybackTimeStep(float fltTimeStep);
824 
825  virtual unsigned long long StepStartTick();
826  virtual unsigned long long StepSimEndTick();
827 
828  virtual int DesiredFrameRate();
829  virtual float DesiredFrameStep();
830  virtual void DesiredFrameRate(int iVal);
831 
832  virtual float RealTime();
833 
834  virtual bool InDrag() {return m_bInDrag;};
835  virtual void InDrag(bool bVal) {m_bInDrag = bVal;};
836 
837  virtual bool RobotAdpaterSynch();
838  virtual void RobotAdpaterSynch(bool bVal);
839 
840  virtual bool InSimulation();
841 
842  virtual bool ForceNoWindows();
843  virtual void ForceNoWindows(bool bVal);
844 
845  virtual void Script(ScriptProcessor *lpScript);
846  virtual ScriptProcessor *Script();
847 
848 #pragma endregion
849 
850 #pragma region UnitScalingVariables
851 
852  virtual void DistanceUnits(std::string strUnits);
853  virtual float DistanceUnits();
854  virtual float InverseDistanceUnits();
855  virtual float DenominatorDistanceUnits();
856 
857  virtual void MassUnits(std::string strUnits);
858  virtual float MassUnits();
859  virtual float InverseMassUnits();
860  virtual float DisplayMassUnits();
861 
862 #pragma endregion
863 
864 #pragma region HelperMethods
865 
866  virtual void GetPositionAndRotationFromD3DMatrix(float (&aryTransform)[4][4], CStdFPoint &vPos, CStdFPoint &vRot) = 0;
867 
868  //Timer Methods
869  virtual unsigned long long GetTimerTick() = 0;
870  virtual double TimerDiff_u(unsigned long long lStart, unsigned long long lEnd) = 0;
871  virtual double TimerDiff_m(unsigned long long lStart, unsigned long long lEnd) = 0;
872  virtual double TimerDiff_s(unsigned long long lStart, unsigned long long lEnd) = 0;
873  virtual void MicroSleep(unsigned int iMicroTime) = 0;
874  virtual void MicroWait(unsigned int iMicroTime);
875 
876  virtual void WriteToConsole(std::string strMessage) = 0;
877 
878  virtual void NotifyRigidBodyAdded(std::string strID);
879  virtual void NotifyRigidBodyRemoved(std::string strID);
880 
881 #pragma endregion
882 
883 #pragma region RecordingVariables
884 
885  virtual long VideoSliceCount();
886  virtual void VideoSliceCount(long lVal);
887 
888  virtual int VideoLoops();
889  virtual void VideoLoops(int iVal);
890 
899  virtual KeyFrame *VideoRecorder();
900 
909  virtual void VideoRecorder(KeyFrame *lpFrame);
910 
919  virtual KeyFrame *VideoPlayback();
920 
929  virtual void VideoPlayback(KeyFrame *lpFrame);
930 
931  virtual bool EnableSimRecording();
932  virtual void EnableSimRecording(bool bVal);
933 
934  virtual long SnapshotByteSize();
935 
936 #pragma endregion
937 
938 #pragma endregion
939 
940 #pragma region PublicMethods
941 
942 #pragma region SimulationMethods
943 
944  virtual void BlockSimulation();
945  virtual void UnblockSimulation();
946  virtual bool SimulationBlockConfirm();
947  virtual bool WaitForSimulationBlock(long lTimeout = 6000);
948 
949  virtual void Reset(); //Resets the entire application back to the default state
950  virtual void ResetSimulation(); //Resets the current simulation back to time 0.0
951 
966  virtual void Initialize(int argc, const char **argv) = 0;
967 
968 
977  virtual void Initialize();
978 
988  virtual void Simulate();
989 
996  virtual void ShutdownSimulation() = 0;
997 
1004  virtual void ToggleSimulation() = 0;
1005 
1012  virtual void StopSimulation() = 0;
1013 
1022  virtual bool StartSimulation() = 0;
1023 
1032  virtual bool PauseSimulation() = 0;
1033 
1043  virtual void RunSimulation();
1044 
1045 #pragma endregion
1046 
1047 #pragma region LoadMethods
1048 
1049  virtual void Load(std::string strFileName = "");
1050  virtual void Load(CStdXml &oXml);
1051  virtual void Save(std::string strFilename);
1052 
1053  static IStdClassFactory *LoadClassFactory(std::string strModuleName, bool bThrowError = true);
1054 
1055  virtual void IncrementPhysicsBodyCount();
1056 
1057 #pragma endregion
1058 
1059 #pragma region CreateMethods
1060 
1061  virtual CStdSerialize *CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError = true);
1062  static Simulator *CreateSimulator(std::string strAnimatModule, std::string strSimulationFile, bool bForceNoWindows = false);
1063  static Simulator *CreateSimulator(std::string strSimFile, bool bForceNoWindows = false);
1064  static Simulator *CreateAndInitializeSimulator(std::string strSimFile, bool bForceNoWindows = false);
1065  static Simulator *CreateSimulator(std::string strAnimatModule, CStdXml &oXml);
1066  static Simulator *CreateSimulator(std::string strAnimatModule, std::string strProjectPath, std::string strExecutablePath);
1067  static Simulator *CreateSimulator(int argc, const char **argv);
1068  virtual void GenerateCollisionMeshFile(std::string strOriginalMeshFile, std::string strCollisionMeshFile, float fltScaleX, float fltScaleY, float fltScaleZ) = 0;
1069  virtual void ConvertV1MeshFile(std::string strOriginalMeshFile, std::string strNewMeshFile, std::string strTexture) = 0;
1070 
1071 #pragma endregion
1072 
1073 
1074 #pragma region FindMethods
1075 
1076  virtual IStdClassFactory *FindNeuralModuleFactory(std::string strModuleName, bool bThrowError = false);
1077  virtual Organism *FindOrganism(std::string strOrganismID, bool bThrowError = true);
1078  virtual Structure *FindStructure(std::string strStructureID, bool bThrowError = true);
1079  virtual Structure *FindStructureFromAll(std::string strStructureID, bool bThrowError = true);
1080  virtual Joint *FindJoint(std::string strStructureID, std::string strJointID, bool bThrowError = true);
1081  virtual RigidBody *FindRigidBody(std::string strStructureID, std::string strBodyID, bool bThrowError = true);
1082  virtual OdorType *FindOdorType(std::string strOdorID, bool bThrowError = true);
1083  virtual void FindClosestFoodSources(CStdFPoint &oMouthPos, float fltMinRadius, CStdArray<RigidBody *> &arySources, CStdArray<float> &aryDistances);
1084  virtual AnimatBase *FindByID(std::string strID, bool bThrowError = true);
1085 
1086 #pragma endregion
1087 
1088 #pragma region AddRemoveMethods
1089 
1090  virtual void AddToObjectList(AnimatBase *lpItem);
1091  virtual void RemoveFromObjectList(AnimatBase *lpItem);
1092  virtual void AddNeuralModuleFactory(std::string strModuleName, NeuralModule *lpModule);
1093 
1094  virtual void AddFoodSource(RigidBody *lpFood);
1095  virtual void RemoveFoodSource(RigidBody *lpFood);
1096 
1097  virtual void AttachSourceAdapter(Structure *lpStructure, Adapter *lpAdapter);
1098  virtual void RemoveSourceAdapter(Structure *lpStructure, Adapter *lpAdapter);
1099  virtual void AttachTargetAdapter(Structure *lpStructure, Adapter *lpAdapter);
1100  virtual void RemoveTargetAdapter(Structure *lpStructure, Adapter *lpAdapter);
1101  virtual bool IsPhysicsAdapter(Adapter *lpAdapter);
1102 
1103  virtual void AddToExtractExtraData(BodyPart *lpPart);
1104  virtual void RemoveFromExtractExtraData(BodyPart *lpPart);
1105 
1106 #pragma endregion
1107 
1108 #pragma region DataAccesMethods
1109 
1110  virtual float *GetDataPointer(const std::string &strDataType);
1111  virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError = true);
1112  virtual void QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
1113  virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError = true, bool bDoNotInit = false);
1114  virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError = true);
1115 
1116 #pragma endregion
1117 
1118 #pragma region RecorderMethods
1119 
1120  virtual void EnableVideoPlayback(std::string strKeyFrameID);
1121  virtual void DisableVideoPlayback();
1122  virtual void StartVideoPlayback();
1123  virtual void StopVideoPlayback();
1124  virtual void StepVideoPlayback(int iFrameCount = 1);
1125  virtual void SaveVideo(std::string strPath);
1126 
1127  virtual std::string AddKeyFrame(std::string strType, long lStart, long lEnd);
1128  virtual void RemoveKeyFrame(std::string strID);
1129  virtual std::string MoveKeyFrame(std::string strID, long lStart, long lEnd);
1130  virtual void MoveSimulationToKeyFrame(std::string strKeyFrameID);
1131  virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex);
1132  virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex);
1133 
1134 #pragma endregion
1135 
1136 #pragma region CollisionMethods
1137 
1138  virtual void EnableCollisions(Structure *lpStruct, CStdPtrArray<CollisionPair> &m_aryCollisionList);
1139  virtual void DisableCollisions(Structure *lpStruct, CStdPtrArray<CollisionPair> &m_aryCollisionList);
1140 
1152  virtual void EnableCollision(RigidBody *lpBody);
1153 
1165  virtual void DisableCollision(RigidBody *lpBody);
1166 
1167 #pragma endregion
1168 
1169 #pragma endregion
1170 
1171  };
1172 
1173  Simulator ANIMAT_PORT *GetSimulator();
1174 
1175 } //AnimatSim
long m_lVideoFrame
The video frame.
Definition: Simulator.h:482
float m_fltPrevTotalRealTimeForStep
Previous total time for the step. Used for exponential smoothing algorithm.
Definition: Simulator.h:352
CStdPtrMap< std::string, Organism > m_aryOrganisms
Definition: Simulator.h:50
float m_fltMouseSpringForceMagnitude
The magnitude of the force being applied by the mosue spring at each step.
Definition: Simulator.h:300
bool m_bSetEndSim
true if we the user has manually set the simulation end time.
Definition: Simulator.h:258
long m_lSnapshotByteSize
Size of a memory snapshot in bytes.
Definition: Simulator.h:433
KeyFrame * m_lpSimStopPoint
The pointer to a simulation stop point.
Definition: Simulator.h:448
bool m_bPaused
true if the simulation is paused.
Definition: Simulator.h:143
Standard color class.
Definition: StdColor.h:22
CStdPtrMap< std::string, Structure > m_aryStructures
Definition: Simulator.h:55
float m_fltAngularDamping
The angular damping of the simulation environment.
Definition: Simulator.h:222
float m_fltTotalMicroSleepTime
Total time we were in microsleep during playback pause calculations;.
Definition: Simulator.h:405
Simulates the entire environment.
Definition: Simulator.h:31
Root namespace for the base simulation library for AnimatLab.
short m_iPhysicsStepInterval
Definition: Simulator.h:275
float m_fltSimulationRealTimeToStep
Definition: Simulator.h:346
int m_iVideoLoops
Zero-based index of the video loops.
Definition: Simulator.h:439
bool m_bEnableSimRecording
true to enable simulation recording
Definition: Simulator.h:430
CStdMap< std::string, Organism * >::iterator m_oOrganismIterator
An organism iterator.
Definition: Simulator.h:490
float m_fltPhysicsStepTime
This is the time pers step for the physics engine.
Definition: Simulator.h:381
ExternalStimuliMgr m_oExternalStimuliMgr
Manager for external stimuli.
Definition: Simulator.h:103
Handles processing of a single thread of the simulation.
float m_fltLinearCompliance
The linear compliance of the simulation environment.
Definition: Simulator.h:213
CStdMap< std::string, Structure * > m_aryAllStructures
Definition: Simulator.h:59
bool m_bInitialized
true if the simulation has been initialized.
Definition: Simulator.h:146
Organism * m_lpSelOrganism
The pointer to a selected organism.
Definition: Simulator.h:496
int m_iDesiredFrameRate
Desired frame rate of the simulation video.
Definition: Simulator.h:366
bool m_bInDrag
Tells if we are in the middle of a mouse drag operation to move or rotate a part. ...
Definition: Simulator.h:161
bool m_bManualStepSimulation
If true then the user is manually stepping the simulation.
Definition: Simulator.h:140
float m_fltPlaybackAdditionRealTimeToStep
Definition: Simulator.h:363
float m_fltActualFrameRate
The frame rate for the current frame.
Definition: Simulator.h:375
bool m_bAutoGenerateRandomSeed
Definition: Simulator.h:287
long m_lPhysicsSliceCount
The number of slices that the physics engine has been updated.
Definition: Simulator.h:270
bool m_bForceNoWindows
If this is set to true then no graphical simulation windows will be created regardless of what the co...
Definition: Simulator.h:423
float m_fltDesiredFrameStep
The desired time value duration of the video frame step.
Definition: Simulator.h:369
float m_fltInverseDistanceUnits
The inverse of the distance units.
Definition: Simulator.h:186
float m_fltDataChartStepTime
time to process data charts for this step.
Definition: Simulator.h:395
LightManager m_oLightMgr
Manager for the light objects.
Definition: Simulator.h:115
Declares the simulation window manager class.
KeyFrame * m_lpVideoRecorder
The pointer to a video recorder.
Definition: Simulator.h:442
bool m_bShuttingDown
True if the simulation is shutting down. This is used by other objects in their destructor to know wh...
Definition: Simulator.h:158
unsigned long long m_lStepSimEndTick
The tick count for when the simulation procressing of the step ends.
Definition: Simulator.h:342
CStdArray< BodyPart * > m_aryExtraDataParts
Definition: Simulator.h:91
float m_fltDenominatorDistanceUnits
Definition: Simulator.h:191
bool m_bSimBlockConfirm
true to confirm that a simulation block is in place.
Definition: Simulator.h:127
int m_iSelectionMode
This is the currect visual selection mode used within the GUI.
Definition: Simulator.h:118
ThreadProcessor * m_lpPhysicsThread
The pointer to the physics thread processor.
Definition: Simulator.h:170
float m_fltExternalStimuliStepTime
Time to process external stimuli for this step.
Definition: Simulator.h:392
int m_iVideoStepSize
Size of the i video step.
Definition: Simulator.h:470
bool m_bSimulateHydrodynamics
Definition: Simulator.h:234
bool m_bForceSimulationStop
Set to true to stop the simulation. This is a more forceful way of stopping the sim.
Definition: Simulator.h:137
long m_lTimeSlice
The current time slice. This a long value.
Definition: Simulator.h:251
CStdArray< RigidBody * > m_aryFoodSources
An Array of RigidBody parts that also act as food sources within the environment. ...
Definition: Simulator.h:66
float m_fltAlphaThreshold
The threshold value to use when setting the AlphaFunc for the entire scene.
Definition: Simulator.h:312
float m_fltTotalRealTimeForStep
This is the total time it takes to complete one physics time step.
Definition: Simulator.h:349
float m_ftlMouseSpringDamping
The damping of the user mouse spring.
Definition: Simulator.h:297
long m_lVideoStartSlice
The video start slice.
Definition: Simulator.h:476
Standard class factory.
bool m_bSimRunning
true if the simulation is running
Definition: Simulator.h:149
std::string m_strProjectPath
The directory path where the simulation configuration files are located.
Definition: Simulator.h:40
CStdMap< std::string, Structure * >::iterator m_oStructureIterator
A structure iterator.
Definition: Simulator.h:493
unsigned long long m_lLastTickTaken
This is the last tick taken by a GetTickCount. It is used in debugging.
Definition: Simulator.h:378
float m_fltTotalMicroSleepCount
Total number of times we called microsleep during playback pause calculations.
Definition: Simulator.h:408
SimulationWindowMgr * m_lpWinMgr
Manager for SimulationWindows.
Definition: Simulator.h:112
float m_fltStabilityScale
A linear scaling factor for setting the simulation parameters.
Definition: Simulator.h:210
bool m_bStopSimulation
Set to true to stop the simulation.
Definition: Simulator.h:134
float m_lEndSimTimeSlice
The time slice when the simulation should end.
Definition: Simulator.h:264
Declares the simulation Windows Form.
Materials m_oMaterialMgr
Manager for Materials.
Definition: Simulator.h:109
bool m_bBlockSimulation
true to block simulation. See WaitForBlock for more info.
Definition: Simulator.h:124
float m_fltRemainingStepTime
Definition: Simulator.h:402
Manager for simulation windows.
CStdMap< std::string, AnimatBase * > m_aryObjectList
A list of all animatbase objects in the simulation.
Definition: Simulator.h:81
float m_fltAngularCompliance
The angular compliance of the simulation environment.
Definition: Simulator.h:216
A standard xml manipulation class.
Definition: StdXml.h:19
float m_fltPhysicsSubstepTime
Definition: Simulator.h:248
float m_fltEndSimTime
The time when the simulation should end.
Definition: Simulator.h:261
float m_fltDisplayMassUnits
Tells how many kilograms/m^3 each unit of density is worth within the simulation environment.
Definition: Simulator.h:200
DataChartMgr m_oDataChartMgr
Manager for data charts.
Definition: Simulator.h:100
int m_iTargetAdapterCount
Number of target adapters.
Definition: Simulator.h:94
CStdPtrMap< std::string, OdorType > m_aryOdorTypes
Definition: Simulator.h:63
float m_fltTotalMicroWaitCount
Total number of loop iterations for microwait during playback pause calculations. ...
Definition: Simulator.h:414
CStdMap< std::string, IStdClassFactory * > m_aryNeuralModuleFactories
Definition: Simulator.h:71
int m_iPlaybackControlMode
Determines the mode used for playback control. See the accessor method for more details.
Definition: Simulator.h:332
float m_fltLinearDamping
The linear damping of the simulation environment.
Definition: Simulator.h:219
KeyFrame * m_lpVideoPlayback
The pointer to a video playback.
Definition: Simulator.h:445
float m_fltMouseSpringLengthMagnitude
The magnitude of the length of the mouse spring at each step.
Definition: Simulator.h:306
float m_fltSimRecorderStepTime
Time to process simulation recorder for this step.
Definition: Simulator.h:398
ISimGUICallback * m_lpSimCallback
Definition: Simulator.h:131
float m_fltGravity
The acceleration of gravity to use in the simulation.
Definition: Simulator.h:207
unsigned long long m_lVideoFrameStartTick
The tick when a new video frame time starts.
Definition: Simulator.h:372
SimulationRecorder * m_lpSimRecorder
The pointer to a simulation recorder.
Definition: Simulator.h:106
Namespace for the standard utility objects.
Definition: MarkupSTL.cpp:19
Structure * m_lpSelStructure
The pointer to a selected structure.
Definition: Simulator.h:499
Declares the thread processing class.
bool m_bIsResetting
True if we are in the process of resetting the simulation. False otherwise.
Definition: Simulator.h:164
Callback methods for the simulation object.
float m_fltTimeStep
This is the minimum integration time step taken for all neural modules and the physics engine...
Definition: Simulator.h:237
long m_lStepTimeCount
This is a temp variable for measuring sim time for a set period for each simulation.
Definition: Simulator.h:420
Animat base class.
Definition: AnimatBase.h:36
long m_lVideoSliceCount
Current video slice time slice.
Definition: Simulator.h:436
float m_fltVideoRecordFrameTime
Time of the video record frame.
Definition: Simulator.h:458
std::string m_strExecutablePath
The directory path where the executable is located.
Definition: Simulator.h:43
CStdArray< Adapter * > m_aryTargetPhysicsAdapters
Array of target physics adapters.
Definition: Simulator.h:87
ThreadProcessor * m_lpNeuralThread
The pointer to a neural thread processor.
Definition: Simulator.h:167
Declares the material pair class.
bool m_bForceFastMoving
true if we need to set the physics system to force handling of fast moving objects.
Definition: Simulator.h:155
float m_fltVideoStartTime
Time of the video start.
Definition: Simulator.h:464
float m_fltDistanceUnits
Tells how many meters each unit of distance is worth within the simulation environment.
Definition: Simulator.h:183
float m_fltPrevPhysicsStepTime
Definition: Simulator.h:386
int m_iVideoStep
Zero-based index of the video step.
Definition: Simulator.h:473
bool m_bSteppingSim
true if stepping of simulation has begun. This is set to true once the Simulate methods has been call...
Definition: Simulator.h:152
unsigned long long m_lStartSimTick
The tick count for when the simulation first begins running.
Definition: Simulator.h:267
bool m_bAddBodiesMode
true if the AddBodies mode is enabled within the GUI.
Definition: Simulator.h:121
long m_lVideoEndSlice
The video end slice.
Definition: Simulator.h:479
float m_fltRealTime
This keeps track of the real time from the begginning of the simulation.
Definition: Simulator.h:358
float m_fltTotalNeuralStepTime
Total time for processing of all neural items for this step.
Definition: Simulator.h:389
CStdArray< Adapter * > m_arySourcePhysicsAdapters
Array of source physics adapters.
Definition: Simulator.h:84
float m_fltVideoPlaybackFrameTime
Time of the video playback frame.
Definition: Simulator.h:461
ThreadProcessor * m_lpIOThread
The pointer to an i/o thread processor.
Definition: Simulator.h:173
std::string m_strSimulationFile
The name of the Animat Simulation (ASIM) file.
Definition: Simulator.h:46
bool m_bRecordVideo
true to record video
Definition: Simulator.h:452
double m_dblTotalStepTime
This is a temp variable for measuring sim time for a set period for each simulation.
Definition: Simulator.h:417
float m_fltTime
The current simulation time.
Definition: Simulator.h:254
Declares the materials class.
std::string m_strVideoFilename
Filename of the video file.
Definition: Simulator.h:455
float m_fltVideoEndTime
Time of the video end.
Definition: Simulator.h:467
unsigned long long m_lStepStartTick
This is the tick count that is taken when a step is started.
Definition: Simulator.h:339
Standard serialize class.
Definition: StdSerialize.h:20
float m_fltAngularKineticLoss
The angular kinetic loss of the simulation environment.
Definition: Simulator.h:228
float m_fltMassUnits
Tells how many kilograms each unit of mass is worth within the simulation environment.
Definition: Simulator.h:194
float m_fltRecFieldSelRadius
Definition: Simulator.h:317
float m_fltTotalMicroWaitTime
Total time we were in microwait during playback pause calculations;.
Definition: Simulator.h:411
Declares the thread processing class for a specific module.
float m_fltLinearKineticLoss
The linear kinetic loss of the simulation environment.
Definition: Simulator.h:225
float m_fltTotalRealTimeForStepSmooth
Current value of the exponential smoothing algorith for real time step.
Definition: Simulator.h:355
float m_fltInverseMassUnits
The inverse of the mass units.
Definition: Simulator.h:197
int m_iExtraDataCount
Number of parts that require extra data to be collected.
Definition: Simulator.h:97
float m_fltPhysicsTimeStep
The time increment for each time slice of the physics simulation.
Definition: Simulator.h:278
float m_fltPresetPlaybackTimeStep
Definition: Simulator.h:336
float m_fltMouseSpringDampingForceMagnitude
The magnitude of the damping component of the force being applied by the mosue spring at each step...
Definition: Simulator.h:303
IStdClassFactory * m_lpAnimatClassFactory
Definition: Simulator.h:78
float m_fltMouseSpringStiffness
The stiffness of the user mouse spring.
Definition: Simulator.h:294
CStdColor m_vBackgroundColor
The background color to use when drawing the environment.
Definition: Simulator.h:309