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 intThe field index for bboxCenterprotected static final intThe field index for bboxDisplayprotected static final intThe field index for bboxSizeprotected static final intThe field index for enabledprotected static final intThe field index for rotationprotected static final intThe field index for translationprotected static final intThe field index for visibleprotected static final intLast index used by this base nodeprotected org.odejava.PlaceableGeomThe ODE shape of the geometryprotected javax.vecmath.Matrix4fMatrix representing the last calculated positionprotected float[]field SFVec3f bboxCenter 0, 0, 0protected booleanfield SFBool bboxDisplay falseprotected float[]field SFVec3f bboxSize [-1, -1, -1]protected booleanThe value of the enabled fieldprotected float[]The value of the rotation fieldprotected float[]The value of translation fieldprotected booleanfield 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 TypeMethodDescriptionvoidThe end of the frame has been reached, update the matrix now.protected voidConstruct a new instance of this node based on the details from the given node.float[]Get the current value of field the bboxCenter field.booleanGet 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.PlaceableGeomGet the ODE shape of the geometry node.intGet the primary type of this node.float[]Get the current rotation component of the transform.float[]Get the current translation component of the transform.booleanGet the current value of the visible field.booleanGet the current value of the enabled field.booleanisShared()Check to see if this node has been used more than once.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetBboxCenter(float[] val) Set the bounding box for this node.voidsetBboxDisplay(boolean val) Set the bboxDisplay field for this node.voidsetBboxSize(float[] val) Set the bounding box for this node.voidsetEnabled(boolean state) Set a new state for the enabled field.voidsetRotation(float[] rot) Set the rotation component of the of transform.voidsetShared(boolean used) Adjust the sharing count up or down one increment depending on the flag.voidsetTranslation(float[] tx) Set the translation component of the of transform.voidNotification that the construction phase of this node has finished.voidsetValue(int index, boolean value) Set the value of the field at the given index as a boolean.voidsetValue(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.voidsetVisible(boolean val) Set the visible field for this node.voidODE computation has finished, so go update the field values and the rendering API structures with the final computed values.protected voidRecalculate 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, updateRefsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.web3d.vrml.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersionMethods 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:
getODEGeometryin 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:
updateFromODEin interfaceVRMLNBodyCollidableNodeType
-
setEnabled
public void setEnabled(boolean state) Set a new state for the enabled field.- Specified by:
setEnabledin 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:
isEnabledin 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:
setRotationin 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:
getRotationin interfaceVRMLNBodyCollidableNodeType- Returns:
- The current rotation
-
setTranslation
Set the translation component of the of transform. Setting a value of null is an error- Specified by:
setTranslationin 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:
getTranslationin interfaceVRMLNBodyCollidableNodeType- Returns:
- The current translation
-
getBboxCenter
public float[] getBboxCenter()Description copied from interface:VRMLBoundedNodeTypeGet the current value of field the bboxCenter field. The default value is0 0 0.- Specified by:
getBboxCenterin interfaceVRMLBoundedNodeType- Returns:
- The value of bboxCenter(SFVec3f)
-
getBboxSize
public float[] getBboxSize()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the bboxSize field. The default value is-1 -1 -1.- Specified by:
getBboxSizein interfaceVRMLBoundedNodeType- Returns:
- The size of the bboxSize(SFVec3f)
-
getBboxDisplay
public boolean getBboxDisplay()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the bboxDisplay field. The default value isfalse.- Specified by:
getBboxDisplayin interfaceVRMLBoundedNodeType- Returns:
- the value of the bboxDisplay(SFBool)
-
getVisible
public boolean getVisible()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the visible field. The default value istrue.- Specified by:
getVisiblein 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:
allEventsCompletein interfaceFrameStateListener- Overrides:
allEventsCompletein 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:
setupFinishedin interfaceVRMLNodeType- Overrides:
setupFinishedin classAbstractNode
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryTypein 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:
getFieldValuein interfaceVRMLNodeType- Overrides:
getFieldValuein 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:
sendRoutein interfaceVRMLNodeType- Overrides:
sendRoutein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setBboxCenterin 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:
setBboxSizein 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:
setBboxDisplayin 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:
setVisiblein interfaceVRMLBoundedNodeType- Parameters:
val- the boolean value to set for the visible field
-