com.jme3.light
Class SpotLight

java.lang.Object
  extended by com.jme3.light.Light
      extended by com.jme3.light.SpotLight
All Implemented Interfaces:
Savable, java.lang.Cloneable

public class SpotLight
extends Light
implements Savable

Represents a spot light. A spot light emmit a cone of light from a position and in a direction. It can be used to fake torch lights or car's lights.

In addition to a position and a direction, spot lights also have a range which can be used to attenuate the influence of the light depending on the distance between the light and the effected object. Also the angle of the cone can be tweaked by changing the spot inner angle and the spot outer angle. the spot inner angle determin the cone of light where light has full influence. the spot outer angle determin the cone global cone of light of the spot light. the light intensity slowly decrease between the inner cone and the outer cone.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme3.light.Light
Light.Type
 
Field Summary
protected  Vector3f direction
           
protected  float invSpotRange
           
protected  float packedAngleCos
           
protected  Vector3f position
           
protected  float spotInnerAngle
           
protected  float spotOuterAngle
           
protected  float spotRange
           
 
Fields inherited from class com.jme3.light.Light
color, enabled, lastDistance, name
 
Constructor Summary
SpotLight()
           
 
Method Summary
protected  void computeLastDistance(Spatial owner)
          Used internally to compute the last distance value.
 Vector3f getDirection()
           
 float getInvSpotRange()
          for internal use only
 float getPackedAngleCos()
          for internal use only
 Vector3f getPosition()
           
 float getSpotInnerAngle()
          returns the spot inner angle
 float getSpotOuterAngle()
          returns the spot outer angle
 float getSpotRange()
           
 Light.Type getType()
          Returns the light type
 void read(JmeImporter im)
           
 void setDirection(Vector3f direction)
           
 void setPosition(Vector3f position)
           
 void setSpotInnerAngle(float spotInnerAngle)
          Sets the inner angle of the cone of influence.
 void setSpotOuterAngle(float spotOuterAngle)
          Sets the outer angle of the cone of influence.
 void setSpotRange(float spotRange)
          Set the range of the light influence.
 void write(JmeExporter ex)
           
 
Methods inherited from class com.jme3.light.Light
clone, getColor, getName, setColor, setName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

position

protected Vector3f position

direction

protected Vector3f direction

spotInnerAngle

protected float spotInnerAngle

spotOuterAngle

protected float spotOuterAngle

spotRange

protected float spotRange

invSpotRange

protected float invSpotRange

packedAngleCos

protected float packedAngleCos
Constructor Detail

SpotLight

public SpotLight()
Method Detail

computeLastDistance

protected void computeLastDistance(Spatial owner)
Description copied from class: Light
Used internally to compute the last distance value.

Specified by:
computeLastDistance in class Light

getType

public Light.Type getType()
Description copied from class: Light
Returns the light type

Specified by:
getType in class Light
Returns:
the light type
See Also:
Light.Type

getDirection

public Vector3f getDirection()

setDirection

public void setDirection(Vector3f direction)

getPosition

public Vector3f getPosition()

setPosition

public void setPosition(Vector3f position)

getSpotRange

public float getSpotRange()

setSpotRange

public void setSpotRange(float spotRange)
Set the range of the light influence.

Setting a non-zero range indicates the light should use attenuation. If a pixel's distance to this light's position is greater than the light's range, then the pixel will not be effected by this light, if the distance is less than the range, then the magnitude of the influence is equal to distance / range.

Parameters:
spotRange - the range of the light influence.
Throws:
java.lang.IllegalArgumentException - If spotRange is negative

getInvSpotRange

public float getInvSpotRange()
for internal use only

Returns:
the inverse of the spot range

getSpotInnerAngle

public float getSpotInnerAngle()
returns the spot inner angle

Returns:
the spot inner angle

setSpotInnerAngle

public void setSpotInnerAngle(float spotInnerAngle)
Sets the inner angle of the cone of influence. This angle is the angle between the spot direction axis and the inner border of the cone of influence.

Parameters:
spotInnerAngle -

getSpotOuterAngle

public float getSpotOuterAngle()
returns the spot outer angle

Returns:
the spot outer angle

setSpotOuterAngle

public void setSpotOuterAngle(float spotOuterAngle)
Sets the outer angle of the cone of influence. This angle is the angle between the spot direction axis and the outer border of the cone of influence. this should be greater than the inner angle or the result will be unexpected.

Parameters:
spotOuterAngle -

getPackedAngleCos

public float getPackedAngleCos()
for internal use only

Returns:
the cosines of the inner and outter angle packed in a float

write

public void write(JmeExporter ex)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class Light
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class Light
Throws:
java.io.IOException