Class BasePhysicsModel
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.particle.BasePhysicsModel
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLNodeType
,VRMLParticlePhysicsModelNodeType
- Direct Known Subclasses:
BaseGravityPhysicsModel
,BaseWindPhysicsModel
public abstract class BasePhysicsModel
extends AbstractNode
implements VRMLParticlePhysicsModelNodeType
Common implementation of a GravityPhysics node.
- Version:
- $Revision: 2.2 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The field index for cycleIntervalprotected static final int
The last field index used by this classprotected org.j3d.geom.particle.ParticleFunction
The j3d.org particle function implementation this node is wrappingprotected boolean
The value of the cycle time 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
ConstructorsModifierConstructorDescriptionprotected
BasePhysicsModel
(String nodeName) Construct a new time sensor object -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Copy the node to this node.boolean
Get the current enabled state of this model.getFieldValue
(int index) Get the value of a field.org.j3d.geom.particle.ParticleFunction
Return the particle function implementation that this model controls.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
setEnabled
(boolean state) Set the enabled state of the Physics model.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.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, 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.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, setValue, updateRefCount
-
Field Details
-
FIELD_ENABLED
protected static final int FIELD_ENABLEDThe field index for cycleInterval- See Also:
-
LAST_PHYSICS_INDEX
protected static final int LAST_PHYSICS_INDEXThe last field index used by this class- See Also:
-
vfEnabled
protected boolean vfEnabledThe value of the cycle time field -
particleFunction
protected org.j3d.geom.particle.ParticleFunction particleFunctionThe j3d.org particle function implementation this node is wrapping
-
-
Constructor Details
-
BasePhysicsModel
Construct a new time sensor object- Parameters:
nodeName
-
-
-
Method Details
-
copy
Copy the node to this node.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not the same type
-
getParticleFunction
public org.j3d.geom.particle.ParticleFunction getParticleFunction()Return the particle function implementation that this model controls. May not be available until after setupFinished() is called.- Specified by:
getParticleFunction
in interfaceVRMLParticlePhysicsModelNodeType
- Returns:
- The current function to control the system
-
setEnabled
public void setEnabled(boolean state) Set the enabled state of the Physics model.- Specified by:
setEnabled
in interfaceVRMLParticlePhysicsModelNodeType
- Parameters:
state
- true to enable the use of this model
-
getEnabled
public boolean getEnabled()Get the current enabled state of this model.- Specified by:
getEnabled
in interfaceVRMLParticlePhysicsModelNodeType
- Returns:
- The value of the enabled field
-
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 field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-