Class PointLight

java.lang.Object
com.jme3.light.Light
com.jme3.light.PointLight
All Implemented Interfaces:
Savable, Cloneable

public class PointLight extends Light
Represents a point light. A point light emits light from a given position into all directions in space. E.g a lamp or a bright effect. Point light positions are in world space.

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.

  • Field Details

    • position

      protected Vector3f position
    • radius

      protected float radius
    • invRadius

      protected float invRadius
  • Constructor Details

    • PointLight

      public PointLight()
      Creates a PointLight
    • PointLight

      public PointLight(Vector3f position)
      Creates a PointLight at the given position
      Parameters:
      position - the position in world space
    • PointLight

      public PointLight(Vector3f position, ColorRGBA color)
      Creates a PointLight at the given position and with the given color
      Parameters:
      position - the position in world space
      color - the light color
    • PointLight

      public PointLight(Vector3f position, ColorRGBA color, float radius)
      Creates a PointLight at the given position, with the given color and the given radius
      Parameters:
      position - the position in world space
      color - the light color
      radius - the light radius
    • PointLight

      public PointLight(Vector3f position, float radius)
      Creates a PointLight at the given position, with the given radius
      Parameters:
      position - the position in world space
      radius - the light radius
  • Method Details

    • computeLastDistance

      public void computeLastDistance(Spatial owner)
      Description copied from class: Light
      Used internally to compute the last distance value.
      Specified by:
      computeLastDistance in class Light
      Parameters:
      owner - the Spatial whose distance is to be determined
    • getPosition

      public Vector3f getPosition()
      Returns the world space position of the light.
      Returns:
      the world space position of the light.
      See Also:
    • setPosition

      public final void setPosition(Vector3f position)
      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

      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:
    • intersectsBox

      public boolean intersectsBox(BoundingBox box, TempVars vars)
      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, or point lights without influence radius, this method should always return true.

      Specified by:
      intersectsBox in 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.
    • intersectsSphere

      public boolean intersectsSphere(BoundingSphere sphere, TempVars vars)
      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, or point lights without influence radius, this method should always return true.

      Specified by:
      intersectsSphere in 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.
    • intersectsFrustum

      public boolean intersectsFrustum(Camera camera, TempVars vars)
      Description copied from class: Light
      Determines if the light intersects with the given camera frustum. For non-local lights, such as directional lights, ambient lights, or point lights without influence radius, this method should always return true.
      Specified by:
      intersectsFrustum in class Light
      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

      public void write(JmeExporter ex) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class Light
      Throws:
      IOException
    • read

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class Light
      Throws:
      IOException
    • clone

      public PointLight clone()
      Overrides:
      clone in class Light