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 SummaryNested classes/interfaces inherited from class com.jme3.light.LightLight.Type
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Vector3fprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected Vector3fprotected floatprotected floatprotected floatFields inherited from class com.jme3.light.Lightcolor, enabled, lastDistance, name
- 
Constructor SummaryConstructorsConstructorDescriptionCreates 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 SummaryModifier 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.LightgetColor, getName, isEnabled, isFrustumCheckNeeded, isIntersectsFrustum, setColor, setEnabled, setFrustumCheckNeeded, setIntersectsFrustum, setName
- 
Field Details- 
position
- 
direction
- 
spotInnerAngleprotected float spotInnerAngle
- 
spotOuterAngleprotected float spotOuterAngle
- 
spotRangeprotected float spotRange
- 
invSpotRangeprotected float invSpotRange
- 
packedAngleCosprotected float packedAngleCos
- 
outerAngleCosSqrprotected float outerAngleCosSqr
- 
outerAngleSinSqrprotected float outerAngleSinSqr
- 
outerAngleSinRcpprotected float outerAngleSinRcp
- 
outerAngleSinprotected float outerAngleSin
- 
outerAngleCosprotected float outerAngleCos
 
- 
- 
Constructor Details- 
SpotLightpublic SpotLight()Creates a SpotLight.
- 
SpotLightCreates a SpotLight at the given position and with the given direction.- Parameters:
- position- the position in world space.
- direction- the direction of the light.
 
- 
SpotLightCreates 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
 
- 
SpotLightCreates 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.
 
- 
SpotLightCreates 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 range
- color- the light's color.
 
- 
SpotLightpublic 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 range
- color- the light's color.
- innerAngle- the inner angle of the spotlight.
- outerAngle- the outer angle of the spotlight.
- See Also:
 
 
- 
- 
Method Details- 
intersectsBoxDescription 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 class- Light
- 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.
 
- 
intersectsSphereDescription 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 class- Light
- 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.
 
- 
intersectsFrustumDescription 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 class- Light
- 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.
 
- 
computeLastDistanceDescription copied from class:LightUsed internally to compute the last distance value.- Specified by:
- computeLastDistancein class- Light
- Parameters:
- owner- the Spatial whose distance is to be determined
 
- 
getTypeDescription copied from class:LightReturns the light type
- 
getDirection
- 
setDirection
- 
getPosition
- 
setPosition
- 
getSpotRangepublic float getSpotRange()
- 
setSpotRangepublic 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
 
- 
getInvSpotRangepublic float getInvSpotRange()for internal use only- Returns:
- the inverse of the spot range
 
- 
getSpotInnerAnglepublic float getSpotInnerAngle()returns the spot inner angle- Returns:
- the spot inner angle
 
- 
setSpotInnerAnglepublic 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)
 
- 
getSpotOuterAnglepublic float getSpotOuterAngle()returns the spot outer angle- Returns:
- the spot outer angle
 
- 
setSpotOuterAnglepublic 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)
 
- 
getPackedAngleCospublic float getPackedAngleCos()for internal use only- Returns:
- the cosines of the inner and outer angle packed in a float
 
- 
write- Specified by:
- writein interface- Savable
- Overrides:
- writein class- Light
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- Light
- Throws:
- IOException
 
- 
clone
 
-