Class Light

java.lang.Object
com.jme3.light.Light
All Implemented Interfaces:
Savable, Cloneable
Direct Known Subclasses:
AmbientLight, DirectionalLight, LightProbe, PointLight, SpotLight

public abstract class Light extends Object implements Savable, Cloneable
Abstract class for representing a light source.

All light source types have a color.

  • Field Details

    • color

      protected ColorRGBA color
    • lastDistance

      protected transient float lastDistance
      Used in LightList for caching the distance to the owner spatial. Should be reset after the sorting.
    • enabled

      protected boolean enabled
    • name

      protected String name
      The light name.
  • Constructor Details

    • Light

      protected Light()
    • Light

      protected Light(ColorRGBA color)
  • Method Details

    • getColor

      public ColorRGBA getColor()
      Returns the color of the light.
      Returns:
      The color of the light.
    • setName

      public void setName(String name)
      This method sets the light name.
      Parameters:
      name - the light name
    • getName

      public String getName()
      Return the light name.
      Returns:
      the light name
    • setColor

      public void setColor(ColorRGBA color)
      Sets the light color.
      Parameters:
      color - the light color.
    • isEnabled

      public boolean isEnabled()
      Returns true if this light is enabled.
      Returns:
      true if enabled, otherwise false.
    • setEnabled

      public void setEnabled(boolean enabled)
      Set to false in order to disable a light and have it filtered out from being included in rendering.
      Parameters:
      enabled - true to enable and false to disable the light.
    • isFrustumCheckNeeded

      public boolean isFrustumCheckNeeded()
    • setFrustumCheckNeeded

      public void setFrustumCheckNeeded(boolean frustumCheckNeeded)
    • isIntersectsFrustum

      public boolean isIntersectsFrustum()
    • setIntersectsFrustum

      public void setIntersectsFrustum(boolean intersectsFrustum)
    • intersectsBox

      public abstract boolean intersectsBox(BoundingBox box, TempVars vars)
      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.

      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 abstract boolean intersectsSphere(BoundingSphere sphere, TempVars vars)
      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.

      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 abstract boolean intersectsFrustum(Camera camera, TempVars vars)
      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.
      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.
    • clone

      public Light clone()
      Overrides:
      clone in class Object
    • write

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

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • computeLastDistance

      protected abstract void computeLastDistance(Spatial owner)
      Used internally to compute the last distance value.
      Parameters:
      owner - the Spatial whose distance is to be determined
    • getType

      public abstract Light.Type getType()
      Returns the light type
      Returns:
      the light type
      See Also: