Package com.ardor3d.light
Class Light
java.lang.Object
com.ardor3d.light.Light
- All Implemented Interfaces:
Savable
,Serializable
- Direct Known Subclasses:
DirectionalLight
,PointLight
Light
defines the attributes of a light element. This class is abstract and intended to be sub-classed
by specific lighting types. A light will illuminate portions of the scene by assigning its properties to the objects
in the scene. This will affect the objects color values, depending on the color of the ambient, diffuse and specular
light components.
Ambient light defines the general light of the scene, that is the intensity and color of lighting if no particular
lights are affecting it.
Diffuse lighting defines the reflection of light on matte surfaces.
Specular lighting defines the reflection of light on shiny surfaces.- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
when true, indicates the lights in this lightState will cast shadows.static final ReadOnlyColorRGBA
dark grey (.4, .4, .4, 1)static final ReadOnlyColorRGBA
white (1, 1, 1, 1)static final ReadOnlyColorRGBA
white (1, 1, 1, 1) -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Copies the light values from the given light into this Light.getAmbient
returns the ambient color value for this light.float
getConstant
returns the value for the constant attenuation.getDiffuse
returns the diffuse color value for this light.int
float
getLinear
returns the value for the linear attenuation.getName()
float
getQuadratic
returns the value for the quadratic attentuation.getSpecular
returns the specular color value for this light.abstract Light.Type
getType()
getType
returns the type of the light that has been created.boolean
isAttenuate
returns true if attenuation is to be used for this light.boolean
isEnabled
returns true if the light is enabled, false otherwise.boolean
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
setAmbient
(ReadOnlyColorRGBA ambient) setAmbient
sets the ambient color value for this light.void
setAttenuate
(boolean attenuate) setAttenuate
sets if attenuation is to be used.void
setConstant
(float constant) setConstant
sets the value for the constant attentuation.void
setDiffuse
(ReadOnlyColorRGBA diffuse) setDiffuse
sets the diffuse color value for this light.void
setEnabled
(boolean value) setEnabled
sets the light on or off.void
setLightMask
(int lightMask) setLightMask
sets what attributes of this light to apply as an int comprised of bitwise |'ed values from LightState.Mask_XXXX.void
setLinear
(float linear) setLinear
sets the value for the linear attentuation.void
void
setQuadratic
(float quadratic) setQuadratic
sets the value for the quadratic attenuation.void
setShadowCaster
(boolean mayCastShadows) void
setSpecular
(ReadOnlyColorRGBA specular) setSpecular
sets the specular color value for this light.void
write
(OutputCapsule capsule)
-
Field Details
-
DEFAULT_AMBIENT
dark grey (.4, .4, .4, 1) -
DEFAULT_DIFFUSE
white (1, 1, 1, 1) -
DEFAULT_SPECULAR
white (1, 1, 1, 1) -
_shadowCaster
protected boolean _shadowCasterwhen true, indicates the lights in this lightState will cast shadows.
-
-
Constructor Details
-
Light
public Light()Constructor instantiates a newLight
object. All light color values are set to white.
-
-
Method Details
-
getType
getType
returns the type of the light that has been created.- Returns:
- the type of light that has been created.
-
getConstant
public float getConstant()getConstant
returns the value for the constant attenuation.- Returns:
- the value for the constant attenuation.
-
setConstant
public void setConstant(float constant) setConstant
sets the value for the constant attentuation.- Parameters:
constant
- the value for the constant attenuation.
-
getLinear
public float getLinear()getLinear
returns the value for the linear attenuation.- Returns:
- the value for the linear attenuation.
-
setLinear
public void setLinear(float linear) setLinear
sets the value for the linear attentuation.- Parameters:
linear
- the value for the linear attenuation.
-
getQuadratic
public float getQuadratic()getQuadratic
returns the value for the quadratic attentuation.- Returns:
- the value for the quadratic attenuation.
-
setQuadratic
public void setQuadratic(float quadratic) setQuadratic
sets the value for the quadratic attenuation.- Parameters:
quadratic
- the value for the quadratic attenuation.
-
isAttenuate
public boolean isAttenuate()isAttenuate
returns true if attenuation is to be used for this light.- Returns:
- true if attenuation is to be used, false otherwise.
-
setAttenuate
public void setAttenuate(boolean attenuate) setAttenuate
sets if attenuation is to be used. True sets it on, false otherwise.- Parameters:
attenuate
- true to use attenuation, false not to.
-
isEnabled
public boolean isEnabled()isEnabled
returns true if the light is enabled, false otherwise.- Returns:
- true if the light is enabled, false if it is not.
-
setEnabled
public void setEnabled(boolean value) setEnabled
sets the light on or off. True turns it on, false turns it off.- Parameters:
value
- true to turn the light on, false to turn it off.
-
getSpecular
getSpecular
returns the specular color value for this light.- Returns:
- the specular color value of the light.
-
setSpecular
setSpecular
sets the specular color value for this light.- Parameters:
specular
- the specular color value of the light.
-
getDiffuse
getDiffuse
returns the diffuse color value for this light.- Returns:
- the diffuse color value for this light.
-
setDiffuse
setDiffuse
sets the diffuse color value for this light.- Parameters:
diffuse
- the diffuse color value for this light.
-
getAmbient
getAmbient
returns the ambient color value for this light.- Returns:
- the ambient color value for this light.
-
setAmbient
setAmbient
sets the ambient color value for this light.- Parameters:
ambient
- the ambient color value for this light.
-
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 light to apply as an int comprised of bitwise |'ed values from LightState.Mask_XXXX. LightMask.MASK_GLOBALAMBIENT is ignored.- 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:
-
isShadowCaster
public boolean isShadowCaster()- Returns:
- Returns whether this light is able to cast shadows.
-
setShadowCaster
public void setShadowCaster(boolean mayCastShadows) - Parameters:
mayCastShadows
- true if this light can be used to derive shadows (when used in conjunction with a shadow pass.)
-
copyFrom
Copies the light values from the given light into this Light.- Parameters:
light
- the Light to copy from.
-
getName
-
setName
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-