Package com.ardor3d.renderer.state
Class LightState
java.lang.Object
com.ardor3d.renderer.state.RenderState
com.ardor3d.renderer.state.LightState
- All Implemented Interfaces:
Savable
LightState
maintains a collection of lights up to the set number of maximum lights allowed. Any subclass
of Light
can be added to the light state. Each light is processed and used to modify the color of the
scene.-
Nested Class Summary
Nested classes/interfaces inherited from class com.ardor3d.renderer.state.RenderState
RenderState.StateStack, RenderState.StateType
-
Field Summary
Modifier and TypeFieldDescriptionprotected ColorRGBA
protected int
static final ReadOnlyColorRGBA
protected int
static boolean
Debug flag for turning off all lighting.protected boolean
When true, the eye position (as opposed to just the view direction) will be taken into account when computing specular reflections.static final int
When applied to lightMask, implies ambient light should be set to 0 for this lightstatestatic final int
When applied to lightMask, implies diffuse light should be set to 0 for this lightstatestatic final int
When applied to lightMask, implies global ambient light should be set to 0 for this lightstatestatic final int
When applied to lightMask, implies specular light should be set to 0 for this lightstatestatic final int
defines the maximum number of lights that are allowed to be maintained at one time.protected boolean
When true, specular highlights will be computed separately and added to fragments after texturing.protected boolean
When true, both sides of the model will be lighted.Fields inherited from class com.ardor3d.renderer.state.RenderState
_quickCompare
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
attach
places a light in the queue to be processed.void
detach
removes a light from the queue for processing.void
detachAll
clears the queue of all lights to be processed.extract
(Stack<? extends RenderState> stack, Spatial spat) Extracts from the stack the correct renderstate that should apply to the given spatial.get
(int i) get
retrieves a particular light defined by an index.Retrieves all lights handled by this LightStateint
boolean
Returns the current state of local viewer mode for this LightState.int
getNumberOfChildren
returns the number of lights currently in the queue.boolean
Returns the current state of separate specular mode for this LightState.boolean
Returns the current state of two sided lighting for this LightState.getType()
void
Recalls the light mask from a back store or 0 if none was pushed.void
Saves the light mask to a back store.void
read
(InputCapsule capsule) void
void
setLightMask
(int lightMask) setLightMask
sets what attributes of this lightstate to apply as an int comprised of bitwise or'ed values.void
setLocalViewer
(boolean localViewerOn) Sets if local viewer mode should be enabled for this LightState.void
setSeparateSpecular
(boolean separateSpecularOn) Sets if separate specular mode should be enabled for this LightState.void
setTwoSidedLighting
(boolean twoSidedOn) Sets if two sided lighting should be enabled for this LightState.void
write
(OutputCapsule capsule) Methods inherited from class com.ardor3d.renderer.state.RenderState
createState, getClassTag, isEnabled, needsRefresh, setEnabled, setNeedsRefresh, setQuickCompares
-
Field Details
-
LIGHTS_ENABLED
public static boolean LIGHTS_ENABLEDDebug flag for turning off all lighting. -
MAX_LIGHTS_ALLOWED
public static final int MAX_LIGHTS_ALLOWEDdefines the maximum number of lights that are allowed to be maintained at one time.- See Also:
-
MASK_AMBIENT
public static final int MASK_AMBIENTWhen applied to lightMask, implies ambient light should be set to 0 for this lightstate- See Also:
-
MASK_DIFFUSE
public static final int MASK_DIFFUSEWhen applied to lightMask, implies diffuse light should be set to 0 for this lightstate- See Also:
-
MASK_SPECULAR
public static final int MASK_SPECULARWhen applied to lightMask, implies specular light should be set to 0 for this lightstate- See Also:
-
MASK_GLOBALAMBIENT
public static final int MASK_GLOBALAMBIENTWhen applied to lightMask, implies global ambient light should be set to 0 for this lightstate- See Also:
-
lightMask
protected int lightMask -
backLightMask
protected int backLightMask -
twoSidedOn
protected boolean twoSidedOnWhen true, both sides of the model will be lighted. -
_globalAmbient
-
DEFAULT_GLOBAL_AMBIENT
-
localViewerOn
protected boolean localViewerOnWhen true, the eye position (as opposed to just the view direction) will be taken into account when computing specular reflections. -
separateSpecularOn
protected boolean separateSpecularOnWhen true, specular highlights will be computed separately and added to fragments after texturing.
-
-
Constructor Details
-
LightState
public LightState()Constructor instantiates a newLightState
object. Initially there are no lights set.
-
-
Method Details
-
getType
- Specified by:
getType
in classRenderState
- Returns:
- An statetype enum value for the subclass.
- See Also:
-
attach
attach
places a light in the queue to be processed. If there are already eight lights placed in the queue, the light is ignored and false is returned. Otherwise, true is returned to indicate success.- Parameters:
light
- the light to add to the queue.- Returns:
- true if the light was added successfully, false if there are already eight lights in the queue.
-
detach
detach
removes a light from the queue for processing.- Parameters:
light
- the light to be removed.
-
detachAll
public void detachAll()detachAll
clears the queue of all lights to be processed. -
getLightList
Retrieves all lights handled by this LightState- Returns:
- List of lights handled
-
get
get
retrieves a particular light defined by an index. If there exists no light at a particular index, null is returned.- Parameters:
i
- the index to retrieve the light from the queue.- Returns:
- the light at the given index, null if no light exists at this index.
-
getNumberOfChildren
public int getNumberOfChildren()getNumberOfChildren
returns the number of lights currently in the queue.- Returns:
- the number of lights currently in the queue.
-
setTwoSidedLighting
public void setTwoSidedLighting(boolean twoSidedOn) Sets if two sided lighting should be enabled for this LightState. Two sided lighting will cause the back of surfaces to be colored using the inverse of the surface normal as well as the Material properties set for MaterialFace.Back.- Parameters:
twoSidedOn
- If true, two sided lighting is enabled.
-
getTwoSidedLighting
public boolean getTwoSidedLighting()Returns the current state of two sided lighting for this LightState. By default, it is off.- Returns:
- True if two sided lighting is enabled.
-
setLocalViewer
public void setLocalViewer(boolean localViewerOn) Sets if local viewer mode should be enabled for this LightState.- Parameters:
localViewerOn
- If true, local viewer mode is enabled.
-
getLocalViewer
public boolean getLocalViewer()Returns the current state of local viewer mode for this LightState. By default, it is off.- Returns:
- True if local viewer mode is enabled.
-
setSeparateSpecular
public void setSeparateSpecular(boolean separateSpecularOn) Sets if separate specular mode should be enabled for this LightState.- Parameters:
separateSpecularOn
- If true, separate specular mode is enabled.
-
getSeparateSpecular
public boolean getSeparateSpecular()Returns the current state of separate specular mode for this LightState. By default, it is off.- Returns:
- True if separate specular mode is enabled.
-
setGlobalAmbient
-
getGlobalAmbient
- Returns:
- the global ambient color
-
getLightMask
public int getLightMask()- Returns:
- Returns the lightMask - default is 0 or not masked.
-
setLightMask
public void setLightMask(int lightMask) setLightMask
sets what attributes of this lightstate to apply as an int comprised of bitwise or'ed values.- Parameters:
lightMask
- The lightMask to set.
-
pushLightMask
public void pushLightMask()Saves the light mask to a back store. That backstore is recalled with popLightMask. Despite the name, this is not a stack and additional pushes will simply overwrite the backstored value. -
popLightMask
public void popLightMask()Recalls the light mask from a back store or 0 if none was pushed.- See Also:
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classRenderState
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classRenderState
- Throws:
IOException
-
extract
Description copied from class:RenderState
Extracts from the stack the correct renderstate that should apply to the given spatial. This is mainly used for RenderStates that can be cumulitive such as TextureState or LightState. By default, the top of the static is returned. This function should not be called by users directly.- Overrides:
extract
in classRenderState
- Parameters:
stack
- The stack to extract render states from.spat
- The spatial to apply the render states too.- Returns:
- The render state to use.
-
createStateRecord
- Specified by:
createStateRecord
in classRenderState
-