j3d.examples.particles.emitters
Class Particle

java.lang.Object
  extended by j3d.examples.particles.emitters.Particle

public class Particle
extends java.lang.Object

Represents the elementary particle of a particle system. Maintains position, velocity, acceleration and age of the particle. Assumes a cartesian coordinate representation of position, velocity, and acceleration. This implementation also includes rotational attributes normally associated with rigid bodies. Strictly speaking particles would not have rotational attributes and could be split out into a rigid body particle. I'll leave that as an exercise to the interested student. I would create a IParticle interface and factories for the primitive particle and rigid body particle so the emitter would not need to know which one was in use. Note: This implementation uses Euler's approach to numeric integration. This approach is simple but has the potential for significant error. Physical simulation implementations should use the Runge-Kutta order four method to significantly reduce the accumulated error. Implies a BY_REFERENCE implementation for Java3D by delegating some actions to the owning particle emitter.


Constructor Summary
Particle(int indice, ParticleEmitter emitter)
           
 
Method Summary
 void addLocalAcceleration(javax.vecmath.Vector3f anAcceleration)
           
 void addWorldAcceleration(javax.vecmath.Vector3f anAcceleration)
           
 void age(float dt)
           
 void die()
          Kill this particle before it's time.
 javax.vecmath.Quat4f getAngularVelocityDirection()
           
 float getAngularVelocityMagnitude()
           
 ParticleEmitter getEmitter()
           
 javax.vecmath.Vector3f getEulerOrientation()
           
 javax.vecmath.Vector3f getEulerRotationRate()
           
 int getIndice()
           
 float getLifeSpanPercentage()
           
 javax.vecmath.Vector3f getLocalAcceleration()
           
 float[] getLocalPosition()
           
 javax.vecmath.Vector3f getLocalVelocity()
           
 javax.vecmath.Quat4f getOrientation()
           
 float getScale()
           
 float[] getWorldPosition()
           
 javax.vecmath.Vector3f getWorldVelocity()
           
 boolean isAlive()
           
 boolean isDead()
           
 boolean isRotatable()
           
 boolean isRotating()
           
 void move(float dt)
          Move this particle based on the current position, velocity, and acceleration.
 void rotate(float dt)
          Rotate this particle based on the current rotational position and angular velocity.
 void setAngularVelocityDirection(javax.vecmath.Quat4f aQuat4f)
           
 void setAngularVelocityMagnitude(float aMagnitude)
           
 void setEulerOrientation(javax.vecmath.Vector3f anOrientation)
          Set the rotational position of the particle by using Euler angles (in radians).
 void setEulerRotationRate(javax.vecmath.Vector3f aRate)
           
 void setInitialLocalPosition(float x, float y, float z)
           
 void setLocalPosition(float x, float y, float z)
           
 void setLocalVelocity(javax.vecmath.Vector3f aVelocity)
           
 void setOrientation(javax.vecmath.Quat4f aQuaternion)
           
 void setRotatable(boolean aBoolean)
           
 void setScale(float f)
           
 void setWorldPosition(float x, float y, float z)
           
 void setWorldVelocity(javax.vecmath.Vector3f worldVelocity)
           
 void startRotating()
           
 void stopRotating()
           
 java.lang.String toString()
           
 void update(float dt)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Particle

public Particle(int indice,
                ParticleEmitter emitter)
Method Detail

addLocalAcceleration

public void addLocalAcceleration(javax.vecmath.Vector3f anAcceleration)

addWorldAcceleration

public void addWorldAcceleration(javax.vecmath.Vector3f anAcceleration)

age

public void age(float dt)

die

public void die()
Kill this particle before it's time. The emitter will treat this particle as it does any other particle that dies of old age.


getAngularVelocityDirection

public javax.vecmath.Quat4f getAngularVelocityDirection()

getAngularVelocityMagnitude

public float getAngularVelocityMagnitude()

getEmitter

public ParticleEmitter getEmitter()

getEulerOrientation

public javax.vecmath.Vector3f getEulerOrientation()

getEulerRotationRate

public javax.vecmath.Vector3f getEulerRotationRate()

getIndice

public int getIndice()

getLifeSpanPercentage

public float getLifeSpanPercentage()

getLocalAcceleration

public javax.vecmath.Vector3f getLocalAcceleration()

getLocalPosition

public float[] getLocalPosition()

getLocalVelocity

public javax.vecmath.Vector3f getLocalVelocity()

getOrientation

public javax.vecmath.Quat4f getOrientation()
Returns:
The quaternion representing the the rotational position of the particle.

getScale

public float getScale()

getWorldPosition

public float[] getWorldPosition()

getWorldVelocity

public javax.vecmath.Vector3f getWorldVelocity()

isAlive

public boolean isAlive()

isDead

public boolean isDead()

isRotatable

public boolean isRotatable()

isRotating

public boolean isRotating()

move

public void move(float dt)
Move this particle based on the current position, velocity, and acceleration. Calculations use Euler's algorithm for numerically integrating ordinary differential equations. See Chris Hecker's excellent series game physics series in Game Developer Magazine (starting in Oct/Nov 1996).

Parameters:
dt - - The time interval (in seconds) since the last move.

rotate

public void rotate(float dt)
Rotate this particle based on the current rotational position and angular velocity.

Parameters:
dt - - The time interval (in seconds) since the last rotation.

setAngularVelocityDirection

public void setAngularVelocityDirection(javax.vecmath.Quat4f aQuat4f)

setAngularVelocityMagnitude

public void setAngularVelocityMagnitude(float aMagnitude)

setEulerOrientation

public void setEulerOrientation(javax.vecmath.Vector3f anOrientation)
Set the rotational position of the particle by using Euler angles (in radians). Euler angles specify rotations independently for each axis.

Parameters:
anOrientation - - a Vector3f containing the axis specific orientation.

setEulerRotationRate

public void setEulerRotationRate(javax.vecmath.Vector3f aRate)

setInitialLocalPosition

public void setInitialLocalPosition(float x,
                                    float y,
                                    float z)

setLocalPosition

public void setLocalPosition(float x,
                             float y,
                             float z)

setLocalVelocity

public void setLocalVelocity(javax.vecmath.Vector3f aVelocity)

setRotatable

public void setRotatable(boolean aBoolean)

setOrientation

public void setOrientation(javax.vecmath.Quat4f aQuaternion)

setScale

public void setScale(float f)

setWorldPosition

public void setWorldPosition(float x,
                             float y,
                             float z)

setWorldVelocity

public void setWorldVelocity(javax.vecmath.Vector3f worldVelocity)

startRotating

public void startRotating()

stopRotating

public void stopRotating()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

update

public void update(float dt)