DART  6.6.2
dart::gui::osg::WorldNode Class Reference

WorldNode class encapsulates a World to be displayed in OpenSceneGraph. More...

#include <WorldNode.hpp>

Inheritance diagram for dart::gui::osg::WorldNode:

Public Member Functions

 WorldNode (std::shared_ptr< dart::simulation::World > world=nullptr, ::osg::ref_ptr< osgShadow::ShadowTechnique > shadowTechnique=nullptr)
 Default constructor Shadows are disabled by default. 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::WorldgetWorld () const
 Get the World that this WorldNode is associated with. More...
 
virtual void refresh ()
 This function is called at the beginning of each rendering cycle. 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 ~WorldNode ()
 Destructor. More...
 
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

NodeMap mFrameToNode
 Map from Frame pointers to FrameNode pointers. More...
 
std::shared_ptr< dart::simulation::WorldmWorld
 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...
 
ViewermViewer
 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...
 

Friends

class Viewer
 

Detailed Description

WorldNode class encapsulates a World to be displayed in OpenSceneGraph.

Member Typedef Documentation

◆ NodeMap

Constructor & Destructor Documentation

◆ WorldNode()

dart::gui::osg::WorldNode::WorldNode ( std::shared_ptr< dart::simulation::World world = nullptr,
::osg::ref_ptr< osgShadow::ShadowTechnique >  shadowTechnique = nullptr 
)
explicit

Default constructor Shadows are disabled by default.

◆ ~WorldNode()

dart::gui::osg::WorldNode::~WorldNode ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ clearChildUtilizationFlags()

void dart::gui::osg::WorldNode::clearChildUtilizationFlags ( )
protected

Clear the utilization flags of each child node.

◆ clearUnusedNodes()

void dart::gui::osg::WorldNode::clearUnusedNodes ( )
protected

Clear any nodes whose utilization flags were not triggered on this render cycle.

◆ createDefaultShadowTechnique()

osg::ref_ptr< osgShadow::ShadowTechnique > dart::gui::osg::WorldNode::createDefaultShadowTechnique ( const Viewer viewer)

Helper function to create a default ShadowTechnique given a Viewer the default ShadowTechnique is ShadowMap.

◆ customPostRefresh()

void dart::gui::osg::WorldNode::customPostRefresh ( )
virtual

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.

◆ customPostStep()

void dart::gui::osg::WorldNode::customPostStep ( )
virtual

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.

◆ customPreRefresh()

void dart::gui::osg::WorldNode::customPreRefresh ( )
virtual

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.

◆ customPreStep()

void dart::gui::osg::WorldNode::customPreStep ( )
virtual

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.

◆ getNumStepsPerCycle()

std::size_t dart::gui::osg::WorldNode::getNumStepsPerCycle ( ) const

Get the number of steps that will be taken between each render cycle (only if the simulation is not paused)

◆ getShadowTechnique()

osg::ref_ptr< osgShadow::ShadowTechnique > dart::gui::osg::WorldNode::getShadowTechnique ( ) const

Get the current ShadowTechnique nullptr is there are no shadows.

◆ getWorld()

std::shared_ptr< dart::simulation::World > dart::gui::osg::WorldNode::getWorld ( ) const

Get the World that this WorldNode is associated with.

◆ isShadowed()

bool dart::gui::osg::WorldNode::isShadowed ( ) const

Get whether the WorldNode is casting shadows.

◆ isSimulating()

bool dart::gui::osg::WorldNode::isSimulating ( ) const

Returns true iff the WorldNode is stepping between render cycles.

◆ refresh()

void dart::gui::osg::WorldNode::refresh ( )
virtual

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.

◆ refreshBaseFrameNode()

void dart::gui::osg::WorldNode::refreshBaseFrameNode ( dart::dynamics::Frame frame)
protected

◆ refreshShapeFrameNode()

void dart::gui::osg::WorldNode::refreshShapeFrameNode ( dart::dynamics::Frame frame)
protected

◆ refreshSimpleFrames()

void dart::gui::osg::WorldNode::refreshSimpleFrames ( )
protected

Refresh all the custom Frame rendering data.

◆ refreshSkeletons()

void dart::gui::osg::WorldNode::refreshSkeletons ( )
protected

Refresh all the Skeleton rendering data.

◆ setNumStepsPerCycle()

void dart::gui::osg::WorldNode::setNumStepsPerCycle ( std::size_t  steps)

Set the number of steps to take between each render cycle (only if the simulation is not paused)

◆ setShadowTechnique()

void dart::gui::osg::WorldNode::setShadowTechnique ( ::osg::ref_ptr< osgShadow::ShadowTechnique >  shadowTechnique = nullptr)

Set the ShadowTechnique If you wish to disable shadows, pass a nullptr.

◆ setupViewer()

void dart::gui::osg::WorldNode::setupViewer ( )
protectedvirtual

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.

◆ setWorld()

void dart::gui::osg::WorldNode::setWorld ( std::shared_ptr< dart::simulation::World newWorld)

Set the World that this WorldNode is associated with.

◆ simulate()

void dart::gui::osg::WorldNode::simulate ( bool  on)

Pass in true to take steps between render cycles; pass in false to turn off steps between render cycles.

Friends And Related Function Documentation

◆ Viewer

friend class Viewer
friend

Member Data Documentation

◆ mFrameToNode

NodeMap dart::gui::osg::WorldNode::mFrameToNode
protected

Map from Frame pointers to FrameNode pointers.

◆ mNormalGroup

::osg::ref_ptr<::osg::Group> dart::gui::osg::WorldNode::mNormalGroup
protected

OSG group for non-shadowed objects.

◆ mNumStepsPerCycle

std::size_t dart::gui::osg::WorldNode::mNumStepsPerCycle
protected

Number of steps to take between rendering cycles.

◆ mShadowed

bool dart::gui::osg::WorldNode::mShadowed
protected

Whether the shadows are enabled.

◆ mShadowedGroup

::osg::ref_ptr<::osg::Group> dart::gui::osg::WorldNode::mShadowedGroup
protected

OSG group for shadowed objects.

◆ mSimulating

bool dart::gui::osg::WorldNode::mSimulating
protected

True iff simulation is active.

◆ mViewer

Viewer* dart::gui::osg::WorldNode::mViewer
protected

Viewer that this WorldNode is inside of.

◆ mWorld

std::shared_ptr<dart::simulation::World> dart::gui::osg::WorldNode::mWorld
protected

The World that this WorldNode is associated with.