Class LightEngine



  • public class LightEngine
    extends java.lang.Object
    This Light engine calculates phong shading for three normals over the day. The data is relative to a position on a map because the lighting can be different on different positions on the map.
    Since:
    WE1.1
    • Field Detail

      • VERSION

        public static final java.lang.String VERSION
        The Version of the light engine.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LightEngine

        public LightEngine​()
      • LightEngine

        public LightEngine​(int xPos,
                           int yPos)
        Parameters:
        xPos - the x position of the diagrams position (center)
        yPos - the y position of the diagrams position (center)
    • Method Detail

      • update

        public void update​(float dt)
        Parameters:
        dt -
      • getVertexBrightness

        public static float getVertexBrightness​()
        Returns the average brightness.
        Returns:
      • getSun

        public GlobalLightSource getSun​(Position pos)
        You can pass the position if the sun changes relative to the postition.
        Parameters:
        pos - relative to this position
        Returns:
      • getMoon

        public GlobalLightSource getMoon​(Position pos)
        You can pass the position if the moon changes relative to the postition.
        Parameters:
        pos -
        Returns:
      • setSun

        public void setSun​(GlobalLightSource sun)
        restores position via save cvar "LEsunAzimuth".
        Parameters:
        sun -
      • isShadingPixelBased

        public boolean isShadingPixelBased​()
        The light engine can shade the world pixel based or vertext based.
        Returns:
        true if rendering via normal map false if vertext based
      • getColor

        public com.badlogic.gdx.graphics.Color getColor​(Side normal,
                                                        Position pos)
        copy safe
        Parameters:
        normal -
        pos -
        Returns:
      • getAmbient

        public com.badlogic.gdx.graphics.Color getAmbient​(Position pos)
        Returns the sum of every light source's ambient light
        Parameters:
        pos -
        Returns:
        a color with a tone
      • isInDebug

        public boolean isInDebug​()
        Returns:
      • setDebug

        public void setDebug​(boolean debug)
        Should diagrams be rendered showing the data of the LE.
        Parameters:
        debug -
      • render

        public void render​(GameView view,
                           Position pos)
        Shows the data of the light engine in diagramms.
        Parameters:
        view -
        pos - display the light data at this position
      • setToNoon

        public void setToNoon​(Position pos)
        Parameters:
        pos -
      • setToNight

        public void setToNight​(Position pos)
        Parameters:
        pos -
      • getTimeOfDay

        public float getTimeOfDay​()
        Returns:
        value between 0 and 1