7 #include <osgUtil/Version>
9 #include "OsgMovableItem.h"
12 #include "OsgSimulator.h"
14 #include "OsgMouseSpring.h"
16 #include "OsgCameraManipulator.h"
17 #include "OsgDragger.h"
18 #include "OsgMeshMinVertexDistanceVisitor.h"
19 #include "OsgSimulator.h"
29 OsgSimulator::OsgSimulator()
36 m_dblTotalStepTime = 0;
38 m_dblTotalStepTime= 0;
41 m_osgAlphafunc = NULL;
43 m_lpMouseSpring->Initialize();
44 m_lpMatrixUtil = NULL;
47 OsgSimulator::~OsgSimulator()
61 delete m_lpMouseSpring;
64 delete m_lpMatrixUtil;
69 {
Std_TraceMsg(0,
"Caught Error in desctructor of Simulator\r\n",
"", -1,
false,
true);}
72 void OsgSimulator::AlphaThreshold(
float fltValue)
74 Simulator::AlphaThreshold(fltValue);
84 if(m_osgCmdMgr.valid())
85 m_osgCmdMgr.release();
114 osg::NotifySeverity OsgSimulator::ConvertTraceLevelToOSG()
121 return osg::NotifySeverity::FATAL;
123 return osg::NotifySeverity::WARN;
125 return osg::NotifySeverity::INFO;
127 return osg::NotifySeverity::DEBUG_INFO;
129 return osg::NotifySeverity::DEBUG_FP;
131 return osg::NotifySeverity::WARN;
136 unsigned long long OsgSimulator::GetTimerTick()
142 double OsgSimulator::TimerDiff_n(
unsigned long long lStart,
unsigned long long lEnd)
143 {
return osg::Timer::instance()->delta_n(lStart, lEnd);}
145 double OsgSimulator::TimerDiff_u(
unsigned long long lStart,
unsigned long long lEnd)
146 {
return osg::Timer::instance()->delta_u(lStart, lEnd);}
148 double OsgSimulator::TimerDiff_m(
unsigned long long lStart,
unsigned long long lEnd)
149 {
return osg::Timer::instance()->delta_m(lStart, lEnd);}
151 double OsgSimulator::TimerDiff_s(
unsigned long long lStart,
unsigned long long lEnd)
152 {
return osg::Timer::instance()->delta_s(lStart, lEnd);}
154 void OsgSimulator::MicroSleep(
unsigned int iMicroTime)
155 {OpenThreads::Thread::microSleep(iMicroTime);}
157 void OsgSimulator::WriteToConsole(std::string strMessage)
159 osg::notify(osg::NOTICE) << strMessage << std::endl;
165 std::string strVersion = osgUtilGetVersion();
166 strVersion =
"/usr/lib/osgPlugins-" + strVersion;
167 osgDB::setLibraryFilePathList(strVersion);
180 void OsgSimulator::UpdateSimulationWindows()
217 lpData = Simulator::GetDataPointer(strDataType);
219 THROW_TEXT_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType,
"Simulator DataType: " + strDataType);
230 THROW_TEXT_ERROR(Al_Err_lConvertingClassToType, Al_Err_strConvertingClassToType,
"KeyFrame");
237 OsgSimulator *OsgSimulator::ConvertSimulator(Simulator *lpSim)
240 THROW_ERROR(Al_Err_lSimulationNotDefined, Al_Err_strSimulationNotDefined);
245 THROW_ERROR(Osg_Err_lUnableToConvertToVsSimulator, Osg_Err_strUnableToConvertToVsSimulator);
252 std::string strOsgFile = strFile +
".osg";
254 osgDB::writeNodeFile(*OSGRoot(), strOsgFile.c_str());
virtual void StopSimulation()
Stops the simulation and resets it.
KeyFrame * m_lpSimStopPoint
The pointer to a simulation stop point.
bool m_bPaused
true if the simulation is paused.
virtual void ShutdownSimulation()
Shuts down the simulation.
virtual void Realize()
Shows the windows.
virtual void SetSystemPointers(Simulator *lpSim, Structure *lpStructure, NeuralModule *lpModule, Node *lpNode, bool bVerify)
Sets the system pointers.
ExternalStimuliMgr m_oExternalStimuliMgr
Manager for external stimuli.
virtual bool PauseSimulation()
Pauses the simulation.
Declares the vortex Light class.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
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...
bool m_bForceSimulationStop
Set to true to stop the simulation. This is a more forceful way of stopping the sim.
long m_lTimeSlice
The current time slice. This a long value.
float m_fltAlphaThreshold
The threshold value to use when setting the AlphaFunc for the entire scene.
bool m_bSimRunning
true if the simulation is running
unsigned long long m_lLastTickTaken
This is the last tick taken by a GetTickCount. It is used in debugging.
SimulationWindowMgr * m_lpWinMgr
Manager for SimulationWindows.
virtual CStdSerialize * CreateObject(std::string strModule, std::string strClassName, std::string strType, bool bThrowError=true)
Creates an object using a class factory.
bool m_bStopSimulation
Set to true to stop the simulation.
virtual void SnapshotStopFrame()
Takes a snapshot of the current frame.
DataChartMgr m_oDataChartMgr
Manager for data charts.
int Std_GetTraceLevel()
Gets the trace level.
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
SimulationRecorder * m_lpSimRecorder
The pointer to a simulation recorder.
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 Reset()
Resets all objects of the simulation to their unloaded state.
Declares the vortex organism class.
unsigned long long m_lStartSimTick
The tick count for when the simulation first begins running.
virtual void Initialize()
Initializes this object with no argc/argv params.
virtual void SimPausing()
Simulation pausing event.
virtual bool Update()
Updates all of the windows.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
virtual void SimStopping()
Simulation stopping event.
Declares the vortex structure class.
virtual void SimStarting()
Simulation starting event.
virtual bool StartSimulation()
Starts the simulation.
virtual void Save(std::string strFile)
Saves the simulation file.
virtual void ToggleSimulation()
Toggles the simulation between running and paused.