java.lang.Object
technology.sola.engine.graphics.components.LightComponent
All Implemented Interfaces:
technology.sola.ecs.Component

@NullMarked public class LightComponent extends Object implements technology.sola.ecs.Component
LightComponent is a Component containing data for rendering lights.
  • 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

      public LightComponent(float radius, Color color)
      Creates a point light with radius and Color.
      Parameters:
      radius - the radius of the point light
      color - 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 a LightFlicker 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

      public LightComponent setAttenuationConstants(float c1, float c2, float c3)
      Sets the attenuation calculation constants.
       1.0 / (c1 + (c2 * d) + (c3 * d^2))
       
      Parameters:
      c1 - constant value (1 is a good value)
      c2 - linear constant
      c3 - quadratic constant
      Returns:
      this
    • getRadius

      public float getRadius()
      Returns:
      the radius of the light
    • getColor

      public Color 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

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

      public LightComponent setOffset(float x, float y)
      Sets a positional offset for the light.
      Parameters:
      x - the x offset
      y - the y offset
      Returns:
      this
    • getOffsetX

      public float getOffsetX()
      Returns:
      the x positional offset
    • getOffsetY

      public float getOffsetY()
      Returns:
      the y positional offset
    • setLightFlicker

      public LightComponent setLightFlicker(@Nullable LightFlicker lightFlicker)
      Sets the LightFlicker to use or null if no flicker is desired.
      Parameters:
      lightFlicker - the new light flicker behavior
      Returns:
      this