j3d.org Code

org.j3d.geom.particle
Class GravityParticleFunction

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

public class GravityParticleFunction
extends java.lang.Object
implements ParticleFunction

GravityMovementFunction applied a gravity force to Particles.

Version:
$Revision: 2.0 $
Author:
Daniel Selman

Constructor Summary
GravityParticleFunction()
          Construct the function with gravity acting in the traditional newtonian way - down the -Y axis at 9.8m/s^2.
GravityParticleFunction(float x, float y, float z)
          Create a new function with gravity set to the given vector and value.
 
Method Summary
 boolean apply(Particle particle)
          Apply this function to the given particle right now.
 void getGravity(float[] val)
          Get the current value of gravity.
 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 setEnabled(boolean state)
          Set the enabled state of this function.
 void setGravity(float[] gravity)
          Change the gravity to a new value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GravityParticleFunction

public GravityParticleFunction()
Construct the function with gravity acting in the traditional newtonian way - down the -Y axis at 9.8m/s^2.


GravityParticleFunction

public GravityParticleFunction(float x,
                               float y,
                               float z)
Create a new function with gravity set to the given vector and value.

Parameters:
x - The gravity vector to apply along the x axis
y - The gravity vector to apply along the y axis
z - The gravity vector to apply along the z axis
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 stays alive, false otherwise

setGravity

public void setGravity(float[] gravity)
Change the gravity to a new value.

Parameters:
gravity - The vector and magnitude of the new gravity

getGravity

public void getGravity(float[] val)
Get the current value of gravity.

Parameters:
val - An array of length 3 to copy the values to

j3d.org Code

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