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.
    • global

      protected boolean global
  • Constructor Details

    • Light

      protected Light()
    • Light

      protected Light(boolean global)
    • Light

      protected Light(ColorRGBA color, boolean global)
    • Light

      protected Light(ColorRGBA color)
  • Method Details

    • isGlobal

      public boolean isGlobal()
      Returns true if this light affects the entire tree from the root node, otherwise returns false, meaning it only affects the children of the node in which it is attached.
      Returns:
      true if the light is global, otherwise false.
    • 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: