Class PointLight
In addition to a position, point lights also have a radius which can be used to attenuate the influence of the light depending on the distance between the light and the affected object.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.light.Light
Light.Type
-
Field Summary
Fields inherited from class com.jme3.light.Light
color, enabled, lastDistance, name
-
Constructor Summary
ConstructorDescriptionCreates a PointLightPointLight
(Vector3f position) Creates a PointLight at the given positionPointLight
(Vector3f position, float radius) Creates a PointLight at the given position, with the given radiusPointLight
(Vector3f position, ColorRGBA color) Creates a PointLight at the given position and with the given colorPointLight
(Vector3f position, ColorRGBA color, float radius) Creates a PointLight at the given position, with the given color and the given radius -
Method Summary
Modifier and TypeMethodDescriptionclone()
void
computeLastDistance
(Spatial owner) Used internally to compute the last distance value.float
for internal use onlyReturns the world space position of the light.float
Returns the radius of the light influence.getType()
Returns the light typeboolean
intersectsBox
(BoundingBox box, TempVars vars) Determines if the light intersects with the given bounding box.boolean
intersectsFrustum
(Camera camera, TempVars vars) Determines if the light intersects with the given camera frustum.boolean
intersectsSphere
(BoundingSphere sphere, TempVars vars) Determines if the light intersects with the given bounding sphere.void
read
(JmeImporter im) final void
setPosition
(Vector3f position) Set the world space position of the light.final void
setRadius
(float radius) Set the radius of the light influence.void
write
(JmeExporter ex) Methods inherited from class com.jme3.light.Light
getColor, getName, isEnabled, isFrustumCheckNeeded, isIntersectsFrustum, setColor, setEnabled, setFrustumCheckNeeded, setIntersectsFrustum, setName
-
Field Details
-
position
-
radius
protected float radius -
invRadius
protected float invRadius
-
-
Constructor Details
-
PointLight
public PointLight()Creates a PointLight -
PointLight
Creates a PointLight at the given position- Parameters:
position
- the position in world space
-
PointLight
Creates a PointLight at the given position and with the given color- Parameters:
position
- the position in world spacecolor
- the light color
-
PointLight
Creates a PointLight at the given position, with the given color and the given radius- Parameters:
position
- the position in world spacecolor
- the light colorradius
- the light radius
-
PointLight
Creates a PointLight at the given position, with the given radius- Parameters:
position
- the position in world spaceradius
- the light radius
-
-
Method Details
-
computeLastDistance
Description copied from class:Light
Used internally to compute the last distance value.- Specified by:
computeLastDistance
in classLight
- Parameters:
owner
- the Spatial whose distance is to be determined
-
getPosition
Returns the world space position of the light.- Returns:
- the world space position of the light.
- See Also:
-
setPosition
Set the world space position of the light.- Parameters:
position
- the world space position of the light.
-
getRadius
public float getRadius()Returns the radius of the light influence. A radius of 0 means the light has no attenuation.- Returns:
- the radius of the light
-
setRadius
public final void setRadius(float radius) Set the radius of the light influence.Setting a non-zero radius indicates the light should use attenuation. If a pixel's distance to this light's position is greater than the light's radius, then the pixel will not be affected by this light, if the distance is less than the radius, then the magnitude of the influence is equal to distance / radius.
- Parameters:
radius
- the radius of the light influence.- Throws:
IllegalArgumentException
- If radius is negative
-
getInvRadius
public float getInvRadius()for internal use only- Returns:
- the inverse of the radius
-
getType
Description copied from class:Light
Returns the light type -
intersectsBox
Description copied from class:Light
Determines if the light intersects with the given bounding box.For non-local lights, such as
directional lights
,ambient lights
, orpoint lights
without influence radius, this method should always return true.- Specified by:
intersectsBox
in 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:Light
Determines if the light intersects with the given bounding sphere.For non-local lights, such as
directional lights
,ambient lights
, orpoint lights
without influence radius, this method should always return true.- Specified by:
intersectsSphere
in 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:Light
Determines if the light intersects with the given camera frustum. For non-local lights, such asdirectional lights
,ambient lights
, orpoint lights
without influence radius, this method should always return true.- Specified by:
intersectsFrustum
in classLight
- Parameters:
camera
- The camera frustum to check intersection against.vars
- TempVars in case it is needed.- Returns:
- True if the light intersects the frustum, false otherwise.
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classLight
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classLight
- Throws:
IOException
-
clone
-