Package org.dark.shaders.distortion
Class RippleDistortion
java.lang.Object
org.dark.shaders.distortion.RippleDistortion
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprotected static final com.fs.starfarer.api.graphics.SpriteAPI[]protected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected floatprotected booleanprotected floatprotected floatstatic final intprotected floatprotected floatprotected final org.lwjgl.util.vector.Vector2fprotected floatprotected floatprotected floatprotected static booleanprotected final org.lwjgl.util.vector.Vector2f -
Constructor Summary
ConstructorsConstructorDescriptionRippleDistortion(org.lwjgl.util.vector.Vector2f location, org.lwjgl.util.vector.Vector2f velocity) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadvance(float amount) Runs once per frame.voidfadeInIntensity(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.voidfadeInSize(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.voidfadeOutIntensity(float time) Fades out the distortion's intensity over a period of time.voidfadeOutSize(float time) Fades out the distortion's size over a period of time.voidflip(boolean flipped) Sets whether the distortion should be flipped in magnitude.floatThe width of the visible arc's edge attenuation, in degrees.floatThe end of the current visible arc of the distortion, in degrees.floatThe start of the current visible arc of the distortion, in degrees.floatReturns the frame rate the animation will play at after its lifetime expires.floatReturns the starting frame the animation will play from after its lifetime expires.floatReturns the amount of time the distortion will take to fade out in intensity after its lifetime expires.floatReturns the amount of time the distortion will take to fade out in size after its lifetime expires.floatReturns the current frame of the animation.floatGets the change in intensity over time.floatGets the change in size over time.floatThe current facing direction of the distortion, in degrees.floatReturns the current frame rate of the animation.floatReturns the world-space quantity, in units, to distort by at the maximum distortion level (blue channel at 255).org.lwjgl.util.vector.Vector2fReturns the current location of the distortion.floatGets the maximum intensity to reach.floatGets the maximum size to reach.floatReturns the remaining time the distortion has left before it expires.floatgetSize()Returns the apparent size of the distortion, in world-space units.com.fs.starfarer.api.graphics.SpriteAPIThe sprite used to draw the distortion texture.org.lwjgl.util.vector.Vector2fGets the current velocity of the distortion.booleanisFading()Returns whether the distortion is currently fading or not, regardless of how it is fading.booleanWhether the distortion should be flipped in magnitude.voidsetArc(float start, float end) Sets the visible arc of the distortion, in degrees.voidsetArcAttenuationWidth(float width) Sets the width of the visible arc's edge attenuation, in degrees.voidsetAutoAnimateFrameRate(float frameRate, float frameStart) Sets the frame rate and the starting frame the animation will play at after its lifetime expires.voidsetAutoFadeIntensityTime(float time) Sets the amount of time the distortion will take to fade out in intensity after its lifetime expires.voidsetAutoFadeSizeTime(float time) Sets the amount of time the distortion will take to fade out in size after its lifetime expires.voidsetCurrentFrame(float frame) Sets the current animation frame to the given value.voidsetDeltaIntensity(float deltaIntensity) Sets the change in intensity over time.voidsetDeltaSize(float deltaSize) Sets the change in size over time.voidsetFrameRate(float frameRate) Plays the animation at the desired frame rate.voidsetIntensity(float intensity) Sets the world-space quantity, in units, to distort by at the maximum distortion level (blue channel at 255).voidsetLifetime(float lifetime) Sets the time the distortion has before it expires.voidsetLocation(org.lwjgl.util.vector.Vector2f location) Sets the desired location of the distortion.voidsetMaxIntensity(float maxIntensity) Sets the maximum intensity to reach.voidsetMaxSize(float maxSize) Sets the maximum size to reach.voidsetSize(float size) Sets the apparent size of the distortion, in world-space units.voidsetVelocity(org.lwjgl.util.vector.Vector2f velocity) Sets the velocity for the distortion.
-
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:
advancein interfaceDistortionAPI- 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:
getArcAttenuationWidthin interfaceDistortionAPI- 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:
getArcEndin interfaceDistortionAPI- 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:
getArcStartin interfaceDistortionAPI- 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:
getFacingin interfaceDistortionAPI- 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:
getIntensityin interfaceDistortionAPI- 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:
getLocationin interfaceDistortionAPI- 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:
getSpritein interfaceDistortionAPI- 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:
isFlippedin interfaceDistortionAPI- 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
-