Class LightSource
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.lighting.LightSource
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 Summary
ConstructorsConstructorDescriptionLightSource(Point3D position, Color color) Creates a new light source at the specified position with the given color.LightSource(Point3D position, Color color, double intensity) Creates a new light source at the specified position with the given color and intensity. -
Method Summary
Modifier and TypeMethodDescriptiongetColor()Returns the color of this light source.doubleReturns the intensity multiplier of this light source.Returns the position of this light source.voidSets the color of this light source.voidsetIntensity(double intensity) Sets the intensity multiplier of this light source.voidsetPosition(Point3D position) Sets the position of this light source.
-
Constructor Details
-
LightSource
Creates a new light source at the specified position with the given color and intensity.- Parameters:
position- the position of the light in world spacecolor- the color of the lightintensity- the intensity multiplier (1.0 = normal brightness)
-
LightSource
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 spacecolor- the color of the light
-
-
Method Details
-
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
Returns the position of this light source.- Returns:
- the position in world space
-
setColor
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
Sets the position of this light source.- Parameters:
position- the new position in world space
-