Class BaseLightNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseLightNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLChildNodeType
,VRMLLightNodeType
,VRMLNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
BaseDirectionalLight
,BasePointLight
,BaseSpotLight
Abstract common implementation of a light node.
The X3DLightNode is defined as:
X3DLightNode : X3DChildNode { SFFloat [in,out] ambientIntensity 0 [0,1] SFColor [in,out] color 1 1 1 [0,1] SFBool [in,out] global TRUE SFFloat [in,out] intensity 1 [0,1] SFNode [in,out] metadata NULL [X3DMetadataObject] SFBool [in,out] on TRUE }The
global
field is only available from 3.1 onwards.- Version:
- $Revision: 1.10 $
- Author:
- Alan Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
ambientIntensity field indexprotected static final int
color field indexprotected static final int
global light field indexprotected static final int
intensity field indexprotected static final int
on field indexprotected static final String
Error message if the global field is being set on an older spec version of this node.protected static final int
Value of the last index in useprotected float
exposedField SFFloat ambientIntensity 0protected float[]
exposedField SFColor color 1 1 1protected boolean
exposedField SFBool global FALSEprotected float
exposedField SFFloat intensity 1protected boolean
exposedField SFBool on 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
ConstructorsModifierConstructorDescriptionprotected
BaseLightNode
(String name) Construct a new default instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
copy
(VRMLLightNodeType node) Set the fields of the light node that has the fields set based on the fields of the passed in node.float
Get the current value of field ambientIntensity.float[]
getColor()
Get the current value of field color.getFieldValue
(int index) Get the value of a field.boolean
Accessor method to get current value of field global.float
Get the current value of field Intensity.boolean
getOn()
Get the current value of field On.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
setAmbientIntensity
(float newAmbientIntensity) Set the new value of the ambientIntensity field.void
setColor
(float[] newColor) Set the new value of the color field.void
setGlobal
(boolean global) Set the current value of the global field.void
setIntensity
(float newIntensity) Get the current value of field Intensityvoid
setOn
(boolean newOn) Set the value of field On.void
setValue
(int index, boolean value) Set the value of the field at the given index as an boolean.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
setValue
(int index, float[] value, int numValid) Set the value of the field at the given index 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, 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, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_AMBIENT_INTENSITY
protected static final int FIELD_AMBIENT_INTENSITYambientIntensity field index- See Also:
-
FIELD_COLOR
protected static final int FIELD_COLORcolor field index- See Also:
-
FIELD_INTENSITY
protected static final int FIELD_INTENSITYintensity field index- See Also:
-
FIELD_ON
protected static final int FIELD_ONon field index- See Also:
-
FIELD_GLOBAL
protected static final int FIELD_GLOBALglobal light field index- See Also:
-
LAST_LIGHT_INDEX
protected static final int LAST_LIGHT_INDEXValue of the last index in use- See Also:
-
GLOBAL_VERSION_ERR
Error message if the global field is being set on an older spec version of this node.- See Also:
-
vfAmbientIntensity
protected float vfAmbientIntensityexposedField SFFloat ambientIntensity 0 -
vfColor
protected float[] vfColorexposedField SFColor color 1 1 1 -
vfIntensity
protected float vfIntensityexposedField SFFloat intensity 1 -
vfOn
protected boolean vfOnexposedField SFBool on TRUE -
vfGlobal
protected boolean vfGlobalexposedField SFBool global FALSE
-
-
Constructor Details
-
BaseLightNode
Construct a new default instance of this class.- Parameters:
name
- The name of the type of node
-
-
Method Details
-
copy
Set the fields of the light node that has the fields set based on the fields of the passed in node.- Parameters:
node
- The light node to copy info from
-
getAmbientIntensity
public float getAmbientIntensity()Get the current value of field ambientIntensity. Default value is 0.- Specified by:
getAmbientIntensity
in interfaceVRMLLightNodeType
- Returns:
- The current value of ambientIntensity
-
getColor
public float[] getColor()Get the current value of field color. Default value is 1 1 1- Specified by:
getColor
in interfaceVRMLLightNodeType
- Returns:
- The current value of color
-
getIntensity
public float getIntensity()Get the current value of field Intensity. Default value is 1.- Specified by:
getIntensity
in interfaceVRMLLightNodeType
- Returns:
- the current value of Intensity
-
getOn
public boolean getOn()Get the current value of field On. Default value is true.- Specified by:
getOn
in interfaceVRMLLightNodeType
- Returns:
- the current value of On
-
getGlobal
public boolean getGlobal()Accessor method to get current value of field global. Default value is false if the node is from 3.1 onwards. The field does not exist in the 3.0 or 2.0 specifications, so we return the default for the particular light type and its spec-defined behaviour.- Specified by:
getGlobal
in interfaceVRMLLightNodeType
- Returns:
- the current value of the global field
-
setAmbientIntensity
Set the new value of the ambientIntensity field.- Specified by:
setAmbientIntensity
in interfaceVRMLLightNodeType
- Parameters:
newAmbientIntensity
- A value between 0 and 1- Throws:
InvalidFieldValueException
- The value was out of the valid range
-
setColor
Set the new value of the color field.- Specified by:
setColor
in interfaceVRMLLightNodeType
- Parameters:
newColor
- The new value. Each component must be between 0 and 1- Throws:
InvalidFieldValueException
- The value was out of the valid range
-
setIntensity
Get the current value of field Intensity- Specified by:
setIntensity
in interfaceVRMLLightNodeType
- Parameters:
newIntensity
- A value between 0 and 1- Throws:
InvalidFieldValueException
- The value was out of the valid range
-
setOn
public void setOn(boolean newOn) Set the value of field On.- Specified by:
setOn
in interfaceVRMLLightNodeType
- Parameters:
newOn
- true will turn the light on, false to turn it off
-
setGlobal
Set the current value of the global field.- Specified by:
setGlobal
in interfaceVRMLLightNodeType
- Parameters:
global
- true if this should have global effect, false for scoped- Throws:
InvalidFieldException
- Called on a node that belongs to VRML or X3D 3.0.
-
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
Set the value of the field at the given index as an boolean. This would be used to set SFBool 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 node- Throws:
InvalidFieldException
- The field index is not known
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a float. This would be used to set SFFloat 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 node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an array of floats. This would be used to set SFColor and SFVec3f 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 not in range or not appropriate for this field
-