DART
6.7.3
|
#include <RealTimeWorldNode.hpp>
Public Member Functions | |
RealTimeWorldNode (const std::shared_ptr< dart::simulation::World > &world=nullptr, const ::osg::ref_ptr< osgShadow::ShadowTechnique > &shadower=nullptr, double targetFrequency=60.0, double targetRealTimeFactor=1.0) | |
Construct a world node that will attempt to run a simulation with close to real-time playback. More... | |
void | setTargetFrequency (double targetFrequency) |
Set the target refresh rate frequency. More... | |
double | getTargetFrequency () const |
Get the target refresh rate frequency. More... | |
void | setTargetRealTimeFactor (double targetRTF) |
Set the target real time factor. More... | |
double | getTargetRealTimeFactor () const |
Get the target real time factor. More... | |
double | getLastRealTimeFactor () const |
Get the real time factor that was achieved in the last refresh cycle. More... | |
double | getLowestRealTimeFactor () const |
Get the lowest real time factor that has been hit during the simulation. More... | |
double | getHighestRealTimeFactor () const |
Get the highest real time factor that has been hit during the simulation. More... | |
void | setRealTimeFactorDisplay (bool on) |
Turn the text displaying the real time factor on or off. More... | |
void | refresh () override |
This function is called at the beginning of each rendering cycle. More... | |
void | setWorld (std::shared_ptr< dart::simulation::World > newWorld) |
Set the World that this WorldNode is associated with. More... | |
std::shared_ptr< dart::simulation::World > | getWorld () const |
Get the World that this WorldNode is associated with. More... | |
virtual void | customPreRefresh () |
If update() is not overloaded, this function will be called at the beginning of each rendering cycle. More... | |
virtual void | customPostRefresh () |
If update() is not overloaded, this function will be called at the end of each rendering cycle. More... | |
virtual void | customPreStep () |
If update() is not overloaded, this function will be called at the beginning of each simulation step. More... | |
virtual void | customPostStep () |
If update() is not overloaded, this function will be called at the end of each simulation step. More... | |
bool | isSimulating () const |
Returns true iff the WorldNode is stepping between render cycles. More... | |
void | simulate (bool on) |
Pass in true to take steps between render cycles; pass in false to turn off steps between render cycles. More... | |
void | setNumStepsPerCycle (std::size_t steps) |
Set the number of steps to take between each render cycle (only if the simulation is not paused) More... | |
std::size_t | getNumStepsPerCycle () const |
Get the number of steps that will be taken between each render cycle (only if the simulation is not paused) More... | |
bool | isShadowed () const |
Get whether the WorldNode is casting shadows. More... | |
void | setShadowTechnique (::osg::ref_ptr< osgShadow::ShadowTechnique > shadowTechnique=nullptr) |
Set the ShadowTechnique If you wish to disable shadows, pass a nullptr. More... | |
::osg::ref_ptr< osgShadow::ShadowTechnique > | getShadowTechnique () const |
Get the current ShadowTechnique nullptr is there are no shadows. More... | |
static ::osg::ref_ptr< osgShadow::ShadowTechnique > | createDefaultShadowTechnique (const Viewer *viewer) |
Helper function to create a default ShadowTechnique given a Viewer the default ShadowTechnique is ShadowMap. More... | |
Protected Types | |
using | NodeMap = std::unordered_map< dart::dynamics::Frame *, ShapeFrameNode * > |
Protected Member Functions | |
virtual void | setupViewer () |
Called when this world gets added to an dart::gui::osg::Viewer. More... | |
void | clearChildUtilizationFlags () |
Clear the utilization flags of each child node. More... | |
void | clearUnusedNodes () |
Clear any nodes whose utilization flags were not triggered on this render cycle. More... | |
void | refreshSkeletons () |
Refresh all the Skeleton rendering data. More... | |
void | refreshSimpleFrames () |
Refresh all the custom Frame rendering data. More... | |
void | refreshBaseFrameNode (dart::dynamics::Frame *frame) |
void | refreshShapeFrameNode (dart::dynamics::Frame *frame) |
Protected Attributes | |
bool | mFirstRefresh |
Reset each time the simulation is paused. More... | |
::osg::Timer | mRefreshTimer |
Keeps track of the time between refreshes. More... | |
double | mTargetRealTimeLapse |
The target for how much time should elapse between refreshes. More... | |
double | mTargetSimTimeLapse |
The target for how much simulation time should elapse between refreshes. More... | |
double | mLastRealTimeFactor |
The RTF that was achieved in the last refresh cycle. More... | |
double | mLowestRealTimeFactor |
The lowest RTF that has been achieved. More... | |
double | mHighestRealTimeFactor |
The highest RTF that has been achieved. More... | |
NodeMap | mFrameToNode |
Map from Frame pointers to FrameNode pointers. More... | |
std::shared_ptr< dart::simulation::World > | mWorld |
The World that this WorldNode is associated with. More... | |
bool | mSimulating |
True iff simulation is active. More... | |
std::size_t | mNumStepsPerCycle |
Number of steps to take between rendering cycles. More... | |
Viewer * | mViewer |
Viewer that this WorldNode is inside of. More... | |
::osg::ref_ptr<::osg::Group > | mNormalGroup |
OSG group for non-shadowed objects. More... | |
::osg::ref_ptr<::osg::Group > | mShadowedGroup |
OSG group for shadowed objects. More... | |
bool | mShadowed |
Whether the shadows are enabled. More... | |
|
protectedinherited |
dart::gui::osg::RealTimeWorldNode::RealTimeWorldNode | ( | const std::shared_ptr< dart::simulation::World > & | world = nullptr , |
const ::osg::ref_ptr< osgShadow::ShadowTechnique > & | shadower = nullptr , |
||
double | targetFrequency = 60.0 , |
||
double | targetRealTimeFactor = 1.0 |
||
) |
Construct a world node that will attempt to run a simulation with close to real-time playback.
If a simulation is too computationally expensive, the simulation might not be able to keep up with real time.
[in] | world | The world to simulate |
[in] | targetFrequency | The expected refresh rate. The actual refresh rate may depend on your monitor and your computer's display settings. |
[in] | targetRealTimeFactor | This factor at which the simulation should run. A value of 1.0 (default) means it will try to run at real time. A value 2.0 means the simulation will try to run at double real time speed (fast-forward). A value of 0.5 means the simulation will try to run at half of real-time speed (slowed down). |
[in] | shadowTech | The shading technique to use when rendering this world. |
|
protectedinherited |
Clear the utilization flags of each child node.
|
protectedinherited |
Clear any nodes whose utilization flags were not triggered on this render cycle.
|
inherited |
Helper function to create a default ShadowTechnique given a Viewer the default ShadowTechnique is ShadowMap.
|
virtualinherited |
If update() is not overloaded, this function will be called at the end of each rendering cycle.
This function can be overloaded to customize the behavior of each update. The default behavior is to do nothing, so overloading this function will not interfere with the usual update() operation.
|
virtualinherited |
If update() is not overloaded, this function will be called at the end of each simulation step.
This function can be overloaded to customize the behavior of each step. The default behavior is to do nothing, so overloading this function will not interfere with the usual update() operation. This will not get called if the simulation is paused.
|
virtualinherited |
If update() is not overloaded, this function will be called at the beginning of each rendering cycle.
This function can be overloaded to customize the behavior of each update. The default behavior is to do nothing, so overloading this function will not interfere with the usual update() operation.
|
virtualinherited |
If update() is not overloaded, this function will be called at the beginning of each simulation step.
This function can be overloaded to customize the behavior of each step. The default behavior is to do nothing, so overloading this function will not interfere with the usual update() operation. This will not get called if the simulation is paused.
double dart::gui::osg::RealTimeWorldNode::getHighestRealTimeFactor | ( | ) | const |
Get the highest real time factor that has been hit during the simulation.
double dart::gui::osg::RealTimeWorldNode::getLastRealTimeFactor | ( | ) | const |
Get the real time factor that was achieved in the last refresh cycle.
This may be smaller than target real time factor, because the simulation may not have had time to reach it.
double dart::gui::osg::RealTimeWorldNode::getLowestRealTimeFactor | ( | ) | const |
Get the lowest real time factor that has been hit during the simulation.
|
inherited |
Get the number of steps that will be taken between each render cycle (only if the simulation is not paused)
|
inherited |
Get the current ShadowTechnique nullptr is there are no shadows.
double dart::gui::osg::RealTimeWorldNode::getTargetFrequency | ( | ) | const |
Get the target refresh rate frequency.
double dart::gui::osg::RealTimeWorldNode::getTargetRealTimeFactor | ( | ) | const |
Get the target real time factor.
|
inherited |
Get the World that this WorldNode is associated with.
|
inherited |
Get whether the WorldNode is casting shadows.
|
inherited |
Returns true iff the WorldNode is stepping between render cycles.
|
overridevirtual |
This function is called at the beginning of each rendering cycle.
It updates the tree of Frames and Entities that need to be rendered. It may also take a simulation step if the simulation is not paused.
If you want to customize what happens at the beginning of each rendering cycle, you can either overload this function, or you can overload customUpdate(). This update() function will automatically call customUpdate() at the beginning of each rendering cycle. By default, customUpdate() does nothing.
Reimplemented from dart::gui::osg::WorldNode.
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
Refresh all the custom Frame rendering data.
|
protectedinherited |
Refresh all the Skeleton rendering data.
|
inherited |
Set the number of steps to take between each render cycle (only if the simulation is not paused)
void dart::gui::osg::RealTimeWorldNode::setRealTimeFactorDisplay | ( | bool | on | ) |
Turn the text displaying the real time factor on or off.
|
inherited |
Set the ShadowTechnique If you wish to disable shadows, pass a nullptr.
void dart::gui::osg::RealTimeWorldNode::setTargetFrequency | ( | double | targetFrequency | ) |
Set the target refresh rate frequency.
void dart::gui::osg::RealTimeWorldNode::setTargetRealTimeFactor | ( | double | targetRTF | ) |
Set the target real time factor.
|
protectedvirtualinherited |
Called when this world gets added to an dart::gui::osg::Viewer.
Override this function to customize the way your WorldNode starts up in an dart::gui::osg::Viewer. Default behavior does nothing.
|
inherited |
Set the World that this WorldNode is associated with.
|
inherited |
Pass in true to take steps between render cycles; pass in false to turn off steps between render cycles.
|
protected |
Reset each time the simulation is paused.
|
protectedinherited |
Map from Frame pointers to FrameNode pointers.
|
protected |
The highest RTF that has been achieved.
|
protected |
The RTF that was achieved in the last refresh cycle.
|
protected |
The lowest RTF that has been achieved.
|
protectedinherited |
OSG group for non-shadowed objects.
|
protectedinherited |
Number of steps to take between rendering cycles.
|
protected |
Keeps track of the time between refreshes.
|
protectedinherited |
Whether the shadows are enabled.
|
protectedinherited |
OSG group for shadowed objects.
|
protectedinherited |
True iff simulation is active.
|
protected |
The target for how much time should elapse between refreshes.
|
protected |
The target for how much simulation time should elapse between refreshes.
|
protectedinherited |
|
protectedinherited |
The World that this WorldNode is associated with.