Class BaseCollidableNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.rigidphysics.BaseCollidableNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLBoundedNodeType
,VRMLChildNodeType
,VRMLNBodyCollidableNodeType
,VRMLNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseCollidableOffset
,BaseCollidableShape
public abstract class BaseCollidableNode
extends AbstractNode
implements VRMLNBodyCollidableNodeType
Base implementation of the X3DCollidableNode abstract type.
The base class provides most of the basic functionality, including interacting with the ODE portions. However, for returning the scene graph object appropriate for the renderer will require the derived class to take care of it.
The basic (X3D) definition of X3DNBodyCollidableNode is:
X3DNBodyCollidableNode { SFNode [in,out] metadata NULL [X3DMetadataObject] SFBool [in,out] enabled TRUE SFVec3f [in,out] position 0 0 0 (-∞,∞) SFRotation [in,out] rotation 0 0 1 0 [0,1] SFVec3f [] bboxCenter 0 0 0 (-∞,∞) SFVec3f [] bboxSize -1 -1 -1 [0,∞) or -1 -1 -1 SFBool [in,out] bboxDisplay FALSE SFBool [in,out] visible TRUE }
- Version:
- $Revision: 1.6 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The field index for bboxCenterprotected static final int
The field index for bboxDisplayprotected static final int
The field index for bboxSizeprotected static final int
The field index for enabledprotected static final int
The field index for rotationprotected static final int
The field index for translationprotected static final int
The field index for visibleprotected static final int
Last index used by this base nodeprotected org.odejava.PlaceableGeom
The ODE shape of the geometryprotected javax.vecmath.Matrix4f
Matrix representing the last calculated positionprotected float[]
field SFVec3f bboxCenter 0, 0, 0protected boolean
field SFBool bboxDisplay falseprotected float[]
field SFVec3f bboxSize [-1, -1, -1]protected boolean
The value of the enabled fieldprotected float[]
The value of the rotation fieldprotected float[]
The value of translation fieldprotected boolean
field SFBool visible trueFields 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
ConstructorsConstructorDescriptionBaseCollidableNode
(String name) Construct a new generalised joint node object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
The end of the frame has been reached, update the matrix now.protected void
Construct a new instance of this node based on the details from the given node.float[]
Get the current value of field the bboxCenter field.boolean
Get the current value of the bboxDisplay field.float[]
Get the current value of the bboxSize field.getFieldValue
(int index) Get the value of a field.org.odejava.PlaceableGeom
Get the ODE shape of the geometry node.int
Get the primary type of this node.float[]
Get the current rotation component of the transform.float[]
Get the current translation component of the transform.boolean
Get the current value of the visible field.boolean
Get the current value of the enabled field.boolean
isShared()
Check to see if this node has been used more than once.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setBboxCenter
(float[] val) Set the bounding box for this node.void
setBboxDisplay
(boolean val) Set the bboxDisplay field for this node.void
setBboxSize
(float[] val) Set the bounding box for this node.void
setEnabled
(boolean state) Set a new state for the enabled field.void
setRotation
(float[] rot) Set the rotation component of the of transform.void
setShared
(boolean used) Adjust the sharing count up or down one increment depending on the flag.void
setTranslation
(float[] tx) Set the translation component of the of transform.void
Notification that the construction phase of this node has finished.void
setValue
(int index, boolean value) Set the value of the field at the given index as a boolean.void
setValue
(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.void
setVisible
(boolean val) Set the visible field for this node.void
ODE computation has finished, so go update the field values and the rendering API structures with the final computed values.protected void
Recalculate the transformation matrix given the current axis/angle and translation values.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getSecondaryType, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setUserData, 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.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, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_BBOX_SIZE
protected static final int FIELD_BBOX_SIZEThe field index for bboxSize- See Also:
-
FIELD_BBOX_CENTER
protected static final int FIELD_BBOX_CENTERThe field index for bboxCenter- See Also:
-
FIELD_BBOX_DISPLAY
protected static final int FIELD_BBOX_DISPLAYThe field index for bboxDisplay- See Also:
-
FIELD_VISIBLE
protected static final int FIELD_VISIBLEThe field index for visible- See Also:
-
FIELD_ENABLED
protected static final int FIELD_ENABLEDThe field index for enabled- See Also:
-
FIELD_ROTATION
protected static final int FIELD_ROTATIONThe field index for rotation- See Also:
-
FIELD_TRANSLATION
protected static final int FIELD_TRANSLATIONThe field index for translation- See Also:
-
LAST_COLLIDABLE_INDEX
protected static final int LAST_COLLIDABLE_INDEXLast index used by this base node- See Also:
-
vfBboxCenter
protected float[] vfBboxCenterfield SFVec3f bboxCenter 0, 0, 0 -
vfBboxSize
protected float[] vfBboxSizefield SFVec3f bboxSize [-1, -1, -1] -
vfBboxDisplay
protected boolean vfBboxDisplayfield SFBool bboxDisplay false -
vfVisible
protected boolean vfVisiblefield SFBool visible true -
vfEnabled
protected boolean vfEnabledThe value of the enabled field -
vfTranslation
protected float[] vfTranslationThe value of translation field -
vfRotation
protected float[] vfRotationThe value of the rotation field -
odeGeom
protected org.odejava.PlaceableGeom odeGeomThe ODE shape of the geometry -
tmatrix
protected javax.vecmath.Matrix4f tmatrixMatrix representing the last calculated position
-
-
Constructor Details
-
BaseCollidableNode
Construct a new generalised joint node object.- Parameters:
name
- The VRML name of this node
-
-
Method Details
-
copy
Construct a new instance of this node based on the details from the given node. If the node is not the same type, an exception will be thrown.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not the same type
-
getODEGeometry
public org.odejava.PlaceableGeom getODEGeometry()Get the ODE shape of the geometry node.- Specified by:
getODEGeometry
in interfaceVRMLNBodyCollidableNodeType
- Returns:
- The PlaceableGeom instance for this collidable
-
updateFromODE
public void updateFromODE()ODE computation has finished, so go update the field values and the rendering API structures with the final computed values.- Specified by:
updateFromODE
in interfaceVRMLNBodyCollidableNodeType
-
setEnabled
public void setEnabled(boolean state) Set a new state for the enabled field.- Specified by:
setEnabled
in interfaceVRMLNBodyCollidableNodeType
- Parameters:
state
- True if this sensor is to be enabled
-
isEnabled
public boolean isEnabled()Get the current value of the enabled field. Default value istrue
.- Specified by:
isEnabled
in interfaceVRMLNBodyCollidableNodeType
- Returns:
- The value of the enabled field
-
setRotation
Set the rotation component of the of transform. Setting a value of null is an error- Specified by:
setRotation
in interfaceVRMLNBodyCollidableNodeType
- Parameters:
rot
- The new rotation component- Throws:
InvalidFieldValueException
- The rotation was null
-
getRotation
public float[] getRotation()Get the current rotation component of the transform.- Specified by:
getRotation
in interfaceVRMLNBodyCollidableNodeType
- Returns:
- The current rotation
-
setTranslation
Set the translation component of the of transform. Setting a value of null is an error- Specified by:
setTranslation
in interfaceVRMLNBodyCollidableNodeType
- Parameters:
tx
- The new translation component- Throws:
InvalidFieldValueException
- The translation was null
-
getTranslation
public float[] getTranslation()Get the current translation component of the transform.- Specified by:
getTranslation
in interfaceVRMLNBodyCollidableNodeType
- Returns:
- The current translation
-
getBboxCenter
public float[] getBboxCenter()Description copied from interface:VRMLBoundedNodeType
Get the current value of field the bboxCenter field. The default value is0 0 0
.- Specified by:
getBboxCenter
in interfaceVRMLBoundedNodeType
- Returns:
- The value of bboxCenter(SFVec3f)
-
getBboxSize
public float[] getBboxSize()Description copied from interface:VRMLBoundedNodeType
Get the current value of the bboxSize field. The default value is-1 -1 -1
.- Specified by:
getBboxSize
in interfaceVRMLBoundedNodeType
- Returns:
- The size of the bboxSize(SFVec3f)
-
getBboxDisplay
public boolean getBboxDisplay()Description copied from interface:VRMLBoundedNodeType
Get the current value of the bboxDisplay field. The default value isfalse
.- Specified by:
getBboxDisplay
in interfaceVRMLBoundedNodeType
- Returns:
- the value of the bboxDisplay(SFBool)
-
getVisible
public boolean getVisible()Description copied from interface:VRMLBoundedNodeType
Get the current value of the visible field. The default value istrue
.- Specified by:
getVisible
in interfaceVRMLBoundedNodeType
- Returns:
- the value of the visible(SFBool)
-
allEventsComplete
public void allEventsComplete()The end of the frame has been reached, update the matrix now.- Specified by:
allEventsComplete
in interfaceFrameStateListener
- Overrides:
allEventsComplete
in classAbstractNode
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. If the node would like to do any internal processing, such as setting up geometry, then go for it now.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
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
-
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, boolean value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a boolean. This is be used to set SFBool field types isActive, enabled and loop.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The index is not a valid fieldInvalidFieldValueException
- The field value is not legal for the field specified.
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of floats. This would be used to set MFFloat, SFVec2f, SFVec3f and SFRotation field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
updateMatrix
protected void updateMatrix()Recalculate the transformation matrix given the current axis/angle and translation values. The result is placed in tmatrix. -
setBboxCenter
public void setBboxCenter(float[] val) Set the bounding box for this node. Only used by the field parser at setup.- Specified by:
setBboxCenter
in interfaceVRMLBoundedNodeType
- Parameters:
val
- The box center to set
-
setBboxSize
Set the bounding box for this node. Only used by the field parser at setup.- Specified by:
setBboxSize
in interfaceVRMLBoundedNodeType
- Parameters:
val
- The box size to set- Throws:
InvalidFieldValueException
- The bounds is not valid
-
setBboxDisplay
public void setBboxDisplay(boolean val) Set the bboxDisplay field for this node. Only used by the field parser at setup- Specified by:
setBboxDisplay
in interfaceVRMLBoundedNodeType
- Parameters:
val
- the boolean value to set for the bboxDisplay field
-
setVisible
public void setVisible(boolean val) Set the visible field for this node. Only used by the field parser at setup- Specified by:
setVisible
in interfaceVRMLBoundedNodeType
- Parameters:
val
- the boolean value to set for the visible field
-