8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
12 #include <sys/types.h>
18 #include "IPhysicsMovableItem.h"
19 #include "IPhysicsBody.h"
21 #include "MovableItem.h"
43 #include "SimulationThread.h"
44 #include "SimulationMgr.h"
52 {
return g_lpSimulator;};
204 g_lpSimulator = NULL;
271 {
Std_TraceMsg(0,
"Caught Error in desctructor of Simulator\r\n",
"", -1,
false,
true);}
275 #pragma region AccessorMutators
277 #pragma region ProjectVariables
475 if(iVal <0 || iVal > SIMULATION_SELECTION_MODE)
476 THROW_PARAM_ERROR(Al_Err_lInvalidSelMode, Al_Err_strInvalidSelMode,
"Selection Mode", iVal);
481 CStdMap<std::string, AnimatBase *>::iterator oPos;
485 lpBase = oPos->second;
486 if(lpBase && lpBase !=
this)
549 #pragma region EnvironmentVariables
1113 if(iVal == 0) iVal = 1;
1114 Std_IsAboveMin((
int) 0, (
int) iVal,
true,
"PhysicsStepInterval");
1134 float fltMin = MinTimeStep();
1139 int iDiv = (int) ((fltVal / fltMin) + 0.5f);
1148 if(m_iPhysicsStepInterval == 1) fltMin = MinTimeStep();
1268 Std_IsAboveMin((
float) 0, fltVal,
true,
"MouseSpringStiffness",
true);
1299 Std_IsAboveMin((
float) 0, fltVal,
true,
"MouseSpringDamping",
true);
1486 CStdColor vColor(aryColor[0], aryColor[1], aryColor[2], aryColor[3], 1);
1501 vColor.
Load(strXml,
"Color");
1507 void Simulator::AlphaThreshold(
float fltValue)
1515 void Simulator::RecFieldSelRadius(
float fltValue,
bool bUseScaling,
bool bUpdateAllBodies)
1522 if(bUpdateAllBodies)
1524 CStdMap<std::string, AnimatBase *>::iterator oPos;
1528 lpBase = oPos->second;
1530 if(lpBody && lpBase !=
this)
1531 lpBody->Physics_ResizeSelectedReceptiveFieldVertex();
1587 if(iMode != PLAYBACK_MODE_FASTEST_POSSIBLE && iMode != PLAYBACK_MODE_MATCH_PHYSICS_STEP && iMode != PLAYBACK_MODE_PRESET_VALUE)
1588 THROW_PARAM_ERROR(Al_Err_lInvalidPlaybackMode, Al_Err_strInvalidPlaybackMode,
"Mode", STR(iMode));
1620 THROW_PARAM_ERROR(Al_Err_lInvalidPresetPlaybackTimeStep, Al_Err_strInvalidPresetPlaybackTimeStep,
"Time Step", STR((
float) fltTimeStep));
1625 unsigned long long Simulator::StepStartTick()
1628 unsigned long long Simulator::StepSimEndTick()
1631 double Simulator::CurrentRealTimeForStep_n()
1634 double Simulator::CurrentRealTimeForStep_s()
1678 void Simulator::ForceNoWindows(
bool bVal)
1694 m_lpScript = lpScript;
1701 #pragma region UnitScalingVariables
1814 #pragma region RecordingVariables
1897 #pragma region Methods
1899 #pragma region SimulationMethods
1950 CStdMap<std::string, Structure *>::iterator oPos;
1954 lpStructure = oPos->second;
1955 lpStructure->Create();
1971 struct stat f__stat;
1972 bool bFileExists = (stat(strVideoFile.c_str(), &f__stat) != 0);
1974 remove(strVideoFile.c_str( ));
1990 CStdMap<std::string, AnimatBase *>::iterator oPos;
1994 lpBase = oPos->second;
1995 if(lpBase && lpBase !=
this)
2001 void Simulator::NotifyRigidBodyAdded(std::string strID)
2003 CStdMap<std::string, AnimatBase *>::iterator oPos;
2007 lpBase = oPos->second;
2009 lpBase->RigidBodyAdded(strID);
2013 void Simulator::NotifyRigidBodyRemoved(std::string strID)
2015 CStdMap<std::string, AnimatBase *>::iterator oPos;
2019 lpBase = oPos->second;
2021 lpBase->RigidBodyRemoved(strID);
2094 if(lTimeout > 0 && lTime >= lTimeout)
2320 CStdMap<std::string, Structure *>::iterator oPos;
2324 lpStructure = oPos->second;
2329 for(
int iIndex=0; iIndex<iSize; iIndex++)
2333 for(
int iIndex=0; iIndex<iSize; iIndex++)
2350 float Simulator::MinTimeStep()
2353 CStdMap<std::string, Structure *>::iterator oPos;
2357 lpStructure = oPos->second;
2364 void Simulator::MicroWait(
unsigned int iMicroTime)
2367 unsigned long long lStart = GetTimerTick();
2368 int iRemaining = iMicroTime;
2371 while(iRemaining > 0)
2373 iRemaining = iMicroTime - (
unsigned int) TimerDiff_u(lStart, GetTimerTick());
2378 THROW_ERROR(Al_Err_lTimedOutInMicroWait, Al_Err_strTimedOutInMicroWait);
2385 void Simulator::StepPlaybackControl()
2387 RecordSimulationStepTimer();
2395 double dblRemainingTime = 0;
2398 dblRemainingTime = (CalculateRemainingPlaybackTime());
2400 if(dblRemainingTime > 0)
2408 else if(dblRemainingTime > 100e-6)
2423 }
while(dblRemainingTime > 0);
2426 RecordAddedPlaybackTime();
2429 void Simulator::StepVideoFrame()
2431 double dblTime = TimeBetweenVideoFrames();
2435 UpdateSimulationWindows();
2436 StartVideoFrameTimer();
2439 MicroSleep((
unsigned int) (RemainingVideoFrameTime()*1000000));
2451 unsigned long long lStart = GetTimerTick();
2454 m_lpScript->BeforeStepNeuralEngine();
2465 m_lpScript->AfterStepNeuralEngine();
2488 m_lpScript->AfterStepPhysicsEngine();
2500 unsigned long long lStart = GetTimerTick();
2503 m_lpScript->BeforeStepPhysicsEngine();
2524 void Simulator::StepExternalStimuli()
2526 unsigned long long lStart = GetTimerTick();
2533 void Simulator::StepDataCharts()
2535 unsigned long long lStart = GetTimerTick();
2542 void Simulator::StepSimRecorder()
2544 unsigned long long lStart = GetTimerTick();
2559 StepExternalStimuli();
2633 std::cout <<
"starting sim" <<
"\r\n";
2659 StartSimulationStepTimer();
2661 StepPlaybackControl();
2664 RecordSimulationTotalStepTimer();
2670 std::string strError =
"An error occurred while stepping the simulation.\nError: " + oError.
m_strError;
2671 HandleNonCriticalError(strError);
2676 HandleCriticalError(Al_Err_strCriticalSimError);
2720 CStdMap<std::string, AnimatBase *>::iterator oPos;
2724 lpBase = oPos->second;
2741 CStdMap<std::string, AnimatBase *>::iterator oPos;
2745 lpBase = oPos->second;
2762 CStdMap<std::string, AnimatBase *>::iterator oPos;
2766 lpBase = oPos->second;
2771 WriteToConsole(
"Simulation stopped. Time: " + STR(
m_fltTime));
2774 void Simulator::HandleCriticalError(std::string strError)
2776 WriteToConsole(
"Critical error occurred: " + strError);
2783 void Simulator::HandleNonCriticalError(std::string strError)
2785 WriteToConsole(
"Non critical error occurred: " + strError);
2791 void Simulator::StartSimulationStepTimer()
2798 void Simulator::RecordSimulationStepTimer()
2810 void Simulator::RecordSimulationTotalStepTimer()
2812 unsigned long long lEnd = GetTimerTick();
2833 double Simulator::CalculateRemainingPlaybackTime()
2843 void Simulator::RecordAddedPlaybackTime()
2845 unsigned long long lEnd = GetTimerTick();
2849 void Simulator::StartVideoFrameTimer()
2851 double dblTime = TimeBetweenVideoFrames();
2856 double Simulator::TimeBetweenVideoFrames()
2862 double Simulator::RemainingVideoFrameTime()
2865 if(dblRemaining < 0) dblRemaining = 0;
2866 return dblRemaining;
2880 struct tm * timeinfo;
2883 timeinfo = localtime ( &rawtime );
2922 #pragma region LoadMethods
2937 TRACE_DEBUG(
"Loading simulator config file.\r\nFileName: " + strFileName);
2942 THROW_ERROR(Al_Err_lSimFileBlank, Al_Err_strSimFileBlank);
2954 TRACE_DEBUG(
"Finished loading simulator config file.");
2970 TRACE_DEBUG(
"Loading simulator config from Xml.");
3005 TRACE_DEBUG(
"Finished loading simulator config from Xml.");
3026 int iFindDebug =
Std_ToLower(strModuleName).find(
"_vc10d");
3027 if(iFindDebug == -1) iFindDebug =
Std_ToLower(strModuleName).find(
"_d.");
3029 int iFindDebug =
Std_ToLower(strModuleName).find(
"_debug");
3030 if(iFindDebug == -1) iFindDebug =
Std_ToLower(strModuleName).find(
"_d.");
3034 if(iFindDebug == -1 )
3037 THROW_PARAM_ERROR(Al_Err_lLoadingReleaseLib, Al_Err_strLoadingReleaseLib,
"Module Name", strModuleName);
3042 if(iFindDebug != -1)
3045 THROW_PARAM_ERROR(Al_Err_lLoadingDebugLib, Al_Err_strLoadingDebugLib,
"Module Name", strModuleName);
3051 lpFactory = IStdClassFactory::LoadModule(strModuleName, bThrowError);
3056 if(lpFactory)
delete lpFactory;
3057 RELAY_ERROR(oError);
3062 if(lpFactory)
delete lpFactory;
3063 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3079 TRACE_DEBUG(
"Loading structures from Xml.");
3082 THROW_ERROR(Al_Err_lClassFactoryNotDefined, Al_Err_strClassFactoryNotDefined);
3135 for(
int iIndex=0; iIndex<iChildCount; iIndex++)
3148 for(
int iIndex=0; iIndex<iCount; iIndex++)
3161 for(
int iIndex=0; iIndex<iCount; iIndex++)
3177 TRACE_DEBUG(
"Finished loading structures from Xml.");
3198 lpStructure->SetSystemPointers(
this, NULL, NULL, NULL,
true);
3199 lpStructure->Load(oXml);
3206 if(lpStructure)
delete lpStructure;
3207 RELAY_ERROR(oError);
3212 if(lpStructure)
delete lpStructure;
3213 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3232 std::string strModule;
3233 std::string strType;
3244 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Organism");
3246 lpOrganism->SetSystemPointers(
this, NULL, NULL, NULL,
true);
3247 lpOrganism->Load(oXml);
3254 if(lpOrganism)
delete lpOrganism;
3255 RELAY_ERROR(oError);
3260 if(lpOrganism)
delete lpOrganism;
3261 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3287 lpOdorType->Load(oXml);
3289 AddOdorType(lpOdorType);
3294 if(lpOdorType)
delete lpOdorType;
3295 RELAY_ERROR(oError);
3300 if(lpOdorType)
delete lpOdorType;
3301 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3318 std::string strModule;
3319 std::string strType;
3331 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Script");
3335 lpScript->
Load(oXml);
3341 if(lpScript)
delete lpScript;
3343 RELAY_ERROR(oError);
3348 if(lpScript)
delete lpScript;
3350 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3366 std::ifstream ifSimFile;
3370 THROW_PARAM_ERROR(Al_Err_lSimFileNotFound, Al_Err_strSimFileNotFound,
"Simulation File", strFile);
3372 ifSimFile.open(strFile);
3374 if(ifSimFile.is_open())
3376 ifSimFile.read(sBuffer, 1000);
3379 std::string strText = sBuffer;
3381 int iModuleStart = strText.find(
"<AnimatModule>");
3382 int iModuleEnd = strText.find(
"</AnimatModule>");
3384 if(iModuleStart == -1)
3385 THROW_PARAM_ERROR(Al_Err_lAnimatModuleTagNotFound, Al_Err_strAnimatModuleTagNotFound,
"Simulation File", strFile);
3387 if(iModuleEnd == -1)
3388 THROW_PARAM_ERROR(Al_Err_lAnimatModuleTagNotFound, Al_Err_strAnimatModuleTagNotFound,
"Simulation File", strFile);
3390 int iLen = iModuleEnd - iModuleStart - 14;
3392 strAnimatModule = strText.substr((iModuleStart+14), iLen);
3395 THROW_PARAM_ERROR(Al_Err_lSimFileNotFound, Al_Err_strSimFileNotFound,
"Simulation File", strFile);
3397 if(strAnimatModule.length() == 0)
3398 THROW_PARAM_ERROR(Al_Err_lAnimatModuleTagNotFound, Al_Err_strAnimatModuleTagNotFound,
"Simulation File", strFile);
3420 #pragma region CreateMethods
3444 if(strModuleCheck ==
"" || strModuleCheck ==
"ANIMATLAB")
3447 THROW_ERROR(Al_Err_lClassFactoryNotDefined, Al_Err_strClassFactoryNotDefined);
3456 return lpFactory->
CreateObject(strClassName, strType, bThrowError);
3495 std::string strExecutablePath, strExeFile;
3507 THROW_ERROR(Al_Err_lNoProjectParamOnCommandLine, Al_Err_strNoProjectParamOnCommandLine);
3509 std::string strProject = argv[1];
3510 std::string strAnimatModule =
"";
3513 THROW_ERROR(Al_Err_lNoProjectParamOnCommandLine, Al_Err_strNoProjectParamOnCommandLine);
3534 std::string strExecutablePath, strExeFile;
3545 std::string strProject = strSimFile;
3546 std::string strAnimatModule =
"";
3549 THROW_ERROR(Al_Err_lNoProjectParamOnCommandLine, Al_Err_strNoProjectParamOnCommandLine);
3581 if(lpSim)
delete lpSim;
3582 RELAY_ERROR(oError);
3587 if(lpSim)
delete lpSim;
3588 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3609 std::string strProjectPath, strProjectFile;
3610 std::string strExecutablePath, strExeFile;
3621 THROW_PARAM_ERROR(Al_Err_lSimFileNotFound, Al_Err_strSimFileNotFound,
"Simulation File", strSimulationFile);
3627 strProjectPath = strExecutablePath;
3628 strSimulationFile = strProjectPath + strSimulationFile;
3642 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Simulator");
3648 lpSim->ForceNoWindows(bForceNoWindows);
3651 {
delete lpAnimatFactory; lpAnimatFactory = NULL;}
3653 g_lpSimulator = lpSim;
3658 if(lpSim)
delete lpSim;
3659 if(lpAnimatFactory)
delete lpAnimatFactory;
3660 RELAY_ERROR(oError);
3665 if(lpSim)
delete lpSim;
3666 if(lpAnimatFactory)
delete lpAnimatFactory;
3667 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3687 std::string strProjectPath, strProjectFile;
3688 std::string strExecutablePath, strExeFile;
3706 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Simulator");
3713 {
delete lpAnimatFactory; lpAnimatFactory = NULL;}
3715 g_lpSimulator = lpSim;
3720 if(lpSim)
delete lpSim;
3721 if(lpAnimatFactory)
delete lpAnimatFactory;
3722 RELAY_ERROR(oError);
3727 if(lpSim)
delete lpSim;
3728 if(lpAnimatFactory)
delete lpAnimatFactory;
3729 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3762 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Simulator");
3769 {
delete lpAnimatFactory; lpAnimatFactory = NULL;}
3771 g_lpSimulator = lpSim;
3776 if(lpSim)
delete lpSim;
3777 if(lpAnimatFactory)
delete lpAnimatFactory;
3778 RELAY_ERROR(oError);
3783 if(lpSim)
delete lpSim;
3784 if(lpAnimatFactory)
delete lpAnimatFactory;
3785 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
3793 #pragma region FindMethods
3810 CStdMap<std::string, IStdClassFactory *>::iterator oPos;
3814 lpFactory = oPos->second;
3815 else if(bThrowError)
3816 THROW_PARAM_ERROR(Al_Err_lModuleNameNotFound, Al_Err_strModuleNameNotFound,
"ModuleName", strModuleName);
3838 CStdPtrMap<std::string, Organism>::iterator oPos;
3842 lpOrganism = oPos->second;
3843 else if(bThrowError)
3844 THROW_PARAM_ERROR(Al_Err_lOrganismIDNotFound, Al_Err_strOrganismIDNotFound,
"OrganismID", strOrganismID);
3868 CStdPtrMap<std::string, Structure>::iterator oPos;
3872 lpStructure = oPos->second;
3873 else if(bThrowError)
3874 THROW_PARAM_ERROR(Al_Err_lStructureIDNotFound, Al_Err_strStructureIDNotFound,
"StructureID", strStructureID);
3894 CStdPtrMap<std::string, OdorType>::iterator oPos;
3898 lpOdorType = oPos->second;
3899 else if(bThrowError)
3900 THROW_PARAM_ERROR(Al_Err_lOdorIDNotFound, Al_Err_strOdorIDNotFound,
"OdorID", strOdorID);
3923 CStdPtrMap<std::string, Structure>::iterator oPos;
3927 lpStructure = oPos->second;
3928 else if(bThrowError)
3929 THROW_PARAM_ERROR(Al_Err_lStructureIDNotFound, Al_Err_strStructureIDNotFound,
"StructureID", strStructureID);
3959 return lpStructure->
FindJoint(strJointID, bThrowError);
4011 CStdMap<std::string, AnimatBase *>::iterator oPos;
4015 lpFind = oPos->second;
4016 else if(bThrowError)
4017 THROW_PARAM_ERROR(Al_Err_lIDNotFound, Al_Err_strIDNotFound,
"ID", strID);
4033 void Simulator::FindClosestFoodSources(CStdFPoint &oMouthPos,
float fltMinRadius, CStdArray<RigidBody *> &arySources, CStdArray<float> &aryDistances)
4035 RigidBody *lpFood = NULL, *lpMinFood = NULL;
4036 float fltDist=0, fltMinDist=0;
4039 arySources.RemoveAll();
4040 aryDistances.RemoveAll();
4042 for(
int iIndex=0; iIndex<iCount; iIndex++)
4048 if( (fltDist <= fltMinRadius) && ((fltDist < fltMinDist) || !lpMinFood))
4050 arySources.Add(lpFood);
4051 aryDistances.Add(fltDist);
4058 #pragma region AddRemoveMethods
4071 THROW_PARAM_ERROR(Al_Err_lDuplicateAddOfObject, Al_Err_strDuplicateAddOfObject,
"ID", lpItem->
ID());
4101 void Simulator::AddNeuralModuleFactory(std::string strModuleName,
NeuralModule *lpModule)
4104 THROW_PARAM_ERROR(Al_Err_lModuleClassFactoryNotDefined, Al_Err_strModuleClassFactoryNotDefined,
"ModuleName", strModuleName);
4111 int Simulator::FindAdapterListIndex(CStdArray<Adapter *> aryAdapters, std::string strID,
bool bThrowError)
4113 int iCount = aryAdapters.GetSize();
4114 for(
int iIdx=0; iIdx<iCount; iIdx++)
4115 if(aryAdapters[iIdx]->
ID() == strID)
4119 THROW_PARAM_ERROR(Al_Err_lAdapterIDNotFound, Al_Err_strAdapterIDNotFound,
"ID", strID);
4133 void Simulator::AttachSourceAdapter(
Structure *lpStructure,
Adapter *lpAdapter)
4139 if(strModuleName ==
"" || strModuleName ==
"ANIMATLAB")
4148 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Organism");
4164 void Simulator::RemoveSourceAdapter(
Structure *lpStructure,
Adapter *lpAdapter)
4170 if(strModuleName ==
"" || strModuleName ==
"ANIMATLAB")
4180 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Organism");
4196 void Simulator::AttachTargetAdapter(
Structure *lpStructure,
Adapter *lpAdapter)
4202 if(strModuleName ==
"" || strModuleName ==
"ANIMATLAB")
4214 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Organism");
4233 void Simulator::RemoveTargetAdapter(
Structure *lpStructure,
Adapter *lpAdapter)
4239 if(strModuleName ==
"" || strModuleName ==
"ANIMATLAB")
4252 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"Organism");
4267 bool Simulator::IsPhysicsAdapter(
Adapter *lpAdapter)
4272 if(iIdx1 > -1 || iIdx2 > -1)
4287 void Simulator::AddFoodSource(
RigidBody *lpFood)
4302 void Simulator::RemoveFoodSource(
RigidBody *lpFood)
4322 for(
int iIdx=0; iIdx<iCount; iIdx++)
4329 void Simulator::AddToExtractExtraData(
BodyPart *lpPart)
4331 int iIndex = FindExtraDataIndex(lpPart);
4337 void Simulator::RemoveFromExtractExtraData(
BodyPart *lpPart)
4339 int iIndex = FindExtraDataIndex(lpPart);
4345 int Simulator::FindExtraDataIndex(
BodyPart *lpPart)
4348 for(
int iIdx=0; iIdx<iCount; iIdx++)
4358 THROW_ERROR(Al_Err_lStructureNotDefined, Al_Err_strStructureNotDefined);
4367 oError.
m_strError +=
" Duplicate Organism Key: " + lpOrganism->
ID();
4368 RELAY_ERROR(oError);
4413 THROW_ERROR(Al_Err_lStructureNotDefined, Al_Err_strStructureNotDefined);
4422 oError.
m_strError +=
" Duplicate structure Key: " + lpStructure->
ID();
4423 RELAY_ERROR(oError);
4474 void Simulator::AddOdorType(
OdorType *lpOdorType)
4477 THROW_ERROR(Al_Err_lOdorNotDefined, Al_Err_strOdorNotDefined);
4485 oError.
m_strError +=
" Duplicate odor type Key: " + lpOdorType->
ID();
4486 RELAY_ERROR(oError);
4490 void Simulator::AddOdorType(std::string strXml,
bool bDoNotInit)
4503 void Simulator::RemoveOdorType(std::string strID,
bool bThrowError)
4508 void Simulator::IncrementPhysicsBodyCount()
4536 m_lpScript = lpScript;
4540 if(lpScript)
delete lpScript;
4542 RELAY_ERROR(oError);
4546 if(lpScript)
delete lpScript;
4548 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
4568 if(m_lpScript && m_lpScript->
ID() == strID)
4574 THROW_PARAM_ERROR(Al_Err_lRigidBodyIDNotFound, Al_Err_strRigidBodyIDNotFound,
"ID", strID);
4579 #pragma region DataAccesMethods
4586 if(strType ==
"TIME")
4588 else if(strType ==
"PHYSICSTIMESTEP")
4590 else if(strType ==
"PHYSICSSUBSTEPTIME")
4592 else if(strType ==
"SIMULATIONREALTIMETOSTEP")
4594 else if(strType ==
"PLAYBACKADDITIONREALTIMETOSTEP")
4596 else if(strType ==
"TOTALREALTIMEFORSTEP")
4598 else if(strType ==
"ACTUALFRAMERATE")
4600 else if(strType ==
"REALTIME")
4602 else if(strType ==
"TOTALREALTIMEFORSTEPSMOOTHED")
4604 else if(strType ==
"PHYSICSREALTIMEFORSTEP")
4606 else if(strType ==
"NEURALREALTIMEFORSTEP")
4608 else if(strType ==
"EXTERNALSTIMULIREALTIMEFORSTEP")
4610 else if(strType ==
"DATACHARTREALTIMEFORSTEP")
4612 else if(strType ==
"SIMRECORDERREALTIMEFORSTEP")
4614 else if(strType ==
"REMAININGSTEPTIME")
4616 else if(strType ==
"MOUSESPRINGFORCEMAGNITUDE")
4618 else if(strType ==
"MOUSESPRINGDAMPINGFORCEMAGNITUDE")
4620 else if(strType ==
"MOUSESPRINGLENGTHMAGNITUDE")
4622 else if(strType ==
"TOTALMICROSLEEPTIME")
4624 else if(strType ==
"TOTALMICROSLEEPCOUNT")
4626 else if(strType ==
"TOTALMICROWAITTIME")
4628 else if(strType ==
"TOTALMICROWAITCOUNT")
4631 THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Simulator DataType: " + strDataType);
4640 if(strType ==
"VISUALSELECTIONMODE")
4645 else if(strType ==
"ADDBODIESMODE")
4650 else if(strType ==
"DISTANCEUNITS")
4655 else if(strType ==
"MASSUNITS")
4660 else if(strType ==
"GRAVITY")
4662 Gravity((
float) atof(strValue.c_str()));
4665 else if(strType ==
"PHYSICSTIMESTEP")
4670 else if(strType ==
"PHYSICSSUBSTEPS")
4675 else if(strType ==
"SIMULATEHYDRODYNAMICS")
4680 else if(strType ==
"AUTOGENERATERANDOMSEED")
4685 else if(strType ==
"MANUALRANDOMSEED")
4690 else if(strType ==
"FRAMERATE")
4695 else if(strType ==
"FORCEFASTMOVING")
4700 else if(strType ==
"MOUSESPRINGSTIFFNESS")
4705 else if(strType ==
"MOUSESPRINGDAMPING")
4710 else if(strType ==
"LINEARCOMPLIANCE")
4715 else if(strType ==
"ANGULARCOMPLIANCE")
4720 else if(strType ==
"LINEARDAMPING")
4725 else if(strType ==
"ANGULARDAMPING")
4730 else if(strType ==
"LINEARKINETICLOSS")
4735 else if(strType ==
"ANGULARKINETICLOSS")
4740 else if(strType ==
"SETENDSIMTIME")
4745 else if(strType ==
"ENDSIMTIME")
4750 else if(strType ==
"RECFIELDSELRADIUS")
4752 RecFieldSelRadius((
float) atof(strValue.c_str()));
4755 else if(strDataType ==
"BACKGROUNDCOLOR")
4760 else if(strDataType ==
"ALPHATHRESHOLD")
4762 AlphaThreshold((
float) atof(strValue.c_str()));
4765 else if(strDataType ==
"BACKGROUNDCOLOR.RED")
4771 else if(strDataType ==
"BACKGROUNDCOLOR.GREEN")
4777 else if(strDataType ==
"BACKGROUNDCOLOR.BLUE")
4783 else if(strDataType ==
"BACKGROUNDCOLOR.ALPHA")
4789 else if(strDataType ==
"TIMESTEPMODIFIED")
4794 else if(strDataType ==
"PLAYBACKCONTROLMODE")
4799 else if(strDataType ==
"PRESETPLAYBACKTIMESTEP")
4804 else if(strDataType ==
"STABILITYSCALE")
4812 THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Data Type", strDataType);
4821 aryProperties.Add(
new TypeProperty(
"Time", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4822 aryProperties.Add(
new TypeProperty(
"PhysicsSubStepTime", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4823 aryProperties.Add(
new TypeProperty(
"SimulationRealTimeToStep", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4824 aryProperties.Add(
new TypeProperty(
"PlaybackAdditionalRealTimeToStep", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4825 aryProperties.Add(
new TypeProperty(
"TotalRealTimeForStep", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4826 aryProperties.Add(
new TypeProperty(
"AcutalFrameRate", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4827 aryProperties.Add(
new TypeProperty(
"RealTime", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4828 aryProperties.Add(
new TypeProperty(
"TotalRealTimeForStepSmoothed", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4829 aryProperties.Add(
new TypeProperty(
"PhysicsRealTimeForStep", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4830 aryProperties.Add(
new TypeProperty(
"NeuralRealTimeForStep", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4831 aryProperties.Add(
new TypeProperty(
"ExternalStimuliRealTimeForStep", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4832 aryProperties.Add(
new TypeProperty(
"DataChartRealTimeForStep", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4833 aryProperties.Add(
new TypeProperty(
"SimRecorderRealTimeForStep", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4834 aryProperties.Add(
new TypeProperty(
"RemainingStepTime", AnimatPropertyType::Float, AnimatPropertyDirection::Get));
4836 aryProperties.Add(
new TypeProperty(
"VisualSelectionMode", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
4837 aryProperties.Add(
new TypeProperty(
"AddBodiesMode", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
4838 aryProperties.Add(
new TypeProperty(
"DistanceUnits", AnimatPropertyType::String, AnimatPropertyDirection::Set));
4839 aryProperties.Add(
new TypeProperty(
"MassUnits", AnimatPropertyType::String, AnimatPropertyDirection::Set));
4840 aryProperties.Add(
new TypeProperty(
"Gravity", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4841 aryProperties.Add(
new TypeProperty(
"PhysicsTimeStep", AnimatPropertyType::Float, AnimatPropertyDirection::Both));
4842 aryProperties.Add(
new TypeProperty(
"SimulateHydrodynamics", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
4843 aryProperties.Add(
new TypeProperty(
"AutoGenerateRandomSeed", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
4844 aryProperties.Add(
new TypeProperty(
"ManualRandomSeed", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
4845 aryProperties.Add(
new TypeProperty(
"FrameRate", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
4846 aryProperties.Add(
new TypeProperty(
"ForceFastMoving", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
4847 aryProperties.Add(
new TypeProperty(
"MouseSpringStiffness", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4848 aryProperties.Add(
new TypeProperty(
"MouseSpringDamping", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4849 aryProperties.Add(
new TypeProperty(
"CalcCriticalSimParams", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
4850 aryProperties.Add(
new TypeProperty(
"LinearCompliance", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4851 aryProperties.Add(
new TypeProperty(
"AngularCompliance", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4852 aryProperties.Add(
new TypeProperty(
"LinearDamping", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4853 aryProperties.Add(
new TypeProperty(
"AngularDamping", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4854 aryProperties.Add(
new TypeProperty(
"LinearKineticLoss", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4855 aryProperties.Add(
new TypeProperty(
"AngularKineticLoss", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4856 aryProperties.Add(
new TypeProperty(
"SetEndSimTime", AnimatPropertyType::Boolean, AnimatPropertyDirection::Set));
4857 aryProperties.Add(
new TypeProperty(
"EndSimTime", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4858 aryProperties.Add(
new TypeProperty(
"RecFieldSelRadius", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4859 aryProperties.Add(
new TypeProperty(
"BackgroundColor", AnimatPropertyType::Xml, AnimatPropertyDirection::Set));
4860 aryProperties.Add(
new TypeProperty(
"BackgroundColor.Red", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4861 aryProperties.Add(
new TypeProperty(
"BackgroundColor.Blue", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4862 aryProperties.Add(
new TypeProperty(
"BackgroundColor.Green", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4863 aryProperties.Add(
new TypeProperty(
"BackgroundColor.Alpha", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4864 aryProperties.Add(
new TypeProperty(
"PlaybackControlMode", AnimatPropertyType::Integer, AnimatPropertyDirection::Set));
4865 aryProperties.Add(
new TypeProperty(
"PresetPlaybackTimeStep", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4866 aryProperties.Add(
new TypeProperty(
"StabilityScale", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4867 aryProperties.Add(
new TypeProperty(
"AlphaThreshold", AnimatPropertyType::Float, AnimatPropertyDirection::Set));
4870 bool Simulator::AddItem(
const std::string &strItemType,
const std::string &strXml,
bool bThrowError,
bool bDoNotInit)
4874 if(strType ==
"STIMULUS")
4876 else if(strType ==
"DATACHART")
4878 else if(strType ==
"LIGHT")
4880 else if(strType ==
"STRUCTURE")
4885 else if(strType ==
"ORGANISM")
4890 else if(strType ==
"HUDITEM")
4896 else if(strType ==
"ODORTYPE")
4898 AddOdorType(strXml, bDoNotInit);
4901 else if(strType ==
"SCRIPT")
4906 else if(strType ==
"MATERIALTYPE" || strType ==
"MATERIALPAIR")
4911 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
4920 if(strType ==
"STIMULUS")
4922 else if(strType ==
"DATACHART")
4924 else if(strType ==
"LIGHT")
4926 else if(strType ==
"STRUCTURE")
4931 else if(strType ==
"ORGANISM")
4936 else if(strType ==
"ODORTYPE")
4938 RemoveOdorType(strID);
4941 else if(strType ==
"SCRIPT")
4946 else if(strType ==
"MATERIALTYPE" || strType ==
"MATERIALPAIR")
4948 else if(strType ==
"SCRIPTEDSIMWINDOW")
4953 THROW_PARAM_ERROR(Al_Err_lInvalidItemType, Al_Err_strInvalidItemType,
"Item Type", strItemType);
4960 #pragma region RecorderMethods
4973 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
4991 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5006 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5021 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5038 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5055 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5076 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5079 return lpFrame->
ID();
5093 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5113 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5119 return lpFrame->
ID();
5124 return lpFrame->
ID();
5138 THROW_ERROR(Al_Err_lNoRecorderDefined, Al_Err_strNoRecorderDefined);
5160 CStdMap<std::string, Structure *>::iterator oPos;
5164 lpStructure = oPos->second;
5182 CStdMap<std::string, Structure *>::iterator oPos;
5186 lpStructure = oPos->second;
5202 CStdMap<std::string, Structure *>::iterator oPos;
5206 lpStructure = oPos->second;
5223 #pragma region CollisionMethods
5236 void Simulator::EnableCollisions(
Structure *lpStruct, CStdPtrArray<CollisionPair> &m_aryCollisionList)
5239 int iCount = m_aryCollisionList.GetSize();
5243 for(
int iIndex=0; iIndex<iCount; iIndex++)
5245 lpPair = m_aryCollisionList[iIndex];
5255 CStdMap<std::string, Structure *>::iterator oPos;
5259 lpStructure = oPos->second;
5275 void Simulator::DisableCollisions(
Structure *lpStruct, CStdPtrArray<CollisionPair> &m_aryCollisionList)
5278 int iCount = m_aryCollisionList.GetSize();
5282 for(
int iIndex=0; iIndex<iCount; iIndex++)
5284 lpPair = m_aryCollisionList[iIndex];
5295 CStdMap<std::string, Structure *>::iterator oPos;
5299 lpStructure = oPos->second;
5311 #pragma region UnitScaleMethods
5330 if(strUnits ==
"KILOMETERS" || strUnits ==
"KILOMETER")
5331 return (
float) 1000;
5333 if(strUnits ==
"CENTAMETERS" || strUnits ==
"CENTAMETER")
5336 if(strUnits ==
"DECAMETERS" || strUnits ==
"DECAMETER")
5339 if(strUnits ==
"METERS" || strUnits ==
"METER")
5342 if(strUnits ==
"DECIMETERS" || strUnits ==
"DECIMETER")
5345 if(strUnits ==
"CENTIMETERS" || strUnits ==
"CENTIMETER")
5346 return (
float) 0.01;
5348 if(strUnits ==
"MILLIMETERS" || strUnits ==
"MILLIMETER")
5349 return (
float) 0.001;
5351 THROW_PARAM_ERROR(Al_Err_lInvalidDistanceUnits, Al_Err_strInvalidDistanceUnits,
"DistanceUnits", strUnits);
5373 if(strUnits ==
"KILOMETERS" || strUnits ==
"KILOMETER")
5376 if(strUnits ==
"CENTAMETERS" || strUnits ==
"CENTAMETER")
5379 if(strUnits ==
"DECAMETERS" || strUnits ==
"DECAMETER")
5382 if(strUnits ==
"METERS" || strUnits ==
"METER")
5385 if(strUnits ==
"DECIMETERS" || strUnits ==
"DECIMETER")
5388 if(strUnits ==
"CENTIMETERS" || strUnits ==
"CENTIMETER")
5391 if(strUnits ==
"MILLIMETERS" || strUnits ==
"MILLIMETER")
5394 THROW_PARAM_ERROR(Al_Err_lInvalidDistanceUnits, Al_Err_strInvalidDistanceUnits,
"DenominatorDistanceUnits", strUnits);
5416 if(strUnits ==
"KILOGRAMS" || strUnits ==
"KILOGRAM")
5419 if(strUnits ==
"CENTAGRAMS" || strUnits ==
"CENTAGRAM")
5422 if(strUnits ==
"DECAGRAMS" || strUnits ==
"DECAGRAM")
5423 return (
float) 0.01;
5425 if(strUnits ==
"GRAMS" || strUnits ==
"GRAM")
5426 return (
float) 0.001;
5428 if(strUnits ==
"DECIGRAMS" || strUnits ==
"DECIGRAM")
5429 return (
float) 1e-4;
5431 if(strUnits ==
"CENTIGRAMS" || strUnits ==
"CENTIGRAM")
5432 return (
float) 1e-5;
5434 if(strUnits ==
"MILLIGRAMS" || strUnits ==
"MILLIGRAM")
5435 return (
float) 1e-6;
5437 THROW_PARAM_ERROR(Al_Err_lInvalidMassUnits, Al_Err_strInvalidMassUnits,
"MassUnits", strUnits);
5461 if(strUnits ==
"KILOGRAMS" || strUnits ==
"KILOGRAM")
5462 return (
float) 1000;
5464 if(strUnits ==
"CENTAGRAMS" || strUnits ==
"CENTAGRAM")
5467 if(strUnits ==
"DECAGRAMS" || strUnits ==
"DECAGRAM")
5470 if(strUnits ==
"GRAMS" || strUnits ==
"GRAM")
5473 if(strUnits ==
"DECIGRAMS" || strUnits ==
"DECIGRAM")
5476 if(strUnits ==
"CENTIGRAMS" || strUnits ==
"CENTIGRAM")
5477 return (
float) 0.01;
5479 if(strUnits ==
"MILLIGRAMS" || strUnits ==
"MILLIGRAM")
5480 return (
float) 0.001;
5482 THROW_PARAM_ERROR(Al_Err_lInvalidMassUnits, Al_Err_strInvalidMassUnits,
"MassUnits", strUnits);
long m_lVideoFrame
The video frame.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
float m_fltPrevTotalRealTimeForStep
Previous total time for the step. Used for exponential smoothing algorithm.
virtual void RemoveKeyFrame(std::string strID)
Removes the key frame described by strID.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual void Deserialize(std::string &strXml)
Deserializes a string into an xml document.
CStdPtrMap< std::string, Organism > m_aryOrganisms
The base class for all of the joint type of objects.
float m_fltMouseSpringForceMagnitude
The magnitude of the force being applied by the mosue spring at each step.
virtual float LinearDamping()
Gets the linear damping of the simulation.
virtual IStdClassFactory * ClassFactory()
Gets the class factory.
bool m_bSetEndSim
true if we the user has manually set the simulation end time.
virtual void RemoveScript(std::string strID, bool bThrowError=true)
Removes the script based on ID.
virtual void Save(std::string strFilename)
Saves the simulation file.
long m_lSnapshotByteSize
Size of a memory snapshot in bytes.
bool m_bRobotAdpaterSynch
virtual DataChartMgr * GetDataChartMgr()
Gets the data chart manager.
KeyFrame * m_lpSimStopPoint
The pointer to a simulation stop point.
bool m_bPaused
true if the simulation is paused.
virtual void SaveVideo(std::string strPath)=0
Saves a video.
Base class file for all Animat simulation objects.
virtual float StabilityScale()
Sets the linear scaling factor that controls the simulation stability parameters. ...
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual std::string ExecutablePath()
Gets the directory path to the executable.
CStdPtrMap< std::string, Structure > m_aryStructures
Declares the nervous system class.
virtual float MassUnits()
Gets the mass units.
virtual bool EnableSimRecording()
Tells whehter simulation recording is enabled.
float m_fltAngularDamping
The angular damping of the simulation environment.
virtual float MouseSpringDamping()
Gets the mouse spring damping.
This class is derived from the ActivatedItemMgr and it handles all of the external stimuli...
virtual void RemoveSourceAdapter(Adapter *lpAdapter)
Removes a source adapter.
Declares the simulation recorder class.
float m_fltTotalMicroSleepTime
Total time we were in microsleep during playback pause calculations;.
virtual void RemoveFromObjectList(AnimatBase *lpItem)
Removes an object from the list of all simulation objects.
virtual float AngularKineticLoss()
Gets the angular kinetic loss of teh simulation.
virtual std::string TargetModule()
Gets the name of the target NeuralModule.
virtual Materials * GetMaterialMgr()
Gets the material manager.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
Simulator()
Default constructor.
Simulates the entire environment.
virtual void DisableCollision(RigidBody *lpBody)
Disables collision between the past-in object and this object.
virtual int VideoLoops()
Gets the video loops.
virtual bool FindChildElement(std::string strElementName, bool fThrowError=true)
Finds a child element by name.
virtual bool InSimulation()
Used to determine if we are running in a simulation, or in a real control mode.
virtual std::string SourceModule()
Gets the name of the source NeuralModule.
virtual KeyFrame * VideoPlayback()
Gets the video playback frame.
Root namespace for the base simulation library for AnimatLab.
short m_iPhysicsStepInterval
virtual void SimPausing()
Called just before the simulation pauses.
void Set(float R, float G, float B, float A)
Sets the color values.
virtual void ProcessSimulationStep()
Process the an entire step of the simulation. This includes the simulation portion, video and calculating timing.
virtual void EnableCollision(RigidBody *lpBody)
Enables collision between the past-in object and this object.
virtual void RemoveOrganism(std::string strID, bool bThrowError=true)
Removes an organism by its ID.
virtual float InverseMassUnits()
Gets the inverse mass units.
virtual void ResetSimulation()
Resets the simulation back to time 0.
float m_fltSimulationRealTimeToStep
virtual void StepNeuralEngine()
Step neural engine.
int m_iVideoLoops
Zero-based index of the video loops.
virtual IStdClassFactory * FindNeuralModuleFactory(std::string strModuleName, bool bThrowError=false)
Searches for the first neural module factory with the matching name.
bool m_bEnableSimRecording
true to enable simulation recording
virtual bool AddStimulus(std::string strXml)
Creates a new stimulus from an xml definition and adds it to the manager.
virtual float Gravity()
Gets the gravity value.
CStdMap< std::string, Organism * >::iterator m_oOrganismIterator
An organism iterator.
float m_fltPhysicsStepTime
This is the time pers step for the physics engine.
virtual void SimulateEnd()
Called at the end of the Simulate method.
Declares the body part class.
virtual RigidBody * FindRigidBody(std::string strStructureID, std::string strBodyID, bool bThrowError=true)
Finds a rigid body with the specified ID in the specified structure.
virtual std::string SimulationFile()
Gets the simulation filename.
ExternalStimuliMgr m_oExternalStimuliMgr
Manager for external stimuli.
float m_fltLinearCompliance
The linear compliance of the simulation environment.
CStdMap< std::string, Structure * > m_aryAllStructures
static void LoadAnimatModuleName(std::string strFile, std::string &strAnimatModule)
Loads an animat module name.
void Load(CStdXml &oXml, std::string strParamName, bool bThrowError=true)
Loads the color.
virtual ExternalStimuliMgr * GetExternalStimuliMgr()
Gets the external stimuli manager.
virtual long MillisecondToSlice(long lMillisecond)
Calculates the number of time slices from a supplied number of milliseconds.
bool m_bInitialized
true if the simulation has been initialized.
Organism * m_lpSelOrganism
The pointer to a selected organism.
int m_iDesiredFrameRate
Desired frame rate of the simulation video.
bool m_bInDrag
Tells if we are in the middle of a mouse drag operation to move or rotate a part. ...
virtual std::string Type()
returns the string type name of this object.
bool m_bManualStepSimulation
If true then the user is manually stepping the simulation.
virtual void Reset()
Resets this object.
virtual void MoveSimulationToKeyFrame(std::string strKeyFrameID)
Move simulation to key frame.
std::string m_strError
The error message.
float m_fltPlaybackAdditionRealTimeToStep
void Std_SplitPathAndFile(std::string &strFullPath, std::string &strPath, std::string &strFile)
Splits the path from the actual filename.
virtual bool FindElement(std::string strElementName, bool fThrowError=true)
Finds an element with the specified name.
float m_fltActualFrameRate
The frame rate for the current frame.
virtual void StopVideoPlayback()=0
Stop video playback.
virtual float PhysicsTimeStep()
Gets the integration time step for the physics engine.
virtual void UpdateBackgroundColor()
Updates the background color for all simulation windows.
virtual bool AutoGenerateRandomSeed()
Gets whether to automatically generate a random seed.
virtual short PhysicsStepInterval()
Gets the physics step interval.
virtual int FindFoodSourceIndex(RigidBody *lpFood)
Searches for the index of the food source.
virtual LightManager * GetLightMgr()
Gets the light manager.
virtual void StepVideoPlayback(int iFrameCount)=0
Step video playback.
virtual bool Paused()
Gets whether the Simulation is paused.
virtual bool Initialized()
Tells if the simulation has been initialized or not.
Information about the standard error.
virtual std::string ID()
Gets the unique GUID ID of this object.
virtual float LinearCompliance()
Gets the linear compliance of the simulation.
bool m_bAutoGenerateRandomSeed
virtual bool IntoElem()
Goes into the next element where the cursor is located.
virtual void RunSimulation()
Runs the simulation.
long m_lPhysicsSliceCount
The number of slices that the physics engine has been updated.
virtual float LinearKineticLoss()
Gets the linear kinetic loss of the simulation.
std::string m_strPart2ID
GUID ID of the second part of the collision pair.
virtual float PresetPlaybackTimeStep()
Gets the preset playback time step.
virtual float DesiredFrameStep()
Gets the frame step time.
virtual bool WaitForSimulationBlock(long lTimeout=6000)
Wait for simulation block.
bool m_bForceNoWindows
If this is set to true then no graphical simulation windows will be created regardless of what the co...
float m_fltDesiredFrameStep
The desired time value duration of the video frame step.
virtual float DenominatorDistanceUnits()
Gets the denominator distance units.
float m_fltInverseDistanceUnits
The inverse of the distance units.
virtual Structure * FindStructure(std::string strStructureID, bool bThrowError=true)
Searches for the first structure with the specified ID.
Class that stores information about types for QueryProperty information.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
virtual void TimeStepModified()
Notification method that the time step modified has been modified. Objects should recalculate any sli...
virtual Organism * FindOrganism(std::string strOrganismID, bool bThrowError=true)
Searches for the first organism with the specified ID.
virtual void LoadEnvironment(CStdXml &oXml)
Loads all structures from from the configuration file for this simulation.
virtual float MouseSpringForceMagnitude()
Gets the magnitude of the mouse spring force applied at each time step.
virtual bool RemoveStimulus(std::string strID)
Removes the stimulus described by strID.
float m_fltDataChartStepTime
time to process data charts for this step.
virtual bool PauseSimulation()=0
Pauses the simulation.
LightManager m_oLightMgr
Manager for the light objects.
static Simulator * CreateSimulator(std::string strAnimatModule, std::string strSimulationFile, bool bForceNoWindows=false)
Creates a simulator from a simulator file.
virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Loads a key frame snapshot.
virtual void Initialize()
Initializes this object.
virtual bool IsResetting()
Returns true if the simulation is in the process of resetting. False otherwise.
virtual void StartVideoPlayback()=0
Starts a video playback.
Declares the link base class.
virtual void StepSimulation()
Steps the entire simulation forward by one physics integration time step.
KeyFrame * m_lpVideoRecorder
The pointer to a video recorder.
Records the simulation keyframes and videos.
virtual void SimStarting()
Called just before the simulation starts.
virtual void InitializeStructures()
Initializes all of the structures of this simulation.
bool m_bShuttingDown
True if the simulation is shutting down. This is used by other objects in their destructor to know wh...
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
virtual float DistanceUnits()
Gets the distance units used in the simulation.
Declares the key frame class.
virtual void SaveVideo(std::string strPath)
Saves a video.
unsigned long long m_lStepSimEndTick
The tick count for when the simulation procressing of the step ends.
CStdArray< BodyPart * > m_aryExtraDataParts
virtual float AngularCompliance()
Gets the angular compliance of the simulation.
float m_fltDenominatorDistanceUnits
bool m_bSimBlockConfirm
true to confirm that a simulation block is in place.
int m_iSelectionMode
This is the currect visual selection mode used within the GUI.
ThreadProcessor * m_lpPhysicsThread
The pointer to the physics thread processor.
virtual CStdColor * BackgroundColor()
Gets the background color.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
float m_fltExternalStimuliStepTime
Time to process external stimuli for this step.
int m_iVideoStepSize
Size of the i video step.
virtual bool IsPhysicsBeingUpdated()
Query if this object is physics being updated on this time slice.
virtual int PlaybackControlMode()
Gets the playback control mode.
virtual bool ShuttingDown()
Tells whether the simulation is shutting down or not.
bool m_bSimulateHydrodynamics
bool m_bForceSimulationStop
Set to true to stop the simulation. This is a more forceful way of stopping the sim.
virtual void DisableCollision(RigidBody *lpBody)
Disables collision between the past-in body and all rigid bodies of the simulator.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
Declares the joint class.
virtual void AttachSourceAdapter(Adapter *lpAdapter)
Attaches a source adapter.
long m_lTimeSlice
The current time slice. This a long value.
virtual void RecordVideoFrame()
Record video frame.
static Simulator * CreateAndInitializeSimulator(std::string strSimFile, bool bForceNoWindows=false)
Creates a simulator from a specified file and initializes it.
CStdArray< RigidBody * > m_aryFoodSources
An Array of RigidBody parts that also act as food sources within the environment. ...
virtual void InitializeRandomNumbers()
Initializes the random number generation system.
Declares the organism class.
float m_fltAlphaThreshold
The threshold value to use when setting the AlphaFunc for the entire scene.
virtual void SimulateBegin()
Called at the beginning of the Simulate method.
virtual bool SimRunning()
Gets whether the simulation is running.
virtual int GetChildInt(std::string strElementName)
Gets an integer value from the element with the specified name.
virtual void EnableVideoPlayback(std::string strKeyFrameID)
Enables the video playback.
virtual void StopVideoPlayback()
Stop video playback.
virtual int VisualSelectionMode()
Gets the visual selection mode.
virtual long PhysicsSliceCount()
Gets the physics time slice count.
float m_fltTotalRealTimeForStep
This is the total time it takes to complete one physics time step.
float m_ftlMouseSpringDamping
The damping of the user mouse spring.
long m_lVideoStartSlice
The video start slice.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
std::string m_strID
The unique Id for this object.
virtual int GetMaterialID(std::string strID)
Gets a material identifier from the physics engine for the specified unique ID.
bool Std_DirectoryExists(std::string strPath)
Queries if a given directory exists.
virtual void StepVideoPlayback(int iFrameCount=1)
Step video playback.
virtual float PhysicsSubstepTime()
Gets the physics substep time.
bool m_bSimRunning
true if the simulation is running
std::string m_strProjectPath
The directory path where the simulation configuration files are located.
virtual bool AddDataChart(std::string strXml)
Adds a data chart to the manager.
static IStdClassFactory * LoadClassFactory(std::string strModuleName, bool bThrowError=true)
Loads the class factory specified in the DLL module name.
CStdMap< std::string, Structure * >::iterator m_oStructureIterator
A structure iterator.
virtual long PhysicsStepCount()
Gets the physics step count.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
virtual void NotifyTimeStepModified()
Notifies the objects that time step has been modified.
Declares the activated item class.
int Std_IRand(int low, int high)
Generates a random number between two values.
unsigned long long m_lLastTickTaken
This is the last tick taken by a GetTickCount. It is used in debugging.
virtual void AttachTargetAdapter(Adapter *lpAdapter)
Attaches a target adapter.
virtual float DisplayMassUnits()
Gets the density mass units.
virtual float TimeStep()
Gets the smallest integration time step used within the simulation.
float m_fltTotalMicroSleepCount
Total number of times we called microsleep during playback pause calculations.
SimulationWindowMgr * m_lpWinMgr
Manager for SimulationWindows.
virtual long SnapshotByteSize()
Gets the snapshot byte size.
virtual CStdSerialize * CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError=true)
Creates an object using a class factory.
virtual void BlockSimulation()
Blocks the simulation from stepping.
Declares a light manager object.
float m_fltStabilityScale
A linear scaling factor for setting the simulation parameters.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
virtual bool RobotAdpaterSynch()
Gets whether we need to synch the physics adapters in a simulation to the robot physics time step...
bool m_bStopSimulation
Set to true to stop the simulation.
float m_lEndSimTimeSlice
The time slice when the simulation should end.
virtual void AfterStepSimulation()
Method called for the base Simulator object to run code after the physics engine has been fully stepp...
virtual void Reset()
Resets this object.
Materials m_oMaterialMgr
Manager for Materials.
virtual Joint * FindJoint(std::string strStructureID, std::string strJointID, bool bThrowError=true)
Finds a joint with the specified ID in the specified structure.
bool m_bBlockSimulation
true to block simulation. See WaitForBlock for more info.
OdorType * LoadOdorType(CStdXml &oXml)
Loads an odor type.
float m_fltRemainingStepTime
Declares the bounding box class.
virtual long StartSlice()
Returns the starts slice for activation.
virtual float MouseSpringLengthMagnitude()
Gets the magnitude of the mouse spring length at each time step.
virtual long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
Manager for simulation windows.
Declares the gain base class.
virtual void LoadKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Loads a key frame snapshot.
virtual void Load(std::string strFilename)
Loads an xml data file.
CStdMap< std::string, AnimatBase * > m_aryObjectList
A list of all animatbase objects in the simulation.
virtual CStdFPoint GetCurrentPosition()
Gets the current position of this part.
float m_fltAngularCompliance
The angular compliance of the simulation environment.
virtual void Close()
Closes all windows.
virtual void ResetSimulation()
Resets the simulation back to time 0.
virtual long CalculateSnapshotByteSize()
Calculates the snapshot byte size.
virtual void Simulate()
Simulates the system.
A standard xml manipulation class.
float m_fltPhysicsSubstepTime
virtual int PhysicsSubsteps()
Gets the physics substeps.
Odor type that can be emitted from a RigidBody and sensed by an OdorSensor.
float m_fltEndSimTime
The time when the simulation should end.
virtual bool SimulationBlockConfirm()
Confirms that the simulation has been blocked.
A "static" structure in the simulation.
virtual ~Simulator()
Destructor.
virtual OdorType * FindOdorType(std::string strOdorID, bool bThrowError=true)
Searches for the first odor type with the specified ID.
virtual void StepSimulation()
Step the simulation for this object.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
float m_fltDisplayMassUnits
Tells how many kilograms/m^3 each unit of density is worth within the simulation environment.
virtual CStdMap< std::string, AnimatBase * > * ObjectList()
Gets the list of pointers to all objects in the simulation.
DataChartMgr m_oDataChartMgr
Manager for data charts.
virtual ISimGUICallback * SimCallback()
Calback object from the simulation.
virtual void Reset()
Resets this manager.
int m_iTargetAdapterCount
Number of target adapters.
virtual ScriptProcessor * LoadScript(CStdXml &oXml)
Loads the script.
virtual void DisableCollision(RigidBody *lpCollisionBody)
Disables collision between the past-in object and all rigid bodies of this structure.
CStdPtrMap< std::string, OdorType > m_aryOdorTypes
float m_fltTotalMicroWaitCount
Total number of loop iterations for microwait during playback pause calculations. ...
virtual void ResetSimulationTimingParams()
Resets the variables that are used to keep track of the time that each component of the time step tak...
CStdMap< std::string, IStdClassFactory * > m_aryNeuralModuleFactories
virtual void RemoveTargetAdapter(Adapter *lpAdapter)
Removes a target adapter.
int m_iPlaybackControlMode
Determines the mode used for playback control. See the accessor method for more details.
float m_fltLinearDamping
The linear damping of the simulation environment.
virtual std::string ProjectPath()
Gets the project path.
KeyFrame * m_lpVideoPlayback
The pointer to a video playback.
void r(float fltR, bool bThrowError=true)
Sets the red value of the color.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
Base class for all body parts and joints.
virtual bool RemoveDataChart(std::string strID)
Removes the data chart described by ID.
virtual bool SetEndSimTime()
Gets whether to use the set simulation end time.
float m_fltMouseSpringLengthMagnitude
The magnitude of the length of the mouse spring at each step.
Keeps track of all of the materials and the various material pair interaction parameters for the enti...
float m_fltSimRecorderStepTime
Time to process simulation recorder for this step.
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
ISimGUICallback * m_lpSimCallback
virtual Joint * FindJoint(std::string strJointID, bool bThrowError=true)
Finds a joint with a specified ID within this structure.
virtual AnimatBase * FindByID(std::string strID, bool bThrowError=true)
Searches for the object with the specified ID.
float m_fltGravity
The acceleration of gravity to use in the simulation.
unsigned long long m_lVideoFrameStartTick
The tick when a new video frame time starts.
SimulationRecorder * m_lpSimRecorder
The pointer to a simulation recorder.
virtual void GenerateAutoSeed()
Generates an automatic seed value based on the current time.
virtual void ResetSimulation()
Resets the the simulation to its orginal settings at time 0.
virtual CStdSerialize * CreateObject(std::string strClassType, std::string strObjectType, bool bThrowError=true)=0
Creates an object of the specified class and object types.
virtual void DisableVideoPlayback()
Disables the video playback.
Structure * m_lpSelStructure
The pointer to a selected structure.
float ConvertDisplayMassUnits(std::string strUnits)
Convert the string ID of the display units to a conversion factor.
virtual bool SimulateHydrodynamics()
Gets whether the simulation uses hydrodynamics.
virtual void CloseAllWindows()
Closes all windows internally.
virtual void AddOrganism(Organism *lpOrganism)
Adds a new organism to the list of structures for this simulation.
bool Std_ToBool(int iVal)
Converts a value toa bool.
virtual void EnableCollision(RigidBody *lpCollisionBody)
Enables collision between the past-in object and all rigid bodies of this structure.
virtual void StepPhysicsEngine()
Allows the organism and its parts to update at each time slice.
virtual void Load(StdUtils::CStdXml &oXml)
Loads the item using an XML data packet.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
virtual bool GetChildBool(std::string strElementName)
Gets a bool value from the element with the specified name.
virtual KeyFrame * VideoRecorder()
Gets the video recorder.
virtual bool CheckSimulationBlock()
Checks whether or not a simulation block has been requested.
void Std_SRand(unsigned long lSeed)
Sets the seed for generating a random number.
virtual float MouseSpringDampingForceMagnitude()
Gets the magnitude of the mouse spring damping force applied at each time step.
bool m_bIsResetting
True if we are in the process of resetting the simulation. False otherwise.
virtual SimulationWindowMgr * GetWindowMgr()
Gets the window manager.
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...
virtual SimulationRecorder * CreateSimulationRecorder()=0
Creates the simulation recorder.
long m_lStepTimeCount
This is a temp variable for measuring sim time for a set period for each simulation.
virtual void StepPhysicsEngine()
Calls StepPhysicsEngine of all structures.
virtual void Load(std::string strFileName="")
Loads the simulation from an xml configuration file.
virtual void Reset()
Resets all objects of the simulation to their unloaded state.
long m_lVideoSliceCount
Current video slice time slice.
virtual ActivatedItem * Find(std::string strID, int &iIndex, bool bThrowError)
Searches for an item with the specified ID and sets its index in the array.
std::string Std_ToLower(std::string strVal)
Converts a string to lower case.
virtual float MouseSpringStiffness()
Gets the mouse spring stiffness.
float ConvertDistanceUnits(std::string strUnits)
Convert the string ID of the distance units to a conversion factor.
float m_fltVideoRecordFrameTime
Time of the video record frame.
std::string Std_ExecutablePath()
Finds the name and path of the current executable.
virtual void SimCallBack(ISimGUICallback *lpCallback)
Sets the calback object from the simulation.
std::string m_strExecutablePath
The directory path where the executable is located.
float ConvertMassUnits(std::string strUnits)
Convert the string ID of the mass units to a conversion factor.
virtual int NumberOfChildren()
Gets the number of children of the current element.
A dynamic organism that is controlled by a neural network.
CStdArray< Adapter * > m_aryTargetPhysicsAdapters
Array of target physics adapters.
ThreadProcessor * m_lpNeuralThread
The pointer to a neural thread processor.
virtual void AddStructure(Structure *lpStructure)
Adds a new "static" structure to the list of structures for this simulation.
Organism * LoadOrganism(CStdXml &oXml)
Loads an organism.
virtual void EnableCollision(RigidBody *lpBody)
Enables collision between the past-in body and all rigid bodies of the simulator. ...
virtual long EndSlice()
Gets the end time slice for deactivation.
bool m_bForceFastMoving
true if we need to set the physics system to force handling of fast moving objects.
float m_fltVideoStartTime
Time of the video start.
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
float m_fltDistanceUnits
Tells how many meters each unit of distance is worth within the simulation environment.
virtual void StepNeuralEngine()
Step the neural engine of each organism.
float m_fltPrevPhysicsStepTime
int m_iVideoStep
Zero-based index of the video step.
bool m_bSteppingSim
true if stepping of simulation has begun. This is set to true once the Simulate methods has been call...
virtual float RealTime()
Returns the real time since the simulation was started.
virtual bool RemoveItem(const std::string &strItemType, const std::string &strID, bool bThrowError=true)
Removes a child item from this parent.
unsigned long long m_lStartSimTick
The tick count for when the simulation first begins running.
bool m_bAddBodiesMode
true if the AddBodies mode is enabled within the GUI.
virtual void Initialize()
Initializes this object.
virtual void Initialize()
Initializes this object with no argc/argv params.
virtual void MakeCurrentFrame()=0
Makes the current frame.
virtual void Initialize(int argc, const char **argv)=0
Initializes this object.
virtual bool Stopped()
Tells if the simulation has been stopped.
virtual Structure * FindStructureFromAll(std::string strStructureID, bool bThrowError=true)
Searches for the first structure with the specified ID.
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
Declares the data chart manager class.
virtual void ShutdownSimulation()=0
Shuts down the simulation.
long m_lVideoEndSlice
The video end slice.
float m_fltRealTime
This keeps track of the real time from the begginning of the simulation.
float m_fltTotalNeuralStepTime
Total time for processing of all neural items for this step.
virtual void Step()
Steps the simulation forward by one time slice.
CStdArray< Adapter * > m_arySourcePhysicsAdapters
Array of source physics adapters.
std::string m_strPart1ID
GUID ID of the first part of the collision pair.
virtual void SimPausing()
Simulation pausing event.
Declares the rigid body class.
float m_fltVideoPlaybackFrameTime
Time of the video playback frame.
ThreadProcessor * m_lpIOThread
The pointer to an i/o thread processor.
virtual unsigned long long StartSimTick()
The time slice tick at which the simulation start.
virtual bool IntoChildElement(std::string strElementName, bool bThrowError=true)
Goes into the child element with the specified name.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void HandleCriticalError(std::string strError)=0
Handle critical-errors in the GUI. A critical error will report the error and then shut the entire ap...
virtual void SimStopping()
Called just before the simulation stops.
std::string m_strSimulationFile
The name of the Animat Simulation (ASIM) file.
bool m_bRecordVideo
true to record video
double m_dblTotalStepTime
This is a temp variable for measuring sim time for a set period for each simulation.
virtual void AddScript(std::string strXml)
Creates and adds a scripting object to this structure.
float m_fltTime
The current simulation time.
virtual void Remove(std::string strID, bool bThrowError=true)
Removes the item with the specified ID.
virtual int ManualRandomSeed()
Gets the manual random seed value.
virtual long TimeSlice()
Gets the current time slice.
Declares the structure class.
virtual bool ManualStepSimulation()
Gets whether the simulation is being stepped manually by the user.
std::string m_strVideoFilename
Filename of the video file.
bool Std_IsFullPath(std::string strPath)
determines if this is a full path name.
virtual void CheckEndSimulationTime()
Checks the simulation end time.
virtual void VisualSelectionModeChanged(int iNewMode)
Visual selection mode changed.
Declares the odor type class.
float m_fltVideoEndTime
Time of the video end.
virtual void Add(ActivatedItem *lpItem)
Adds a new ActivatedItem to be managed.
virtual void RemoveStructure(std::string strID, bool bThrowError=true)
Removes a structure by its ID.
unsigned long long m_lStepStartTick
This is the tick count that is taken when a step is started.
virtual long Millisecond()
Gets the current simulation time in millisecond.
Standard serialize class.
virtual long SliceToMillisecond(long lSlice)
Calculates the number of milliseconds from a supplied number of time slices.
virtual void SimStopping()
Simulation stopping event.
float m_fltAngularKineticLoss
The angular kinetic loss of the simulation environment.
float m_fltMassUnits
Tells how many kilograms each unit of mass is worth within the simulation environment.
virtual void NeedToStopSimulation()=0
Callback to inform that GUI that the currently running simulation needs to be stopped.
float m_fltRecFieldSelRadius
virtual float AngularDamping()
Gets the angular damping of the simulation.
bool Std_FileExists(std::string strFullPath)
Finds if a given file exists.
virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError=true)
Set a variable based on a string data type name.
virtual float InverseDistanceUnits()
Gets the inverse distance units.
virtual void StartVideoPlayback()
Starts a video playback.
virtual NeuralModule * FindNeuralModule(std::string strModuleName, bool bThrowError=true)
Searches for a neural module with a matching module name.
float m_fltTotalMicroWaitTime
Total time we were in microwait during playback pause calculations;.
virtual void DisableVideoPlayback()=0
Disables the video playback.
virtual void QueryProperties(CStdPtrArray< TypeProperty > &aryProperties)
Queries this object for a list of properties that can be changed using SetData.
void g(float fltG, bool bThrowError=true)
Sets the green value of the color.
float m_fltLinearKineticLoss
The linear kinetic loss of the simulation environment.
float ConvertDenominatorDistanceUnits(std::string strUnits)
Convert the string ID of the distance units to a conversion factor for the denominator of the distanc...
virtual void EnableVideoPlayback()=0
Enables the video playback.
Declares the simulator class.
float m_fltTotalRealTimeForStepSmooth
Current value of the exponential smoothing algorith for real time step.
Declares the neural module class.
virtual bool FindChildByIndex(int iIndex, bool bThrowError=true)
Finds a child element by index.
virtual void HandleNonCriticalError(std::string strError)=0
Handle a non-critical error in the GUI. Non-critical errors are simply reported and the simulation st...
float m_fltInverseMassUnits
The inverse of the mass units.
virtual float Time()
Gets the current simulation time in seconds.
virtual std::string MoveKeyFrame(std::string strID, long lStart, long lEnd)
Move key frame.
virtual bool ForceFastMoving()
Gets whether we have set the simulation to force fast moving calculations.
int m_iExtraDataCount
Number of parts that require extra data to be collected.
virtual void SimStarting()
Simulation starting event.
Declares the activated item manager class.
virtual bool AddBodiesMode()
Gets the Adds bodies mode.
float m_fltPhysicsTimeStep
The time increment for each time slice of the physics simulation.
void Std_SetLogFilePrefix(std::string strFilePrefix)
Sets the log file prefix.
Structure * LoadStructure(CStdXml &oXml)
Loads a structure.
virtual void SaveKeyFrameSnapshot(byte *aryBytes, long &lIndex)
Saves a key frame snapshot.
Declares the external stimuli manager class.
float m_fltPresetPlaybackTimeStep
virtual void UnblockSimulation()
Unblock simulation.
virtual RigidBody * FindRigidBody(std::string strBodyID, bool bThrowError=true)
Finds a rigid body with a specified ID within this structure.
float m_fltMouseSpringDampingForceMagnitude
The magnitude of the damping component of the force being applied by the mosue spring at each step...
virtual void AddToObjectList(AnimatBase *lpItem)
Adds an object to the list of all simulation objects.
virtual bool AddItem(const std::string &strItemType, const std::string &strXml, bool bThrowError=true, bool bDoNotInit=false)
Adds a new object to this parent.
void a(float fltA, bool bThrowError=true)
Sets the alpha value of the color.
virtual SimulationRecorder * GetSimulationRecorder()
Gets the simulation recorder.
The base class for all of the basic rigid body type of objects.
Declares the receptive field class.
double Std_CalculateDistance(CStdIPoint &ptA, CStdIPoint &ptB)
Calculates the distance between two points.
virtual int DesiredFrameRate()
Gets the frame rate used for the simulation windows in cylces per second.
std::string m_strName
The name for this object.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
virtual long VideoSliceCount()
Gets the video slice count.
IStdClassFactory * m_lpAnimatClassFactory
virtual long EndSimTimeSlice()
Gets the time slice at which to automatically end the simulation.
virtual std::string AddKeyFrame(std::string strType, long lStart, long lEnd)
Adds a key frame.
float m_fltMouseSpringStiffness
The stiffness of the user mouse spring.
virtual float EndSimTime()
Gets the time at which to automatically end the simulation.
void b(float fltB, bool bThrowError=true)
Sets the blue value of the color.
CStdColor m_vBackgroundColor
The background color to use when drawing the environment.