j3d.org Code

org.j3d.geom.particle
Class WindParticleFunction

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

public class WindParticleFunction
extends java.lang.Object
implements ParticleFunction

WindParticleFunction models a directional wind source.

The wind has a direction and speed that control how it effects the individual particle. From the wind speed, a pressure is calculated using the following model:

 pressure = 10^(2 * log(speed)) * 0.64615
 
This is taken from the only I could find that would convert speed to a pressure applied on an object. The location of this convertor is http://www.cactus2000.de/uk/unit/masswsp.shtml

The force applied to the particle is thus proportional to it's surface area. Naturally this does not do a really good model, such as taking into account drag effects, etc, but it should be good-enough to model a gusty wind acting on a lot of small particles.

Further parameterisation is provided by allowing gustiness (speed variation) and turbulence (direction variation) per frame, controlling the strength and direction of the wind force.

Internationalisation Resource Names

Version:
$Revision: 2.2 $
Author:
Justin Couch

Constructor Summary
WindParticleFunction()
          Construct a new default wind particle function.
WindParticleFunction(float[] direction, float speed, float gustiness, float turbulence)
          Construct a new wind function with the parameters provided.
 
Method Summary
 boolean apply(Particle particle)
          Apply this function to the given particle right now.
 void getDirection(float[] dir)
          Fetch the current direction of the wind speed direction.
 float getGustiness()
          Get the current gustiness that particles effected by.
 float getSpeed()
          Get the current speed of the wind.
 float getTurbulence()
          Get the current turbulence that particles are effected by.
 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 setDirection(float x, float y, float z)
          Change the direction of the wind.
 void setEnabled(boolean state)
          Set the enabled state of this function.
 void setGustiness(float gustiness)
          Change the gustiness that wind is blowing at.
 void setSpeed(float speed)
          Change the speed that wind is blowing at.
 void setTurbulence(float turbulence)
          Change the turbulence of the wind.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindParticleFunction

public WindParticleFunction()
Construct a new default wind particle function. Everything is set to zeroes.


WindParticleFunction

public WindParticleFunction(float[] direction,
                            float speed,
                            float gustiness,
                            float turbulence)
Construct a new wind function with the parameters provided.

Parameters:
direction - The direction of the wind
speed - The speed of the wind
gustiness - Speed variation per-frame, non-negative
turbulence - Amount of per-particle variance
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 has changed, false otherwise

setSpeed

public void setSpeed(float speed)
Change the speed that wind is blowing at.

Parameters:
speed - The magnitude of the wind speed to use

getSpeed

public float getSpeed()
Get the current speed of the wind.

Returns:
A value of the speed

setDirection

public void setDirection(float x,
                         float y,
                         float z)
Change the direction of the wind.

Parameters:
x - The x component of the wind direction
y - The y component of the wind direction
z - The z component of the wind direction

getDirection

public void getDirection(float[] dir)
Fetch the current direction of the wind speed direction.

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

setGustiness

public void setGustiness(float gustiness)
                  throws java.lang.IllegalArgumentException
Change the gustiness that wind is blowing at. Gustiness is a per-frame modifier for the wind speed, so it will be used to control how strong the wind is. However, it should not allow for the wind to blow backwards, so it is limited to non-negative values only.

Parameters:
gustiness - The magnitude of the wind gustiness to use
Throws:
java.lang.IllegalArgumentException - The value was negative

getGustiness

public float getGustiness()
Get the current gustiness that particles effected by.

Returns:
A value of the gustiness

setTurbulence

public void setTurbulence(float turbulence)
Change the turbulence of the wind.

Parameters:
turbulence - The magnitude of the wind turbulence to use

getTurbulence

public float getTurbulence()
Get the current turbulence that particles are effected by.

Returns:
A value of the turbulence

j3d.org Code

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