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 intambientIntensity field indexprotected static final intcolor field indexprotected static final intglobal light field indexprotected static final intintensity field indexprotected static final inton field indexprotected static final StringError message if the global field is being set on an older spec version of this node.protected static final intValue of the last index in useprotected floatexposedField SFFloat ambientIntensity 0protected float[]exposedField SFColor color 1 1 1protected booleanexposedField SFBool global FALSEprotected floatexposedField SFFloat intensity 1protected booleanexposedField 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
ConstructorsModifierConstructorDescriptionprotectedBaseLightNode(String name) Construct a new default instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcopy(VRMLLightNodeType node) Set the fields of the light node that has the fields set based on the fields of the passed in node.floatGet the current value of field ambientIntensity.float[]getColor()Get the current value of field color.getFieldValue(int index) Get the value of a field.booleanAccessor method to get current value of field global.floatGet the current value of field Intensity.booleangetOn()Get the current value of field On.intGet the primary type of this node.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetAmbientIntensity(float newAmbientIntensity) Set the new value of the ambientIntensity field.voidsetColor(float[] newColor) Set the new value of the color field.voidsetGlobal(boolean global) Set the current value of the global field.voidsetIntensity(float newIntensity) Get the current value of field IntensityvoidsetOn(boolean newOn) Set the value of field On.voidsetValue(int index, boolean value) Set the value of the field at the given index as an boolean.voidsetValue(int index, float value) Set the value of the field at the given index as a float.voidsetValue(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, updateRefsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsCompleteMethods 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, 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:
getAmbientIntensityin 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:
getColorin interfaceVRMLLightNodeType- Returns:
- The current value of color
-
getIntensity
public float getIntensity()Get the current value of field Intensity. Default value is 1.- Specified by:
getIntensityin interfaceVRMLLightNodeType- Returns:
- the current value of Intensity
-
getOn
public boolean getOn()Get the current value of field On. Default value is true.- Specified by:
getOnin 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:
getGlobalin interfaceVRMLLightNodeType- Returns:
- the current value of the global field
-
setAmbientIntensity
Set the new value of the ambientIntensity field.- Specified by:
setAmbientIntensityin 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:
setColorin 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:
setIntensityin 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:
setOnin 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:
setGlobalin 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:
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
Set the value of the field at the given index as an boolean. This would be used to set SFBool 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 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:
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 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:
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 not in range or not appropriate for this field
-