Xj3D VRML/X3D Code API

org.web3d.vrml.renderer.common.nodes
Class BaseLightNode

java.lang.Object
  extended byorg.web3d.vrml.renderer.common.nodes.AbstractNode
      extended byorg.web3d.vrml.renderer.common.nodes.BaseLightNode
All Implemented Interfaces:
FrameStateListener, VRMLChildNodeType, VRMLLightNodeType, VRMLNode, VRMLNodeType
Direct Known Subclasses:
J3DLightNode

public abstract class BaseLightNode
extends AbstractNode
implements VRMLLightNodeType

Abstract common implementation of a light.

Version:
$Revision: 1.8 $
Author:
Alan Hudson

Field Summary
protected static int FIELD_AMBIENT_INTENSITY
          ambientIntensity field fndex
protected static int FIELD_COLOR
          color field index
protected static int FIELD_INTENSITY
          intensity field index
protected static int FIELD_ON
          on field index
protected static int LAST_LIGHT_INDEX
          Value of the last index in use
protected  float vfAmbientIntensity
          exposedField SFFloat ambientIntensity 0
protected  float[] vfColor
          exposedField SFColor color 1 1 1
protected  float vfIntensity
          exposedField SFFloat intensity 1
protected  boolean vfOn
          exposedField SFBool on TRUE
 
Fields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
BAD_NODE_MSG, errorReporter, FIELD_METADATA, fieldData, hasChanged, INIT_ONLY_WRITE_MSG, inSetup, isDEF, isStatic, LAST_NODE_INDEX, METADATA_NODE_MSG, METADATA_PROTO_MSG, nodeName, pMetadata, refCount, stateManager, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
 
Constructor Summary
protected BaseLightNode(java.lang.String name)
          Construct a new default instance of this class.
 
Method Summary
protected  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 getAmbientIntensity()
          Accessor method to get current value of field ambientIntensity, default value is 0
 float[] getColor()
          Accessor method to get current value of field color, default value is 1 1 1
 VRMLFieldData getFieldValue(int index)
          Get the value of a field.
 float getIntensity()
          Accessor method to get current value of field Intensity, default value is 1
 boolean getOn()
          Accessor method to get current value of field On.
 int getPrimaryType()
          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)
          Accessor method to get current value of field ambientIntensity
 void setColor(float[] newColor)
          Accessor method to get current value of field color
 void setIntensity(float newIntensity)
          Accessor method to get current value of field Intensity
 void setOn(boolean newOn)
          Accessor method to get current 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, fireFieldChanged, getMetadataObject, getNodeFieldIndices, getRefCount, 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, updateRefCount
 
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.VRMLNodeType
addNodeListener, getMetadataObject, getRefCount, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setupFinished, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
 
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.FrameStateListener
allEventsComplete
 

Field Detail

FIELD_AMBIENT_INTENSITY

protected static final int FIELD_AMBIENT_INTENSITY
ambientIntensity field fndex

See Also:
Constant Field Values

FIELD_COLOR

protected static final int FIELD_COLOR
color field index

See Also:
Constant Field Values

FIELD_INTENSITY

protected static final int FIELD_INTENSITY
intensity field index

See Also:
Constant Field Values

FIELD_ON

protected static final int FIELD_ON
on field index

See Also:
Constant Field Values

LAST_LIGHT_INDEX

protected static final int LAST_LIGHT_INDEX
Value of the last index in use

See Also:
Constant Field Values

vfAmbientIntensity

protected float vfAmbientIntensity
exposedField SFFloat ambientIntensity 0


vfColor

protected float[] vfColor
exposedField SFColor color 1 1 1


vfIntensity

protected float vfIntensity
exposedField SFFloat intensity 1


vfOn

protected boolean vfOn
exposedField SFBool on TRUE

Constructor Detail

BaseLightNode

protected BaseLightNode(java.lang.String name)
Construct a new default instance of this class.

Parameters:
name - The name of the type of node
Method Detail

copy

protected 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.

Parameters:
node - The light node to copy info from

getAmbientIntensity

public float getAmbientIntensity()
Accessor method to get current value of field ambientIntensity, default value is 0

Specified by:
getAmbientIntensity in interface VRMLLightNodeType
Returns:
The current value of ambientIntensity

getColor

public float[] getColor()
Accessor method to get current value of field color, default value is 1 1 1

Specified by:
getColor in interface VRMLLightNodeType
Returns:
The current value of color

getIntensity

public float getIntensity()
Accessor method to get current value of field Intensity, default value is 1

Specified by:
getIntensity in interface VRMLLightNodeType
Returns:
the current value of Intensity

getOn

public boolean getOn()
Accessor method to get current value of field On. default value is true

Specified by:
getOn in interface VRMLLightNodeType
Returns:
the current value of On

setAmbientIntensity

public void setAmbientIntensity(float newAmbientIntensity)
                         throws InvalidFieldValueException
Accessor method to get current value of field ambientIntensity

Specified by:
setAmbientIntensity in interface VRMLLightNodeType
Parameters:
newAmbientIntensity - The new value
Throws:
InvalidFieldValueException

setColor

public void setColor(float[] newColor)
              throws InvalidFieldValueException
Accessor method to get current value of field color

Specified by:
setColor in interface VRMLLightNodeType
Parameters:
newColor - The new value
Throws:
InvalidFieldValueException

setIntensity

public void setIntensity(float newIntensity)
                  throws InvalidFieldValueException
Accessor method to get current value of field Intensity

Specified by:
setIntensity in interface VRMLLightNodeType
Parameters:
newIntensity - The new value
Throws:
InvalidFieldValueException

setOn

public void setOn(boolean newOn)
Accessor method to get current value of field On

Specified by:
setOn in interface VRMLLightNodeType
Parameters:
newOn - The new value

getPrimaryType

public int getPrimaryType()
Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.

Specified by:
getPrimaryType in interface VRMLNode
Returns:
The primary type

getFieldValue

public VRMLFieldData getFieldValue(int index)
                            throws InvalidFieldException
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 interface VRMLNodeType
Overrides:
getFieldValue in class AbstractNode
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

public void sendRoute(double time,
                      int srcIndex,
                      VRMLNodeType destNode,
                      int destIndex)
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 interface VRMLNodeType
Overrides:
sendRoute in class AbstractNode
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 from
destNode - The node reference that we will be sending the value to
destIndex - 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
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 interface VRMLNodeType
Overrides:
setValue in class AbstractNode
Parameters:
index - The index of destination field to set
value - 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 interface VRMLNodeType
Overrides:
setValue in class AbstractNode
Parameters:
index - The index of destination field to set
value - The new value to use for the node
Throws:
InvalidFieldException - The field index is not known
InvalidFieldValueException - The value provided is out of range for the field type.

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 interface VRMLNodeType
Overrides:
setValue in class AbstractNode
Parameters:
index - The index of destination field to set
value - The new value to use for the node
numValid - The number of valid values to copy from the array
Throws:
InvalidFieldException - The field index is not known
InvalidFieldValueException - The value provided is out of range for the field type.

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium