Class DirectionalLight

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

public class DirectionalLight extends Light
DirectionalLight is a light coming from a certain direction in world space. E.g. sun or moon light.

Directional lights have no specific position in the scene, they always come from their direction regardless of where an object is placed.

  • Field Details

    • direction

      protected Vector3f direction
  • Constructor Details

    • DirectionalLight

      public DirectionalLight()
      Creates a DirectionalLight
    • DirectionalLight

      public DirectionalLight(Vector3f direction)
      Creates a DirectionalLight with the given direction
      Parameters:
      direction - the light's direction
    • DirectionalLight

      public DirectionalLight(Vector3f direction, ColorRGBA color)
      Creates a DirectionalLight with the given direction and the given color
      Parameters:
      direction - the light's direction
      color - the light's color
  • 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
    • getDirection

      public Vector3f getDirection()
      Returns the direction vector of the light.
      Returns:
      The direction vector of the light.
      See Also:
    • setDirection

      public final void setDirection(Vector3f dir)
      Sets the direction of the light.

      Represents the direction the light is shining. (1, 0, 0) would represent light shining in the +X direction.

      Parameters:
      dir - the direction of the light.
    • 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.
    • 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:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 DirectionalLight clone()
      Overrides:
      clone in class Light