Class BaseInterpolatorNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseInterpolatorNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLChildNodeType
,VRMLInterpolatorNodeType
,VRMLNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseColorInterpolator
,BaseCoordinateInterpolator
,BaseCoordinateInterpolator2D
,BaseGeoPositionInterpolator
,BaseNormalInterpolator
,BaseNurbsPositionInterpolator
,BaseOrientationInterpolator
,BasePositionInterpolator
,BasePositionInterpolator2D
,BaseScalarInterpolator
Abstract implementation of an interpolator so that specific instances can
derive from it.
Interpolator nodes are designed for linear keyframed animation. Interpolators are driven by an input key and produce corresponding piecewise-linear output functions.
As interpolators all have the same number and named fields, we perform all of the setup here in this class. The handling of the basic fields are performed where you see the overridden methods, however routing and sets are not looked after.
- Version:
- $Revision: 1.9 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The field index for fractionprotected static final int
The field index for keyprotected static final int
The field index for keyValueprotected static final int
The field index for valueprotected static final int
The last field index used by this classprotected int
The number of valid values in vfKeyprotected float
The value of the fraction fieldprotected float[]
The value of the key fieldFields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
errorReporter, FIELD_METADATA, fieldLocalData, hasChanged, inSetup, isDEF, isStatic, LAST_NODE_INDEX, layerIds, nodeName, pMetadata, refCounts, removedLayerIds, stateManager, STATIC_SCENE_GRAPH, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
-
Constructor Summary
ConstructorsConstructorDescriptionBaseInterpolatorNode
(String name) Initialise the time dependent node and it's fields that are held locally. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
copy
(VRMLInterpolatorNodeType node) Set the fields of the interpolator node that has the fields set based on the fields of the passed in node.getFieldValue
(int index) Get the value of a field.float
Get the value of the fraction field.float[]
getKey()
Get current value of key field value.int
Get the number of valid keys defined for this interpolator.int
Get the primary type of this node.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setKey
(float[] keys, int numValid) Set a new value for the key field.void
setValue
(int index, float[] value, int numValid) Set the value of the field as an array of floats.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getSecondaryType, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setupFinished, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefCount, updateRefs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
Methods inherited from interface org.web3d.vrml.nodes.VRMLInterpolatorNodeType
setFraction
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_KEY
protected static final int FIELD_KEYThe field index for key- See Also:
-
FIELD_KEY_VALUE
protected static final int FIELD_KEY_VALUEThe field index for keyValue- See Also:
-
FIELD_FRACTION
protected static final int FIELD_FRACTIONThe field index for fraction- See Also:
-
FIELD_VALUE
protected static final int FIELD_VALUEThe field index for value- See Also:
-
LAST_INTERPOLATOR_INDEX
protected static final int LAST_INTERPOLATOR_INDEXThe last field index used by this class- See Also:
-
vfFraction
protected float vfFractionThe value of the fraction field -
vfKey
protected float[] vfKeyThe value of the key field -
numKey
protected int numKeyThe number of valid values in vfKey
-
-
Constructor Details
-
BaseInterpolatorNode
Initialise the time dependent node and it's fields that are held locally.- Parameters:
name
- The name of the type of node
-
-
Method Details
-
copy
Set the fields of the interpolator node that has the fields set based on the fields of the passed in node.- Parameters:
node
- The interpolator node to copy info from
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryType
in interfaceVRMLNode
- Returns:
- The primary type
-
getFraction
public float getFraction()Get the value of the fraction field.- Specified by:
getFraction
in interfaceVRMLInterpolatorNodeType
- Returns:
- The current value for fraction
-
getKey
public float[] getKey()Get current value of key field value. If no keys exist a blank float[] will be returned.- Specified by:
getKey
in interfaceVRMLInterpolatorNodeType
- Returns:
- The current key values
-
getNumKey
public int getNumKey()Get the number of valid keys defined for this interpolator.- Specified by:
getNumKey
in interfaceVRMLInterpolatorNodeType
- Returns:
- a value >= 0
-
setKey
public void setKey(float[] keys, int numValid) Set a new value for the key field. Null will delete all key values.- Specified by:
setKey
in interfaceVRMLInterpolatorNodeType
- Parameters:
keys
- The new key values to usenumValid
- The number of valid values to copy from the array
-
getFieldValue
Get the value of a field. If the field is a primitive type, it will return a class representing the value. For arrays or nodes it will return the instance directly.- Specified by:
getFieldValue
in interfaceVRMLNodeType
- Overrides:
getFieldValue
in classAbstractNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
sendRoute
Send a routed value from this node to the given destination node. The route should use the appropriate setValue() method of the destination node. It should not attempt to cast the node up to a higher level. Routing should also follow the standard rules for the loop breaking and other appropriate rules for the specification.- Specified by:
sendRoute
in interfaceVRMLNodeType
- Overrides:
sendRoute
in classAbstractNode
- Parameters:
time
- The time that this route occurred (not necessarily epoch time. Should be treated as a relative value only)srcIndex
- The index of the field in this node that the value should be sent fromdestNode
- The node reference that we will be sending the value todestIndex
- The index of the field in the destination node that the value should be sent to.
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldFormatException, InvalidFieldException, InvalidFieldValueException Set the value of the field as an array of floats.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The raw value string to be parsednumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldFormatException
- The string was not in a correct form for this field.InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-