Class RippleDistortion

java.lang.Object
org.dark.shaders.distortion.RippleDistortion
All Implemented Interfaces:
DistortionAPI

public class RippleDistortion extends Object implements DistortionAPI
A 60-frame animated ripple-shaped distortion object. This type of distortion is suitable for situations where a spreading relatively-even ripple effect of varying relative thickness is desired. This distortion is a radial "pop-out" that does not skew textures. You may also opt not to animate this distortion, instead selecting the thickness desired by loading a particular frame.

Since:
Alpha 1.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final com.fs.starfarer.api.graphics.SpriteAPI[]
     
    protected float
     
    protected float
     
    protected float
     
    protected float
     
    protected float
     
    protected float
     
    protected float
     
    protected float
     
    protected float
     
    protected boolean
     
    protected float
     
    protected float
     
    static final int
     
    protected float
     
    protected float
     
    protected final org.lwjgl.util.vector.Vector2f
     
    protected float
     
    protected float
     
    protected float
     
    protected static boolean
     
    protected final org.lwjgl.util.vector.Vector2f
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    RippleDistortion(org.lwjgl.util.vector.Vector2f location, org.lwjgl.util.vector.Vector2f velocity)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    advance(float amount)
    Runs once per frame.
    void
    fadeInIntensity(float time)
    Sets the distortion's intensity to zero and fades in the distortion's intensity to its original value over a period of time.
    void
    fadeInSize(float time)
    Sets the distortion's size to zero and fades in the distortion's size to its original value over a period of time.
    void
    fadeOutIntensity(float time)
    Fades out the distortion's intensity over a period of time.
    void
    fadeOutSize(float time)
    Fades out the distortion's size over a period of time.
    void
    flip(boolean flipped)
    Sets whether the distortion should be flipped in magnitude.
    float
    The width of the visible arc's edge attenuation, in degrees.
    float
    The end of the current visible arc of the distortion, in degrees.
    float
    The start of the current visible arc of the distortion, in degrees.
    float
    Returns the frame rate the animation will play at after its lifetime expires.
    float
    Returns the starting frame the animation will play from after its lifetime expires.
    float
    Returns the amount of time the distortion will take to fade out in intensity after its lifetime expires.
    float
    Returns the amount of time the distortion will take to fade out in size after its lifetime expires.
    float
    Returns the current frame of the animation.
    float
    Gets the change in intensity over time.
    float
    Gets the change in size over time.
    float
    The current facing direction of the distortion, in degrees.
    float
    Returns the current frame rate of the animation.
    float
    Returns the world-space quantity, in units, to distort by at the maximum distortion level (blue channel at 255).
    org.lwjgl.util.vector.Vector2f
    Returns the current location of the distortion.
    float
    Gets the maximum intensity to reach.
    float
    Gets the maximum size to reach.
    float
    Returns the remaining time the distortion has left before it expires.
    float
    Returns the apparent size of the distortion, in world-space units.
    com.fs.starfarer.api.graphics.SpriteAPI
    The sprite used to draw the distortion texture.
    org.lwjgl.util.vector.Vector2f
    Gets the current velocity of the distortion.
    boolean
    Returns whether the distortion is currently fading or not, regardless of how it is fading.
    boolean
    Whether the distortion should be flipped in magnitude.
    void
    setArc(float start, float end)
    Sets the visible arc of the distortion, in degrees.
    void
    Sets the width of the visible arc's edge attenuation, in degrees.
    void
    setAutoAnimateFrameRate(float frameRate, float frameStart)
    Sets the frame rate and the starting frame the animation will play at after its lifetime expires.
    void
    Sets the amount of time the distortion will take to fade out in intensity after its lifetime expires.
    void
    setAutoFadeSizeTime(float time)
    Sets the amount of time the distortion will take to fade out in size after its lifetime expires.
    void
    setCurrentFrame(float frame)
    Sets the current animation frame to the given value.
    void
    setDeltaIntensity(float deltaIntensity)
    Sets the change in intensity over time.
    void
    setDeltaSize(float deltaSize)
    Sets the change in size over time.
    void
    setFrameRate(float frameRate)
    Plays the animation at the desired frame rate.
    void
    setIntensity(float intensity)
    Sets the world-space quantity, in units, to distort by at the maximum distortion level (blue channel at 255).
    void
    setLifetime(float lifetime)
    Sets the time the distortion has before it expires.
    void
    setLocation(org.lwjgl.util.vector.Vector2f location)
    Sets the desired location of the distortion.
    void
    setMaxIntensity(float maxIntensity)
    Sets the maximum intensity to reach.
    void
    setMaxSize(float maxSize)
    Sets the maximum size to reach.
    void
    setSize(float size)
    Sets the apparent size of the distortion, in world-space units.
    void
    setVelocity(org.lwjgl.util.vector.Vector2f velocity)
    Sets the velocity for the distortion.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FRAMES

      public static final int FRAMES
      See Also:
    • animation

      protected static final com.fs.starfarer.api.graphics.SpriteAPI[] animation
    • useLargeRipple

      protected static boolean useLargeRipple
    • arcAttenWidth

      protected float arcAttenWidth
    • arcEnd

      protected float arcEnd
    • arcStart

      protected float arcStart
    • autoAnimateFrameRate

      protected float autoAnimateFrameRate
    • autoAnimateFrameStart

      protected float autoAnimateFrameStart
    • autoFadeIntensityTime

      protected float autoFadeIntensityTime
    • autoFadeSizeTime

      protected float autoFadeSizeTime
    • deltaIntensity

      protected float deltaIntensity
    • deltaSize

      protected float deltaSize
    • flipped

      protected boolean flipped
    • frame

      protected float frame
    • frameRate

      protected float frameRate
    • intensity

      protected float intensity
    • lifetime

      protected float lifetime
    • location

      protected final org.lwjgl.util.vector.Vector2f location
    • maxIntensity

      protected float maxIntensity
    • maxSize

      protected float maxSize
    • size

      protected float size
    • velocity

      protected final org.lwjgl.util.vector.Vector2f velocity
  • Constructor Details

    • RippleDistortion

      public RippleDistortion()
    • RippleDistortion

      public RippleDistortion(org.lwjgl.util.vector.Vector2f location, org.lwjgl.util.vector.Vector2f velocity)
  • Method Details

    • advance

      public boolean advance(float amount)
      Runs once per frame.

      Specified by:
      advance in interface DistortionAPI
      Parameters:
      amount - Seconds since last frame.

      Returns:
      True if the distortion object should be destroyed this frame, false if it should not be destroyed this frame.

      Since:
      Alpha 1.1
    • fadeInIntensity

      public void fadeInIntensity(float time)
      Sets the distortion's intensity to zero and fades in the distortion's intensity to its original value over a period of time.

      Parameters:
      time - The time over which to fade in the distortion's intensity.

      Since:
      Alpha 1.1
    • fadeInSize

      public void fadeInSize(float time)
      Sets the distortion's size to zero and fades in the distortion's size to its original value over a period of time.

      Parameters:
      time - The time over which to fade in the distortion's size.

      Since:
      Alpha 1.1
    • fadeOutIntensity

      public void fadeOutIntensity(float time)
      Fades out the distortion's intensity over a period of time. If the distortion hits zero intensity, it is destroyed. Negative time values will cause the intensity to increase forever.

      Parameters:
      time - The time over which to fade out the distortion's intensity.

      Since:
      Alpha 1.1
    • fadeOutSize

      public void fadeOutSize(float time)
      Fades out the distortion's size over a period of time. If the distortion hits zero size, it is destroyed. Negative time values will cause the size to increase forever.

      Parameters:
      time - The time over which to fade out the distortion's size.

      Since:
      Alpha 1.1
    • flip

      public void flip(boolean flipped)
      Sets whether the distortion should be flipped in magnitude. This simulates the effect of performing a horizontal-vertical inversion of the red and green color channels. For example, if the distortion normally looks like a sphere, it will instead look like a spherical hole.

      Parameters:
      flipped - Whether the magnitude should be flipped.

      Since:
      Alpha 1.1
    • getArcAttenuationWidth

      public float getArcAttenuationWidth()
      The width of the visible arc's edge attenuation, in degrees. Wider attenuation will make the transition smoother.

      Specified by:
      getArcAttenuationWidth in interface DistortionAPI
      Returns:
      The width of the visible arc's edge attenuation, in degrees.

      Since:
      Beta 1.0
    • setArcAttenuationWidth

      public void setArcAttenuationWidth(float width)
      Sets the width of the visible arc's edge attenuation, in degrees. Wider attenuation will make the transition smoother.

      Parameters:
      width - The desired width of the visible arc's edge attenuation, in degrees.

      Since:
      Beta 1.0
    • getArcEnd

      public float getArcEnd()
      The end of the current visible arc of the distortion, in degrees. Note: the entire shader is visible if the arc spans 0 degrees.

      Specified by:
      getArcEnd in interface DistortionAPI
      Returns:
      The current facing direction of the distortion.

      Since:
      Alpha 1.11
    • getArcStart

      public float getArcStart()
      The start of the current visible arc of the distortion, in degrees. Note: the entire shader is visible if the arc spans 0 degrees.

      Specified by:
      getArcStart in interface DistortionAPI
      Returns:
      The start of the current visible arc of the distortion, in degrees.

      Since:
      Alpha 1.11
    • getAutoAnimateFrameRate

      public float getAutoAnimateFrameRate()
      Returns the frame rate the animation will play at after its lifetime expires.

      Returns:
      The frame rate the animation will play at after its lifetime expires.

      Since:
      Alpha 1.1
    • getAutoAnimateFrameStart

      public float getAutoAnimateFrameStart()
      Returns the starting frame the animation will play from after its lifetime expires.

      Returns:
      The starting frame the animation will play from after its lifetime expires.

      Since:
      Alpha 1.1
    • getAutoFadeIntensityTime

      public float getAutoFadeIntensityTime()
      Returns the amount of time the distortion will take to fade out in intensity after its lifetime expires.

      Returns:
      The amount of time the distortion will take to fade out in intensity after its lifetime expires.

      Since:
      Alpha 1.1
    • setAutoFadeIntensityTime

      public void setAutoFadeIntensityTime(float time)
      Sets the amount of time the distortion will take to fade out in intensity after its lifetime expires.

      Parameters:
      time - The amount of time the distortion should take to fade out in intensity after its lifetime expires.

      Since:
      Alpha 1.1
    • getAutoFadeSizeTime

      public float getAutoFadeSizeTime()
      Returns the amount of time the distortion will take to fade out in size after its lifetime expires.

      Returns:
      The amount of time the distortion will take to fade out in size after its lifetime expires.

      Since:
      Alpha 1.1
    • setAutoFadeSizeTime

      public void setAutoFadeSizeTime(float time)
      Sets the amount of time the distortion will take to fade out in size after its lifetime expires.

      Parameters:
      time - The amount of time the distortion should take to fade out in size after its lifetime expires.

      Since:
      Alpha 1.1
    • getCurrentFrame

      public float getCurrentFrame()
      Returns the current frame of the animation.

      Returns:
      The animation's current frame.

      Since:
      Alpha 1.1
    • setCurrentFrame

      public void setCurrentFrame(float frame)
      Sets the current animation frame to the given value.

      Parameters:
      frame - The animation frame to set the object to.
    • getFacing

      public float getFacing()
      The current facing direction of the distortion, in degrees. Matches sprite's rotation.

      Specified by:
      getFacing in interface DistortionAPI
      Returns:
      The current facing direction of the distortion.

      Since:
      Alpha 1.1
    • getFrameRate

      public float getFrameRate()
      Returns the current frame rate of the animation.

      Returns:
      The animation's current frame rate.

      Since:
      Alpha 1.1
    • setFrameRate

      public void setFrameRate(float frameRate)
      Plays the animation at the desired frame rate. May be negative.

      Parameters:
      frameRate - The desired frame rate.

      Since:
      Alpha 1.1
    • getIntensity

      public float getIntensity()
      Returns the world-space quantity, in units, to distort by at the maximum distortion level (blue channel at 255). The distortion engine will handle the transformation for you. Note that this function refers to the intensity scale of the distortion texture, not its size. Modify the texture's sprite directly to change its size directly.

      Specified by:
      getIntensity in interface DistortionAPI
      Returns:
      The scaling factor to transform the blue channel by, in world space units.

      Since:
      Alpha 1.1
    • setIntensity

      public void setIntensity(float intensity)
      Sets the world-space quantity, in units, to distort by at the maximum distortion level (blue channel at 255). The distortion engine will handle the transformation for you. Note that this function refers to the intensity scale of the distortion texture, not its size. Modify the texture's sprite directly to change its size directly.

      Parameters:
      intensity - The scaling factor to transform the blue channel by, in world space units.

      Since:
      Alpha 1.1
    • setLifetime

      public void setLifetime(float lifetime)
      Sets the time the distortion has before it expires. Lifetime does not count down while the distortion is fading (in or out). After reaching the end of its lifetime, the distortion may fade out before disappearing if it has AutoFade set.

      Parameters:
      lifetime - The time the distortion has before it expires.

      Since:
      Alpha 1.1
    • getLocation

      public org.lwjgl.util.vector.Vector2f getLocation()
      Returns the current location of the distortion.

      Specified by:
      getLocation in interface DistortionAPI
      Returns:
      The current location of the distortion.

      Since:
      Alpha 1.1
    • setLocation

      public void setLocation(org.lwjgl.util.vector.Vector2f location)
      Sets the desired location of the distortion.

      Parameters:
      location - The desired location of the distortion.

      Since:
      Alpha 1.1
    • getRemainingLifetime

      public float getRemainingLifetime()
      Returns the remaining time the distortion has left before it expires. Lifetime does not count down while the distortion is fading (in or out). After reaching the end of its lifetime, the distortion may fade out before disappearing if it has AutoFade set.

      Returns:
      The remaining time the distortion has left before it expires.

      Since:
      Alpha 1.1
    • getSize

      public float getSize()
      Returns the apparent size of the distortion, in world-space units.

      Returns:
      The apparent size of the distortion, in world-space units.

      Since:
      Alpha 1.1
    • setSize

      public void setSize(float size)
      Sets the apparent size of the distortion, in world-space units.

      Parameters:
      size - The desired size of the distortion, in world-space units.

      Since:
      Alpha 1.1
    • getSprite

      public com.fs.starfarer.api.graphics.SpriteAPI getSprite()
      The sprite used to draw the distortion texture. The red channel corresponds to horizontal distortion vector, while the green channel corresponds to vertical distortion vector. The engine will normalize these values for you. The blue channel corresponds to distortion magnitude. For example, a pure white square as a distortion texture will copy a square of pixels somewhere to the top-right of the screen.

      Specified by:
      getSprite in interface DistortionAPI
      Returns:
      The sprite used to draw the distortion texture.

      Since:
      Alpha 1.1
    • getVelocity

      public org.lwjgl.util.vector.Vector2f getVelocity()
      Gets the current velocity of the distortion.

      Returns:
      The current velocity of the distortion.

      Since:
      Alpha 1.2
    • setVelocity

      public void setVelocity(org.lwjgl.util.vector.Vector2f velocity)
      Sets the velocity for the distortion.

      Parameters:
      velocity - The velocity to apply to the distortion.

      Since:
      Alpha 1.2
    • isFading

      public boolean isFading()
      Returns whether the distortion is currently fading or not, regardless of how it is fading.

      Returns:
      Whether the distortion is currently fading or not.

      Since:
      Alpha 1.1
    • isFlipped

      public boolean isFlipped()
      Whether the distortion should be flipped in magnitude. This simulates the effect of performing a horizontal-vertical inversion of the red and green color channels. For example, if the distortion normally looks like a sphere, it will instead look like a spherical hole.

      Specified by:
      isFlipped in interface DistortionAPI
      Returns:
      Whether the magnitude should be flipped.

      Since:
      Alpha 1.1
    • setArc

      public void setArc(float start, float end)
      Sets the visible arc of the distortion, in degrees. Note: the entire shader is visible if the arc spans 0 degrees.

      Parameters:
      start - The start of the distortion's visible arc, in degrees.
      end - The end of the distortion's visible arc, in degrees.

      Since:
      Alpha 1.11
    • setAutoAnimateFrameRate

      public void setAutoAnimateFrameRate(float frameRate, float frameStart)
      Sets the frame rate and the starting frame the animation will play at after its lifetime expires.

      Parameters:
      frameRate - The frame rate the animation should play at when the object's lifetime expires.
      frameStart - The frame the animation should start at when the object's lifetime expires.

      Since:
      Alpha 1.1
    • getDeltaSize

      public float getDeltaSize()
      Gets the change in size over time.

      Returns:
      The rate of change of the size of the distortion.

      Since:
      1.8.0
    • setDeltaSize

      public void setDeltaSize(float deltaSize)
      Sets the change in size over time.

      Parameters:
      deltaSize - The rate of change of size to apply to the distortion.

      Since:
      1.8.0
    • getMaxSize

      public float getMaxSize()
      Gets the maximum size to reach.

      Returns:
      The maximum size that the distortion can reach.

      Since:
      1.8.0
    • setMaxSize

      public void setMaxSize(float maxSize)
      Sets the maximum size to reach.

      Parameters:
      maxSize - The maximum size that the distortion should reach.

      Since:
      1.8.0
    • getDeltaIntensity

      public float getDeltaIntensity()
      Gets the change in intensity over time.

      Returns:
      The rate of change of the intensity of the distortion.

      Since:
      1.8.0
    • setDeltaIntensity

      public void setDeltaIntensity(float deltaIntensity)
      Sets the change in intensity over time.

      Parameters:
      deltaIntensity - The rate of change of intensity to apply to the distortion.

      Since:
      1.8.0
    • getMaxIntensity

      public float getMaxIntensity()
      Gets the maximum intensity to reach.

      Returns:
      The maximum intensity that the distortion can reach.

      Since:
      1.8.0
    • setMaxIntensity

      public void setMaxIntensity(float maxIntensity)
      Sets the maximum intensity to reach.

      Parameters:
      maxIntensity - The maximum intensity that the distortion should reach.

      Since:
      1.8.0