java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.lighting.LightSource

public class LightSource extends Object
Represents a light source in the 3D scene with position, color, and intensity.

Light sources emit colored light that illuminates polygons based on their orientation relative to the light. The intensity of illumination follows the Lambert cosine law - surfaces facing the light receive full intensity, while surfaces at an angle receive proportionally less light.

Usage example:


 // Create a yellow light source at position (100, -50, 200)
 LightSource light = new LightSource(
     new Point3D(100, -50, 200),
     Color.YELLOW,
     1.5
 );

 // Move the light source
 light.setPosition(new Point3D(0, 0, 300));

 // Change the light color
 light.setColor(new Color(255, 100, 50));

 // Adjust intensity
 light.setIntensity(2.0);
 
See Also:
  • Constructor Details

    • LightSource

      public LightSource(Point3D position, Color color, double intensity)
      Creates a new light source at the specified position with the given color and intensity.
      Parameters:
      position - the position of the light in world space
      color - the color of the light
      intensity - the intensity multiplier (1.0 = normal brightness)
    • LightSource

      public LightSource(Point3D position, Color color)
      Creates a new light source at the specified position with the given color. Default intensity is 1.0.
      Parameters:
      position - the position of the light in world space
      color - the color of the light
  • Method Details

    • getColor

      public Color getColor()
      Returns the color of this light source.
      Returns:
      the light color
    • getIntensity

      public double getIntensity()
      Returns the intensity multiplier of this light source.
      Returns:
      the intensity multiplier
    • getPosition

      public Point3D getPosition()
      Returns the position of this light source.
      Returns:
      the position in world space
    • setColor

      public void setColor(Color color)
      Sets the color of this light source.
      Parameters:
      color - the new light color
    • setIntensity

      public void setIntensity(double intensity)
      Sets the intensity multiplier of this light source.
      Parameters:
      intensity - the new intensity multiplier (1.0 = normal brightness)
    • setPosition

      public void setPosition(Point3D position)
      Sets the position of this light source.
      Parameters:
      position - the new position in world space