Class SpotLight
In addition to a position and a direction, spotlights also have a range which can be used to attenuate the influence of the light depending on the distance between the light and the affected 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 determines the cone where light has full influence. The spot outer angle determines the global cone of light. The light intensity slowly decreases from the inner cone to the outer cone.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.light.Light
Light.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Vector3fprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected Vector3fprotected floatprotected floatprotected floatFields inherited from class com.jme3.light.Light
color, enabled, lastDistance, name -
Constructor Summary
ConstructorsConstructorDescriptionCreates a SpotLight.Creates a SpotLight at the given position and with the given direction.Creates a SpotLight at the given position, with the given direction, and the given range.Creates a SpotLight at the given position, with the given direction, the given range and the given color.SpotLight(Vector3f position, Vector3f direction, float range, ColorRGBA color, float innerAngle, float outerAngle) Creates a SpotLight at the given position, with the given direction, the given color and the given inner and outer angles (controls the falloff of the light)Creates a SpotLight at the given position, with the given direction and the given color. -
Method Summary
Modifier and TypeMethodDescriptionclone()protected voidcomputeLastDistance(Spatial owner) Used internally to compute the last distance value.floatfor internal use onlyfloatfor internal use onlyfloatreturns the spot inner anglefloatreturns the spot outer anglefloatgetType()Returns the light typebooleanintersectsBox(BoundingBox box, TempVars vars) Determines if the light intersects with the given bounding box.booleanintersectsFrustum(Camera cam, TempVars vars) Determines if the light intersects with the given camera frustum.booleanintersectsSphere(BoundingSphere sphere, TempVars vars) Determines if the light intersects with the given bounding sphere.voidread(JmeImporter im) final voidsetDirection(Vector3f direction) final voidsetPosition(Vector3f position) voidsetSpotInnerAngle(float spotInnerAngle) Sets the inner angle of the cone of influence.voidsetSpotOuterAngle(float spotOuterAngle) Sets the outer angle of the cone of influence.voidsetSpotRange(float spotRange) Set the range of the light influence.voidwrite(JmeExporter ex) Methods inherited from class com.jme3.light.Light
getColor, getName, isEnabled, isFrustumCheckNeeded, isIntersectsFrustum, setColor, setEnabled, setFrustumCheckNeeded, setIntersectsFrustum, setName
-
Field Details
-
position
-
direction
-
spotInnerAngle
protected float spotInnerAngle -
spotOuterAngle
protected float spotOuterAngle -
spotRange
protected float spotRange -
invSpotRange
protected float invSpotRange -
packedAngleCos
protected float packedAngleCos -
outerAngleCosSqr
protected float outerAngleCosSqr -
outerAngleSinSqr
protected float outerAngleSinSqr -
outerAngleSinRcp
protected float outerAngleSinRcp -
outerAngleSin
protected float outerAngleSin -
outerAngleCos
protected float outerAngleCos
-
-
Constructor Details
-
SpotLight
public SpotLight()Creates a SpotLight. -
SpotLight
Creates a SpotLight at the given position and with the given direction.- Parameters:
position- the position in world space.direction- the direction of the light.
-
SpotLight
Creates a SpotLight at the given position, with the given direction, and the given range.- Parameters:
position- the position in world space.direction- the direction of the light.range- the spotlight range
-
SpotLight
Creates a SpotLight at the given position, with the given direction and the given color.- Parameters:
position- the position in world space.direction- the direction of the light.color- the light's color.
-
SpotLight
Creates a SpotLight at the given position, with the given direction, the given range and the given color.- Parameters:
position- the position in world space.direction- the direction of the light.range- the spotlight rangecolor- the light's color.
-
SpotLight
public SpotLight(Vector3f position, Vector3f direction, float range, ColorRGBA color, float innerAngle, float outerAngle) Creates a SpotLight at the given position, with the given direction, the given color and the given inner and outer angles (controls the falloff of the light)- Parameters:
position- the position in world space.direction- the direction of the light.range- the spotlight rangecolor- the light's color.innerAngle- the inner angle of the spotlight.outerAngle- the outer angle of the spotlight.- See Also:
-
-
Method Details
-
intersectsBox
Description copied from class:LightDetermines if the light intersects with the given bounding box.For non-local lights, such as
directional lights,ambient lights, orpoint lightswithout influence radius, this method should always return true.- Specified by:
intersectsBoxin classLight- Parameters:
box- The box to check intersection against.vars- TempVars in case it is needed.- Returns:
- True if the light intersects the box, false otherwise.
-
intersectsSphere
Description copied from class:LightDetermines if the light intersects with the given bounding sphere.For non-local lights, such as
directional lights,ambient lights, orpoint lightswithout influence radius, this method should always return true.- Specified by:
intersectsSpherein classLight- Parameters:
sphere- The sphere to check intersection against.vars- TempVars in case it is needed.- Returns:
- True if the light intersects the sphere, false otherwise.
-
intersectsFrustum
Description copied from class:LightDetermines if the light intersects with the given camera frustum. For non-local lights, such asdirectional lights,ambient lights, orpoint lightswithout influence radius, this method should always return true.- Specified by:
intersectsFrustumin classLight- Parameters:
cam- The camera frustum to check intersection against.vars- TempVars in case it is needed.- Returns:
- True if the light intersects the frustum, false otherwise.
-
computeLastDistance
Description copied from class:LightUsed internally to compute the last distance value.- Specified by:
computeLastDistancein classLight- Parameters:
owner- the Spatial whose distance is to be determined
-
getType
Description copied from class:LightReturns the light type -
getDirection
-
setDirection
-
getPosition
-
setPosition
-
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 affected 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:
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.Must be between 0 and pi/2.
This angle is the angle between the spot direction axis and the inner border of the cone of influence.
- Parameters:
spotInnerAngle- the desired angle (in radians, ≥0, ≤Pi/2)
-
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.Must be between 0 and pi/2.
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- the desired angle (in radians, ≥0, ≤Pi/2)
-
getPackedAngleCos
public float getPackedAngleCos()for internal use only- Returns:
- the cosines of the inner and outer angle packed in a float
-
write
- Specified by:
writein interfaceSavable- Overrides:
writein classLight- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Overrides:
readin classLight- Throws:
IOException
-
clone
-