com.jme.scene.state
Class LightState

java.lang.Object
  extended bycom.jme.scene.state.RenderState
      extended bycom.jme.scene.state.LightState
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
LWJGLLightState

public abstract class LightState
extends RenderState

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.

Version:
$Id: LightState.java,v 1.9 2004/08/01 23:40:28 cep21 Exp $
Author:
Mark Powell
See Also:
Serialized Form

Field Summary
static int COMBINE_CLOSEST
          Combine light states starting from the given Spatial and working towards the root.
static int COMBINE_FIRST
          Combine light states starting from the root node and working towards the given Spatial.
static int COMBINE_RECENT_ENABLED
          Similar to COMBINE_CLOSEST, but if a disabled state is encountered, it will stop combining at that point.
static int INHERIT
          Inherit mode from parent.
static int MAX_LIGHTS_ALLOWED
          defines the maximum number of lights that are allowed to be maintained at one time.
static int OFF
          Ignore lights.
static int REPLACE
          Do not combine light states, just use the most recent one.
protected  boolean twoSidedOn
          When true, both sides of the model will be lighted.
 
Fields inherited from class com.jme.scene.state.RenderState
RS_ALPHA, RS_ATTRIBUTE, RS_CULL, RS_DITHER, RS_FOG, RS_FRAGMENT_PROGRAM, RS_GLSL_SHADER_OBJECTS, RS_LIGHT, RS_MATERIAL, RS_MAX_STATE, RS_SHADE, RS_STENCIL, RS_TEXTURE, RS_VERTEX_PROGRAM, RS_WIREFRAME, RS_ZBUFFER
 
Constructor Summary
LightState()
          Constructor instantiates a new LightState object.
 
Method Summary
 boolean attach(Light light)
          attach places a light in the queue to be processed.
 void detach(Light light)
          detach removes a light from the queue for processing.
 void detachAll()
          detachAll clears the queue of all lights to be processed.
 Light get(int i)
          get retrieves a particular light defined by an index.
 int getQuantity()
          getQuantity returns the number of lights currently in the queue.
 boolean getTwoSidedLighting()
          Returns the current state of two sided lighting for this LightState.
 int getType()
          getType returns the type of render state this is.
 void setTwoSidedLighting(boolean twoSidedOn)
          Sets if two sided lighting should be enabled for this LightState.
 
Methods inherited from class com.jme.scene.state.RenderState
apply, extract, isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_LIGHTS_ALLOWED

public static final int MAX_LIGHTS_ALLOWED
defines the maximum number of lights that are allowed to be maintained at one time.

See Also:
Constant Field Values

OFF

public static final int OFF
Ignore lights.

See Also:
Constant Field Values

COMBINE_FIRST

public static final int COMBINE_FIRST
Combine light states starting from the root node and working towards the given Spatial. Ignore disabled states. Stop combining when lights == MAX_LIGHTS_ALLOWED

See Also:
Constant Field Values

COMBINE_CLOSEST

public static final int COMBINE_CLOSEST
Combine light states starting from the given Spatial and working towards the root. Ignore disabled states. Stop combining when lights == MAX_LIGHTS_ALLOWED

See Also:
Constant Field Values

COMBINE_RECENT_ENABLED

public static final int COMBINE_RECENT_ENABLED
Similar to COMBINE_CLOSEST, but if a disabled state is encountered, it will stop combining at that point. Stop combining when lights == MAX_LIGHTS_ALLOWED

See Also:
Constant Field Values

INHERIT

public static final int INHERIT
Inherit mode from parent.

See Also:
Constant Field Values

REPLACE

public static final int REPLACE
Do not combine light states, just use the most recent one.

See Also:
Constant Field Values

twoSidedOn

protected boolean twoSidedOn
When true, both sides of the model will be lighted.

Constructor Detail

LightState

public LightState()
Constructor instantiates a new LightState object. Initially there are no lights set.

Method Detail

getType

public int getType()
getType returns the type of render state this is. (RS_LIGHT).

Specified by:
getType in class RenderState
Returns:
An int identifying this render state.
See Also:
RenderState.getType()

attach

public boolean attach(Light light)
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

public void detach(Light light)
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.


get

public Light get(int i)
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.

getQuantity

public int getQuantity()
getQuantity 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.

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.