j3d.org Code

org.j3d.geom.particle
Class ColorRampFunction

java.lang.Object
  extended by org.j3d.geom.particle.ColorRampFunction
All Implemented Interfaces:
ParticleFunction

public class ColorRampFunction
extends java.lang.Object
implements ParticleFunction

Apply a colour change over time to the particle.

Particle effects, like fire, like to change the colour of the emitted particles over their lifetime. For example at t=0, the particle starts red but fades to yellow, then transparent over its age. The time values are in seconds and the interpolation is assumed to be in HSV space, although the colors are provided as RGB values.

Internationalisation Resource Names

Version:
$Revision: 2.1 $
Author:
Justin Couch

Constructor Summary
ColorRampFunction()
          Create a disabled, default color ramp function with no values defined.
ColorRampFunction(float[] times, float[] ramp, boolean hasAlpha)
          Create a new colour ramp generator that uses the given times and 3 component colour values for that time for the interpolation.
ColorRampFunction(float[] times, float[] ramp, int numColors, boolean hasAlpha)
          Create a new colour ramp generator that uses the given times and 3 component colour values for that time for the interpolation.
 
Method Summary
 boolean apply(Particle particle)
          Apply this function to the given particle right now.
 boolean isEnabled()
          Check to see if this function has been enabled or not currently.
 boolean newFrame(int deltaT)
          Notification that the system is about to do an update of the particles and to do any system-level initialisation.
 void setColorRamp(float[] times, float[] ramp, boolean hasAlpha)
          Set the color data for the ramp to the new 3 component values.
 void setColorRamp(float[] times, float[] ramp, int numColors, boolean hasAlpha)
          Set the color data for the ramp to the new 3 component values.
 void setEnabled(boolean state)
          Set the enabled state of this function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorRampFunction

public ColorRampFunction()
Create a disabled, default color ramp function with no values defined. By default this will disabled and so an end user must explicitly set it to be enabled if this constructor was called.


ColorRampFunction

public ColorRampFunction(float[] times,
                         float[] ramp,
                         boolean hasAlpha)
Create a new colour ramp generator that uses the given times and 3 component colour values for that time for the interpolation. The colors are in a flat array of values and the entire array is used to source the colour values from.

Parameters:
times - The array of times for each color
ramp - The color values at each time
hasAlpha - True if there is 4 component color, false for 3
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

ColorRampFunction

public ColorRampFunction(float[] times,
                         float[] ramp,
                         int numColors,
                         boolean hasAlpha)
Create a new colour ramp generator that uses the given times and 3 component colour values for that time for the interpolation. The colors are in a flat array of values and only the nominated number of colour values are read from the array.

Parameters:
times - The array of times for each color
ramp - The color values at each time
hasAlpha - True if there is 4 component color, false for 3
numColors - The number of valid items in the array
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length
Method Detail

isEnabled

public boolean isEnabled()
Check to see if this function has been enabled or not currently.

Specified by:
isEnabled in interface ParticleFunction
Returns:
True if this is enabled

setEnabled

public void setEnabled(boolean state)
Set the enabled state of this function. A disabled function will not be applied to particles during this update.

Specified by:
setEnabled in interface ParticleFunction
Parameters:
state - The new enabled state to set it to

newFrame

public boolean newFrame(int deltaT)
Notification that the system is about to do an update of the particles and to do any system-level initialisation.

Specified by:
newFrame in interface ParticleFunction
Parameters:
deltaT - The elapsed time in milliseconds since the last frame
Returns:
true if this should force another update after this one

apply

public boolean apply(Particle particle)
Apply this function to the given particle right now.

Specified by:
apply in interface ParticleFunction
Parameters:
particle - The particle to apply the function to
Returns:
true if the particle is still alive

setColorRamp

public void setColorRamp(float[] times,
                         float[] ramp,
                         boolean hasAlpha)
Set the color data for the ramp to the new 3 component values. Time is defined in seconds.

Parameters:
times - The array of times for each color
ramp - The color values at each time
hasAlpha - true if this is 4-component colour, 3 otherwise
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

setColorRamp

public void setColorRamp(float[] times,
                         float[] ramp,
                         int numColors,
                         boolean hasAlpha)
Set the color data for the ramp to the new 3 component values. Time is defined in seconds.

Parameters:
times - The array of times for each color
ramp - The color values at each time
numColors - The number of valid color values in the array
hasAlpha - True if there is 4 component color, false for 3
Throws:
java.lang.IllegalArgumentException - The two arrays have differet length

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org