Module technology.sola.engine
Class LightComponent
java.lang.Object
technology.sola.engine.graphics.components.LightComponent
- All Implemented Interfaces:
technology.sola.ecs.Component
LightComponent is a
Component
containing data for rendering lights.-
Constructor Summary
ConstructorsConstructorDescriptionLightComponent
(float radius) Creates a fully bright, white point light with radius.LightComponent
(float radius, Color color) Creates a point light with radius andColor
. -
Method Summary
Modifier and TypeMethodDescriptionfloat
calculateAttenuation
(float distance) Calculates the attenuation of the light for a distance.getColor()
float
float
float
setAttenuationConstants
(float c1, float c2, float c3) Sets the attenuation calculation constants.void
Sets theColor
of the light.setLightFlicker
(@Nullable LightFlicker lightFlicker) Sets theLightFlicker
to use or null if no flicker is desired.setOffset
(float x, float y) Sets a positional offset for the light.void
setRadius
(float radius) Sets the radius of the light.void
tickFlicker
(float deltaTime) Method called each from to tick the state of this light's flickering if aLightFlicker
has been set.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface technology.sola.ecs.Component
afterDeserialize
-
Constructor Details
-
LightComponent
public LightComponent(float radius) Creates a fully bright, white point light with radius.- Parameters:
radius
- the radius of the point light
-
LightComponent
Creates a point light with radius andColor
.- Parameters:
radius
- the radius of the point lightcolor
- the color of the light
-
-
Method Details
-
tickFlicker
public void tickFlicker(float deltaTime) Method called each from to tick the state of this light's flickering if aLightFlicker
has been set.- Parameters:
deltaTime
- the delta time of the frame
-
calculateAttenuation
public float calculateAttenuation(float distance) Calculates the attenuation of the light for a distance.1.0 / (c1 + (c2 * d) + (c3 * d^2))
- Parameters:
distance
- the distance to calculate for- Returns:
- the attenuation
-
setAttenuationConstants
Sets the attenuation calculation constants.1.0 / (c1 + (c2 * d) + (c3 * d^2))
- Parameters:
c1
- constant value (1 is a good value)c2
- linear constantc3
- quadratic constant- Returns:
- this
-
getRadius
public float getRadius()- Returns:
- the radius of the light
-
getColor
- Returns:
- the
Color
of the light
-
setRadius
public void setRadius(float radius) Sets the radius of the light.- Parameters:
radius
- the new radius
-
setColor
Sets theColor
of the light.- Parameters:
color
- the new color
-
setOffset
Sets a positional offset for the light.- Parameters:
x
- the x offsety
- the y offset- Returns:
- this
-
getOffsetX
public float getOffsetX()- Returns:
- the x positional offset
-
getOffsetY
public float getOffsetY()- Returns:
- the y positional offset
-
setLightFlicker
Sets theLightFlicker
to use or null if no flicker is desired.- Parameters:
lightFlicker
- the new light flicker behavior- Returns:
- this
-