H3D API
2.4.1
|
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< LightInfo > | LightVector |
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 HapticShapeVector & | getHapticShapes (int device_index) |
Get the HapticShapes that has been added for the H3DHapticsDevice with the given device_index. | |
const HapticShapeVector & | getHapticShapes (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 HapticEffectVector & | getForceEffects (int device_index) |
Get the HAPIForceEffects that has been added for the H3DHapticsDevice with the given device_index. | |
const HapticEffectVector & | getForceEffects (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. | |
H3DSurfaceNode * | getCurrentSurface () |
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 LightVector & | getActiveLightNodes () |
Returns the active lights. | |
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.
TraverseInfo::TraverseInfo | ( | const vector< H3DHapticsDevice * > & | _haptics_devices | ) |
Constructor.
_haptics_devices | The HapticDevice instances that are available to render HapticShapes on. |
References initializeLayers().
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().
|
inline |
Adds a HAPIForceEffect to be rendered by a H3DHapticsDevice.
Shapes will only be added if hapticsEnabled() is true.
hd | The H3DHapticsDevice to render the shape on. |
effect | The HAPIForceEffect to render. |
void TraverseInfo::addForceEffect | ( | int | device_index, |
HAPI::HAPIForceEffect * | effect | ||
) |
Adds a HAPIForceEffect to be rendered by a H3DHapticsDevice.
Effects will only be added if hapticsEnabled() is true.
device_index | The index of the H3DHapticsDevice to render the shape on. |
effect | The HAPIForceEffect to render. |
References H3D_FULL_LOCATION, and hapticsEnabled().
Referenced by H3D::DeviceLog::traverseSG(), H3D::ForceField::traverseSG(), H3D::MagneticGeometryEffect::traverseSG(), H3D::PositionFunctionEffect::traverseSG(), H3D::RotationalSpringEffect::traverseSG(), H3D::SpringEffect::traverseSG(), H3D::TimeFunctionEffect::traverseSG(), and H3D::ViscosityEffect::traverseSG().
void TraverseInfo::addForceEffectToAll | ( | HAPI::HAPIForceEffect * | effect | ) |
Adds a HAPIForceEffect to be rendered by all H3DHapticsDevices.
Effects will only be added if hapticsEnabled() is true.
effect | The HAPIForceEffect to render. |
References hapticsEnabled().
Referenced by H3D::ForceField::traverseSG().
|
inline |
Adds a HapticShape to be rendered by a H3DHapticsDevice.
Shapes will only be added if hapticsEnabled() is true.
hd | The H3DHapticsDevice to render the shape on. |
shape | The HapticShape to render. |
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.
device_index | The index of the H3DHapticsDevice to render the shape on. |
shape | The HapticShape to render. |
References H3D::X3DGeometryNode::getHapticShapeId(), H3D_FULL_LOCATION, and hapticsEnabled().
Referenced by H3D::Sphere::traverseSG().
void TraverseInfo::addHapticShapeToAll | ( | HAPI::HAPIHapticShape * | shape | ) |
Adds a HapticShape to be rendered by all H3DHapticsDevices.
Shapes will only be added if hapticsEnabled() is true.
shape | The HapticShape to render. |
References H3D::X3DGeometryNode::getHapticShapeId(), and hapticsEnabled().
|
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().
|
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().
|
inline |
When called, the addHapticShapes() and addForceEffects() functions calls will add HapticShapes to render.
Haptics is enabled by default.
|
inline |
Get the accumulated forward transformation matrix, i.e.
the transformation matrix from the local space at the current traversal position to global space.
Referenced by H3D::X3DLightNode::disableHapticsState(), H3D::X3DLightNode::enableHapticsState(), H3D::DirectionalLight::traverseSG(), H3D::Fog::traverseSG(), H3D::ForceField::traverseSG(), H3D::GeneratedCubeMapTexture::traverseSG(), H3D::HAnimJoint::traverseSG(), H3D::MagneticGeometryEffect::traverseSG(), H3D::MatrixTransform::traverseSG(), H3D::PlanarReflector::traverseSG(), H3D::PointLight::traverseSG(), H3D::RotationalSpringEffect::traverseSG(), H3D::Sound::traverseSG(), H3D::Sphere::traverseSG(), H3D::SpringEffect::traverseSG(), H3D::TransformInfo::traverseSG(), H3D::VisibilitySensor::traverseSG(), H3D::X3DBackgroundNode::traverseSG(), H3D::X3DLightNode::traverseSG(), H3D::X3DShapeNode::traverseSG(), and H3D::X3DViewpointNode::traverseSG().
|
inline |
Get the accumulated inverse transformation matrix, i.e.
the transformation matrix from global space to the local space at the current traversal position.
Referenced by H3D::ClipPlane::enableHapticsState(), H3D::Billboard::traverseSG(), H3D::DeformableShape::traverseSG(), H3D::HAnimJoint::traverseSG(), H3D::LOD::traverseSG(), H3D::MagneticGeometryEffect::traverseSG(), H3D::MatrixTransform::traverseSG(), H3D::ParticleSystem::traverseSG(), H3D::PhongShader::traverseSG(), H3D::ProximitySensor::traverseSG(), H3D::SpringEffect::traverseSG(), H3D::TransformInfo::traverseSG(), and H3D::X3DViewpointNode::traverseSG().
|
inline |
Returns the index of the given H3DHapticsDevice.
-1 is returned if the H3DHapticsDevice is not in the vector of haptics devices.
|
inline |
Get the user data value with the given key.
Output in the data argument. Returns 0 on success.
Referenced by H3D::H3DWindowNode::render(), H3D::DirectionalLight::traverseSG(), H3D::FrameBufferTextureGenerator::traverseSG(), H3D::HAnimJoint::traverseSG(), H3D::IndexedFaceSet::traverseSG(), H3D::IndexedTriangleSet::traverseSG(), H3D::LineSet::traverseSG(), H3D::PointLight::traverseSG(), H3D::ViewpointGroup::traverseSG(), H3D::X3DShapeNode::traverseSG(), and H3D::X3DViewpointNode::traverseSG().
|
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().
|
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().
|
inline |
This function should be called when we move into a nested coordinate space with the transformation matrices between the coordinate spaces.
forward | Transformation matrix between the space we move into to the previous space. |
inverse | The inverse of forward. |
Referenced by H3D::HAnimJoint::traverseSG(), and H3D::MatrixTransform::traverseSG().
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().
|
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().
|
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().
|
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().
|
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().