H3D API  2.4.1
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
H3D::X3DInterpolatorNode Class Reference

The abstract node X3DInterpolatorNode forms the basis for all types of interpolators specified in this clause. More...

#include <H3D/X3DInterpolatorNode.h>

Inheritance diagram for H3D::X3DInterpolatorNode:
Inheritance graph

Public Member Functions

 X3DInterpolatorNode (Inst< SFNode > _metadata=0, Inst< SFFloat > _set_fraction=0, Inst< MFFloat > _key=0)
 Constructor.
 
int lookupKey (H3DFloat f, H3DFloat &w)
 Utility function for Interpolator nodes to be able to find the index for the key pair to interpolate between for a given fraction value f. More...
 
- Public Member Functions inherited from H3D::X3DChildNode
 X3DChildNode (Inst< SFNode > _metadata=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DNode
 X3DNode (Inst< SFNode > _metadata=0)
 Constructor.
 
X3DMetadataObjectgetMetadataByName (const string &_name)
 Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More...
 
- Public Member Functions inherited from H3D::Node
 Node ()
 Constructor.
 
virtual Nodeclone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL)
 Returns a new instance of this node type with the same state as this one. More...
 
virtual ~Node ()
 Destructor.
 
X3DPrototypeInstancegetProtoInstanceParent ()
 If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More...
 
void setProtoInstanceParent (X3DPrototypeInstance *p)
 Set the X3DPrototypeInstance this node is the the root node if applicaple.
 
virtual void render ()
 the render() function is used for the depth-first rendering traversal of the scene-graph. More...
 
virtual void traverseSG (TraverseInfo &ti)
 traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph. More...
 
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and the Node. More...
 
virtual void closestPoint (const Vec3f &p, NodeIntersectResult &result)
 Find closest point on Node to p. More...
 
virtual bool movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result)
 Detect collision between a moving sphere and the Node. More...
 
virtual string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. More...
 
virtual FieldgetField (const string &_name) const
 return a pointer to the field specified by name within this instance
 
int addDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
int removeDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 

Public Attributes

H3DUniquePtr< SFFloatset_fraction
 The set_fraction inputOnly field receives an SFFloat event and causes the interpolator node function to evaluate, resulting in a value_changed output event of the specified type with the same timestamp as the set_fraction event. More...
 
H3DUniquePtr< MFFloatkey
 The key field contains the list of key times, which could appear as: key [0 0.25 0.65 0.75 1] to indicate there are five key frames in this node. More...
 
- Public Attributes inherited from H3D::X3DNode
H3DUniquePtr< SFNodemetadata
 Meta data about the node. More...
 

Static Public Attributes

static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Additional Inherited Members

- Public Types inherited from H3D::Node
typedef std::map< Node *, Node * > DeepCopyMap
 A map type used during a deep copy clone() to map from original nodes to cloned nodes.
 
- Static Public Member Functions inherited from H3D::Node
static unsigned int nrNodesAlive ()
 Returns the nr of nodes currently alive, i.e. nodes created but not destructed.
 
static int nrNodesCreated ()
 Returns the number of nodes created in total since the start of the program.
 
- Protected Member Functions inherited from H3D::Node
void cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for the clone() method. More...
 
- Static Protected Member Functions inherited from H3D::Node
static NodegetClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for nodes that implement clone() More...
 

Detailed Description

The abstract node X3DInterpolatorNode forms the basis for all types of interpolators specified in this clause.

The key field contains the list of key times, which could appear as:

key [0 0.25 0.65 0.75 1]

to indicate there are five key frames in this node. The keyValue field contains values for the target field, one complete set of values for each key. Interpolator nodes containing no keys in the key field shall not produce any events. However, an input event that replaces an empty key field with one that contains keys will cause the interpolator node to produce events the next time that a set_fraction event is received..

The set_fraction inputOnly field receives an SFFloat event and causes the interpolator node function to evaluate, resulting in a value_changed output event of the specified type with the same timestamp as the set_fraction event.

The contents of the keyValue and value_changed fields are dependent on the type of the node (e.g., the PositionInterpolator fields use MFVec3f values). Each value or set of values in the keyValue field corresponds in order to the parameter value in the key field.

For interpolator nodes that produce a single value, results are undefined if the number of values in the key field is not the same as the number of values in the keyValue field.

For Interpolator nodes that produce multiple values, the keyValue field is an nxm array of values, where n is the number of values in the key field and m is the number of values at each key frame. Each m values in the keyValue field correspond, in order, to a parameter value in the key field. Each value_changed event shall contain m interpolated values. Results are undefined if the number of values in the keyValue field is not a positive integer multiple of the number of values in the key field.

If an X3DInterpolatorNode value_changed outputOnly field is read before it receives any inputs, keyValue[0] is returned if keyValue is not empty. If keyValue is empty (i.e., [ ]), the initial value for the respective field type is returned (EXAMPLE (0, 0, 0) for SFVec3f); see 5 Field type reference for initial event values.

The location of an X3DInterpolatorNode in the transformation hierarchy has no effect on its operation. For example, if a parent of an interpolator node is a Switch node with whichChoice set to 1 (i.e., ignore its children), the interpolator continues to operate as specified (receives and sends events).

A typical simplified structure for a key frame animation implementation involves a TimeSensor, ROUTEs, and the target node.

Transform { Shape IndexedFaceSet { coordIndex='... 1 ... > Coordinate DEF='Moved' point [ x y z, ... ] # t0Geometry }
} }

CoordinateInterpolator DEF='Mover' key [t0 t1 t2 ] # list of key times, 0 to 1 keyValue ' x y z, ... ' # one geometry per key time

TimeSensor DEF='Timer' cycleInterval 5 loop TRUE

ROUTE Timer.fraction_changed TO Mover.set_value
ROUTE Mover.value_changed TO Moved.point

In typical operation, the key frame set_fraction event arrives from a TimeSensor to signal that the time value has advanced. This value varies from 0 to 1 depending upon where the TimeSensor is in its cycle time. For example, if the TimeSensor has a cycleTime of 10 seconds, and 5 seconds has elapsed in its cycle, the set_fraction value will be 0.5.

In this sample structure, the IndexedFaceSet contains a Coordinate field named Moved. This defines the time equals zero geometry for the node. The CoordinateInterpolator node named Mover contains the list of key frame times and the corresponding sets of coordinates in the keyValue field. When the set_fraction event arrives for key, the corresponding interpolated keyValue is sent to the target Coordinate node for rendering.

Member Function Documentation

◆ lookupKey()

int H3D::X3DInterpolatorNode::lookupKey ( H3DFloat  f,
H3DFloat w 
)
inline

Member Data Documentation

◆ key

H3DUniquePtr< MFFloat > H3D::X3DInterpolatorNode::key

◆ set_fraction

H3DUniquePtr< SFFloat > H3D::X3DInterpolatorNode::set_fraction

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