H3D API  2.4.1
Classes | Public Types | Public Member Functions | List of all members
H3D::TraverseInfo Class Reference

TraverseInfo is a structure that is passed along when traversing the scene graph. More...

#include <H3D/TraverseInfo.h>

Classes

class  InvalidHapticsDeviceIndex
 Thrown when trying to get hold of a H3DHapticsDevice using an invalid device index. More...
 
class  LightInfo
 Class grouping X3DLightNode and its transformation matrix. More...
 

Public Types

typedef void(* CallbackFunc) (TraverseInfo &ti, void *data)
 Callback function type.
 
typedef vector< LightInfoLightVector
 Used to get all the X3DLightNodes that are global.
 

Public Member Functions

 TraverseInfo (const vector< H3DHapticsDevice * > &_haptics_devices)
 Constructor. More...
 
unsigned int nrLayers ()
 Returns the number of haptics layers that are available and initialized. More...
 
void initializeLayers (unsigned int nr_layers)
 Make sure that the TraverseInfo object have enough resources allocated for the given amount of haptic layers.
 
void setCurrentLayer (unsigned int layer)
 Set the currently active haptic layer. More...
 
unsigned int getCurrentLayer ()
 Get the currently active haptic layer.
 
int getHapticsDeviceIndex (H3DHapticsDevice *hd)
 Returns the index of the given H3DHapticsDevice. More...
 
void addHapticShape (int device_index, HAPI::HAPIHapticShape *shape)
 Adds a HapticShape to be rendered by a H3DHapticsDevice. More...
 
void addHapticShape (H3DHapticsDevice *hd, HAPI::HAPIHapticShape *shape)
 Adds a HapticShape to be rendered by a H3DHapticsDevice. More...
 
void addHapticShapeToAll (HAPI::HAPIHapticShape *shape)
 Adds a HapticShape to be rendered by all H3DHapticsDevices. More...
 
const HapticShapeVectorgetHapticShapes (int device_index)
 Get the HapticShapes that has been added for the H3DHapticsDevice with the given device_index.
 
const HapticShapeVectorgetHapticShapes (H3DHapticsDevice *hd)
 Get the HapticShapes that has been added for the given H3DHapticsDevice.
 
void addForceEffect (int device_index, HAPI::HAPIForceEffect *effect)
 Adds a HAPIForceEffect to be rendered by a H3DHapticsDevice. More...
 
void addForceEffect (H3DHapticsDevice *hd, HAPI::HAPIForceEffect *effect)
 Adds a HAPIForceEffect to be rendered by a H3DHapticsDevice. More...
 
void addForceEffectToAll (HAPI::HAPIForceEffect *effect)
 Adds a HAPIForceEffect to be rendered by all H3DHapticsDevices. More...
 
const HapticEffectVectorgetForceEffects (int device_index)
 Get the HAPIForceEffects that has been added for the H3DHapticsDevice with the given device_index.
 
const HapticEffectVectorgetForceEffects (H3DHapticsDevice *hd)
 Get the HAPIForceEffects that has been added for the given H3DHapticsDevice.
 
void setCurrentSurface (H3DSurfaceNode *s)
 Sets the surface that is active in the current traversal.
 
H3DSurfaceNodegetCurrentSurface ()
 Get the surface that is active in the current traversal.
 
const vector< H3DHapticsDevice * > & getHapticsDevices ()
 Get the haptics devices that are available.
 
void disableHaptics (int i=-1)
 When called, future calls to addHapticShapes() and addForceEffects() functions will not add any shapes until enableHaptics() is called.
 
void enableHaptics (int i=-1)
 When called, the addHapticShapes() and addForceEffects() functions calls will add HapticShapes to render. More...
 
void disableGraphics ()
 Indicate that this node will not be part of the graphics rendering traversal. More...
 
void enableGraphics ()
 Indicate that this node will be part of the graphics rendering traversal. More...
 
void setMultiPassTransparency (bool b)
 If multi pass transparency is set to true the scene will be rendered three times graphically, once for all solid objects, once for the back side of transparent objects and once for the front face of transparent objects. More...
 
bool getMultiPassTransparency ()
 See if multi pass transparency objects have been encountered.
 
bool hapticsEnabled (unsigned int i=0)
 Check whether haptics is enabled for a device index or not. More...
 
bool hapticsEnabledForAll ()
 Returns true if haptics is enabled for all haptics devices.
 
bool hapticsDisabledForAll ()
 Returns true if haptics is disabled for all haptics devices.
 
const vector< bool > & getHapticsEnabled ()
 Get a vector the same size as the haptics device vector indicating if haptics is disabled for that device or not.
 
int setHapticsEnabled (const vector< bool > &enabled)
 Set a vector indicating for each haptics device if haptics is disabled or enabled. More...
 
bool graphicsEnabled ()
 Check whether graphics is enabled or not.
 
void pushMatrices (const Matrix4f &forward, const Matrix4f &inverse)
 This function should be called when we move into a nested coordinate space with the transformation matrices between the coordinate spaces. More...
 
void popMatrices ()
 This function should be called when we move out from a nested coordinate space.
 
const Matrix4f & getAccForwardMatrix ()
 Get the accumulated forward transformation matrix, i.e. More...
 
const Matrix4f & getAccInverseMatrix ()
 Get the accumulated inverse transformation matrix, i.e. More...
 
int getGeometryCount (X3DGeometryNode *geom)
 Returns the number of times the given geometry has been added as the source of a haptic shape so far in the traversal.
 
void setUserData (const string &key, void *data)
 Set user data in the traversinfo object. More...
 
bool haveUserData (const string &key)
 Returns true of user data with the given key exists.
 
int deleteUserData (const string &key)
 Delete user data with the given key. Returns 0 on success.
 
int getUserData (const string &key, void **data)
 Get the user data value with the given key. More...
 
void addPostTraverseCallback (CallbackFunc func, void *data)
 Adds a callback function that will be called after the entire scene has been traversed

 
void callPostTraverseCallbacks ()
 Call all functions added by the addPostTraverseCallback function.
 
void addActiveLightNode (X3DLightNode *light, const Matrix4f &transform)
 Add a light that is active to the TraverseInfo object. More...
 
void removeActiveLightNode (X3DLightNode *light, const Matrix4f &transform)
 Remove a light that is active to the TraverseInfo object. More...
 
const LightVectorgetActiveLightNodes ()
 Returns the active lights.
 

Detailed Description

TraverseInfo is a structure that is passed along when traversing the scene graph.

It contains information needed during the traversing, including e.g. transform matrices, available haptics devices etc. Geometry nodes must register the shapes to render haptically by calls to the addHapticShape() function calls.

Constructor & Destructor Documentation

◆ TraverseInfo()

TraverseInfo::TraverseInfo ( const vector< H3DHapticsDevice * > &  _haptics_devices)

Constructor.

Parameters
_haptics_devicesThe HapticDevice instances that are available to render HapticShapes on.

References initializeLayers().

Member Function Documentation

◆ addActiveLightNode()

void TraverseInfo::addActiveLightNode ( X3DLightNode light,
const Matrix4f &  transform 
)

Add a light that is active to the TraverseInfo object.

The transform matrix is the transformation from the light's local space to world space. Should only be done by the light nodes themselves.

Referenced by H3D::X3DLightNode::enableHapticsState().

◆ addForceEffect() [1/2]

void H3D::TraverseInfo::addForceEffect ( H3DHapticsDevice hd,
HAPI::HAPIForceEffect *  effect 
)
inline

Adds a HAPIForceEffect to be rendered by a H3DHapticsDevice.

Shapes will only be added if hapticsEnabled() is true.

Parameters
hdThe H3DHapticsDevice to render the shape on.
effectThe HAPIForceEffect to render.

◆ addForceEffect() [2/2]

void TraverseInfo::addForceEffect ( int  device_index,
HAPI::HAPIForceEffect *  effect 
)

◆ addForceEffectToAll()

void TraverseInfo::addForceEffectToAll ( HAPI::HAPIForceEffect *  effect)

Adds a HAPIForceEffect to be rendered by all H3DHapticsDevices.

Effects will only be added if hapticsEnabled() is true.

Parameters
effectThe HAPIForceEffect to render.

References hapticsEnabled().

Referenced by H3D::ForceField::traverseSG().

◆ addHapticShape() [1/2]

void H3D::TraverseInfo::addHapticShape ( H3DHapticsDevice hd,
HAPI::HAPIHapticShape *  shape 
)
inline

Adds a HapticShape to be rendered by a H3DHapticsDevice.

Shapes will only be added if hapticsEnabled() is true.

Parameters
hdThe H3DHapticsDevice to render the shape on.
shapeThe HapticShape to render.

◆ addHapticShape() [2/2]

void TraverseInfo::addHapticShape ( int  device_index,
HAPI::HAPIHapticShape *  shape 
)

Adds a HapticShape to be rendered by a H3DHapticsDevice.

Shapes will only be added if hapticsEnabled() is true.

Parameters
device_indexThe index of the H3DHapticsDevice to render the shape on.
shapeThe HapticShape to render.

References H3D::X3DGeometryNode::getHapticShapeId(), H3D_FULL_LOCATION, and hapticsEnabled().

Referenced by H3D::Sphere::traverseSG().

◆ addHapticShapeToAll()

void TraverseInfo::addHapticShapeToAll ( HAPI::HAPIHapticShape *  shape)

Adds a HapticShape to be rendered by all H3DHapticsDevices.

Shapes will only be added if hapticsEnabled() is true.

Parameters
shapeThe HapticShape to render.

References H3D::X3DGeometryNode::getHapticShapeId(), and hapticsEnabled().

◆ disableGraphics()

void H3D::TraverseInfo::disableGraphics ( )
inline

Indicate that this node will not be part of the graphics rendering traversal.

This should be set by nodes that disable graphics rendering. It does not do anything except setting a state in the TraverseInfo class indicating that this node will not be used in graphics rendering.

Referenced by H3D::ToggleGroup::traverseSG().

◆ enableGraphics()

void H3D::TraverseInfo::enableGraphics ( )
inline

Indicate that this node will be part of the graphics rendering traversal.

It does not do anything except setting a state in the TraverseInfo class indicating that this node will be used in graphics rendering.

Referenced by H3D::ToggleGroup::traverseSG().

◆ enableHaptics()

void H3D::TraverseInfo::enableHaptics ( int  i = -1)
inline

When called, the addHapticShapes() and addForceEffects() functions calls will add HapticShapes to render.

Haptics is enabled by default.

◆ getAccForwardMatrix()

const Matrix4f& H3D::TraverseInfo::getAccForwardMatrix ( )
inline

◆ getAccInverseMatrix()

const Matrix4f& H3D::TraverseInfo::getAccInverseMatrix ( )
inline

◆ getHapticsDeviceIndex()

int H3D::TraverseInfo::getHapticsDeviceIndex ( H3DHapticsDevice hd)
inline

Returns the index of the given H3DHapticsDevice.

-1 is returned if the H3DHapticsDevice is not in the vector of haptics devices.

◆ getUserData()

int H3D::TraverseInfo::getUserData ( const string &  key,
void **  data 
)
inline

◆ hapticsEnabled()

bool H3D::TraverseInfo::hapticsEnabled ( unsigned int  i = 0)
inline

Check whether haptics is enabled for a device index or not.

If disabled the addHapticsShapes() functions will have no effect. Geometry nodes that add shapes should check that haptics is enabled before doing any calculations deciding what to render. This is because any HapticShape created will not be rendered anyway so no computer resources should be used creating them.

Referenced by addForceEffect(), addForceEffectToAll(), addHapticShape(), addHapticShapeToAll(), H3D::DeviceLog::traverseSG(), H3D::ForceField::traverseSG(), H3D::MagneticGeometryEffect::traverseSG(), H3D::PositionFunctionEffect::traverseSG(), H3D::RotationalSpringEffect::traverseSG(), H3D::Sphere::traverseSG(), H3D::SpringEffect::traverseSG(), H3D::TimeFunctionEffect::traverseSG(), and H3D::ViscosityEffect::traverseSG().

◆ nrLayers()

unsigned int H3D::TraverseInfo::nrLayers ( )
inline

Returns the number of haptics layers that are available and initialized.

If you need more you will have to use the initializeLayers() function

Referenced by H3D::Scene::idle().

◆ pushMatrices()

void H3D::TraverseInfo::pushMatrices ( const Matrix4f &  forward,
const Matrix4f &  inverse 
)
inline

This function should be called when we move into a nested coordinate space with the transformation matrices between the coordinate spaces.

Parameters
forwardTransformation matrix between the space we move into to the previous space.
inverseThe inverse of forward.

Referenced by H3D::HAnimJoint::traverseSG(), and H3D::MatrixTransform::traverseSG().

◆ removeActiveLightNode()

void TraverseInfo::removeActiveLightNode ( X3DLightNode light,
const Matrix4f &  transform 
)

Remove a light that is active to the TraverseInfo object.

Should only be done by the light nodes themselves.

Referenced by H3D::X3DLightNode::disableHapticsState().

◆ setCurrentLayer()

void H3D::TraverseInfo::setCurrentLayer ( unsigned int  layer)
inline

Set the currently active haptic layer.

The currently active haptic layer determines which layer later calls to addHapticShape and addHapticShapeToAll should add the shapes to.

Referenced by H3D::HapticLayeredGroup::traverseSG().

◆ setHapticsEnabled()

int H3D::TraverseInfo::setHapticsEnabled ( const vector< bool > &  enabled)
inline

Set a vector indicating for each haptics device if haptics is disabled or enabled.

The vector must be the same size as the number of haptics devices available. Returns -1 on error, 0 on success.

Referenced by H3D::ClipPlane::disableHapticsState(), H3D::ToggleGroup::traverseSG(), and H3D::X3DShapeNode::traverseSG().

◆ setMultiPassTransparency()

void H3D::TraverseInfo::setMultiPassTransparency ( bool  b)
inline

If multi pass transparency is set to true the scene will be rendered three times graphically, once for all solid objects, once for the back side of transparent objects and once for the front face of transparent objects.

This is in order to avoid artifacts for transparent objects when rendered int the wrong order.

Referenced by H3D::FrameBufferTextureGenerator::traverseSG(), and H3D::X3DShapeNode::traverseSG().

◆ setUserData()

void H3D::TraverseInfo::setUserData ( const string &  key,
void *  data 
)
inline

Set user data in the traversinfo object.

User data can be used e.g. to pass information to child nodes about values in parent nodes

Referenced by H3D::FrameBufferTextureGenerator::traverseSG(), H3D::HAnimJoint::traverseSG(), H3D::PhongShader::traverseSG(), and H3D::ViewpointGroup::traverseSG().


The documentation for this class was generated from the following files: