j3d.org Code

org.j3d.geom.particle
Class Particle

java.lang.Object
  extended by org.j3d.geom.particle.Particle

public abstract class Particle
extends java.lang.Object

An abstract Particle that defines some physical properties and life-cycle properties.

This class is subclassed for specific types of particle that have a means of representing themselves. This class contains some fields commonly used to implement physics based particle systems, such as force, energy, surface area as well as a total age and a cyclable age.

Particles start with all settings as zero, except the dimensions, which default to 0.2.

Version:
$Revision: 2.0 $
Author:
Justin Couch, Daniel Selman

Field Summary
protected  float alpha
          Red component of the color of the particle
protected  float blue
          Blue component of the color of the particle
protected  float[] boundingBox
          bounding box for the particle
protected  int cycleAge
          a resettable cyclable age
protected  float depth
          depth of the particle
protected  float energy
          currently unused and undefined
protected  float green
          Green component of the color of the particle
protected  float height
          height of the particle
protected  float mass
          Mass of the object in kilograms
protected  int particleLife
          The maximum lifetime of this particle in milliseconds
protected  javax.vecmath.Point3f position
          Current position of the particle
protected  float red
          Red component of the color of the particle
protected  javax.vecmath.Vector3f resultantForce
          Force applied to the particle in newtons
protected  float surfaceArea
          Surface area of the particle in square meters
protected  javax.vecmath.Vector3f velocity
          Current velocity in meters per second
protected  long wallClockBirth
          The age of the particle in wall clock time (milliseconds), in this cycle
protected  long wallClockLife
          The end time in wall clock time (milliseconds)
protected  float width
          width of the particle in meters
 
Constructor Summary
Particle()
          Construct a new particle instance.
 
Method Summary
 long getBirthTime()
          Get the wall clock time that this particle was born.
 float[] getBounds()
          Retrieve the bounds of this particle in local coordinate space.
 void getColor(float[] val)
          Retrieve the current colour that this particle has.
 int getCycleAge()
          Get the set maximum cycle age.
 int getCycleTime()
          Get the set maximum cycle time.
 float getDepth()
          Get the current depth of the particle.
 float getHeight()
          Get the current height of the particle.
 float getMass()
          Gets the mass of this particle.
 void getPosition(float[] val)
          Retrieve the current position of this particle.
 javax.vecmath.Vector3f getResultantForce()
          Gets the resultantForce applied to a particle.
 float getSurfaceArea()
          Gets the surfaceArea of the particle.
 javax.vecmath.Vector3f getVelocity()
          Gets the current velocity of the particle.
 float getWidth()
          Get the current width of the particle.
 void incAge()
          Increment the cycle age.
 void setColor(float r, float g, float b, float alpha)
          Set this particle to a new colour.
 void setCycleAge(int age)
          Set the cycle age to a new value.
 void setCycleTime(int time)
          Set the cycle time to a new value.
 void setDepth(float depth)
          Sets the depth of the particle.
 void setHeight(float height)
          Sets the height of the particle.
 void setMass(float mass)
          Sets the mass of this particle.
 void setPosition(float x, float y, float z)
          Set the new position of this particle.
 void setResultantForce(javax.vecmath.Vector3f force)
          Sets the resultantForce applied to a particle.
 void setSurfaceArea(float surfaceArea)
          Sets the surfaceArea.
 void setVelocity(javax.vecmath.Vector3f velocity)
          Sets the velocity of the particle.
 void setWidth(float width)
          Sets the width of the particle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cycleAge

protected int cycleAge
a resettable cyclable age


wallClockBirth

protected long wallClockBirth
The age of the particle in wall clock time (milliseconds), in this cycle


wallClockLife

protected long wallClockLife
The end time in wall clock time (milliseconds)


particleLife

protected int particleLife
The maximum lifetime of this particle in milliseconds


surfaceArea

protected float surfaceArea
Surface area of the particle in square meters


energy

protected float energy
currently unused and undefined


mass

protected float mass
Mass of the object in kilograms


resultantForce

protected javax.vecmath.Vector3f resultantForce
Force applied to the particle in newtons


velocity

protected javax.vecmath.Vector3f velocity
Current velocity in meters per second


position

protected javax.vecmath.Point3f position
Current position of the particle


boundingBox

protected float[] boundingBox
bounding box for the particle


red

protected float red
Red component of the color of the particle


green

protected float green
Green component of the color of the particle


blue

protected float blue
Blue component of the color of the particle


alpha

protected float alpha
Red component of the color of the particle


width

protected float width
width of the particle in meters


height

protected float height
height of the particle


depth

protected float depth
depth of the particle

Constructor Detail

Particle

public Particle()
Construct a new particle instance. The dimensions default to 0.2 but no surface area or mass.

Method Detail

getPosition

public void getPosition(float[] val)
Retrieve the current position of this particle.

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

setPosition

public void setPosition(float x,
                        float y,
                        float z)
Set the new position of this particle.

Parameters:
x - The x coordinate of the new position
y - The y coordinate of the new position
z - The z coordinate of the new position

getColor

public void getColor(float[] val)
Retrieve the current colour that this particle has.

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

setColor

public void setColor(float r,
                     float g,
                     float b,
                     float alpha)
Set this particle to a new colour.

Parameters:
r - The red component of the colour
g - The green component of the colour
b - The blue component of the colour
alpha - The alpha component of the colour

getBounds

public float[] getBounds()
Retrieve the bounds of this particle in local coordinate space. They are widht, height, depth in order, first for lower bounds and upper bounds

Returns:
The array of bounding information

incAge

public void incAge()
Increment the cycle age.


getCycleAge

public final int getCycleAge()
Get the set maximum cycle age.

Returns:
The cycle age in frames

setCycleAge

public void setCycleAge(int age)
Set the cycle age to a new value.

Parameters:
age - The new age to set

getCycleTime

public final int getCycleTime()
Get the set maximum cycle time.

Returns:
The cycle time in frames

getBirthTime

public final long getBirthTime()
Get the wall clock time that this particle was born.

Returns:
The birth time in milliseconds

setCycleTime

public void setCycleTime(int time)
Set the cycle time to a new value.

Parameters:
time - The new time to set

getMass

public final float getMass()
Gets the mass of this particle.

Returns:
Returns a double

setMass

public void setMass(float mass)
Sets the mass of this particle.

Parameters:
mass - The mass to set

getResultantForce

public javax.vecmath.Vector3f getResultantForce()
Gets the resultantForce applied to a particle.

Returns:
Returns a Vector3d

setResultantForce

public void setResultantForce(javax.vecmath.Vector3f force)
Sets the resultantForce applied to a particle.

Parameters:
force - The resultant Force to set

getSurfaceArea

public final float getSurfaceArea()
Gets the surfaceArea of the particle.

Returns:
Returns a double

setSurfaceArea

public void setSurfaceArea(float surfaceArea)
Sets the surfaceArea.

Parameters:
surfaceArea - The surfaceArea to set

getVelocity

public javax.vecmath.Vector3f getVelocity()
Gets the current velocity of the particle.

Returns:
Returns a Vector3d

setVelocity

public void setVelocity(javax.vecmath.Vector3f velocity)
Sets the velocity of the particle.

Parameters:
velocity - The velocity to set

setDepth

public void setDepth(float depth)
Sets the depth of the particle.

Parameters:
depth - The depth to set

setHeight

public void setHeight(float height)
Sets the height of the particle.

Parameters:
height - The height to set

setWidth

public void setWidth(float width)
Sets the width of the particle.

Parameters:
width - The width to set

getWidth

public final float getWidth()
Get the current width of the particle.

Returns:
The current width value

getHeight

public final float getHeight()
Get the current height of the particle.

Returns:
The current height value

getDepth

public final float getDepth()
Get the current depth of the particle.

Returns:
The current depth value

j3d.org Code

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