yaarq.sys
Class yrqParticleVisual

java.lang.Object
  |
  +--yaarq.sys.yrqVisual
        |
        +--yaarq.sys.yrqParticleVisual
All Implemented Interfaces:
javax.media.j3d.GeometryUpdater

public class yrqParticleVisual
extends yrqVisual
implements javax.media.j3d.GeometryUpdater

This class provides support for particle systems. It encapsules a pool of particles implemented as one geometry and appearance, with the individual particles being manually updated to save on state changes in the rendering pipeline.

A particle visual is initialised with a number of particles. This number denotes the maximum number of particles existing in the visual. If at particle creation the visual runs out of particles, it simply reuses the oldest particles. Applications using the class have to take care always to reserve enough space in a particle visual.

Particle visuals share a texture for all their particles. However, they do not share an alpha value, this value is done per-vertex for individual particles. So, applications can manipulate texturing attribute for all particles at once, while still changing individual particle properties.

Particle creation, modification and removal is done by a particlemanager class. Every particle visual automatically gets a particle mangager assigned. Set the desired particle system properties to the particle manager to cause the visual to produce the wanted effect. Do not modify the particles individually. A particle visual is always added to the root frame internally. To allow for particles to be generated at a position synchronized with a yrqFrame instance, the setSourceFrame method is provided.

TODO: Nothing


Field Summary
 
Fields inherited from class yaarq.sys.yrqVisual
COLOR_AMBIENT, COLOR_DIFFUSE, COLOR_EMISSIVE, COLOR_SPECULAR, m_parent, MODE_ADD, MODE_BLEND, MODE_NONE, TEXTURE_DOT3BUMP, TEXTURE_LIGHTMAP, TEXTURE_MATERIAL, TEXTURE_REFLECT
 
Constructor Summary
yrqParticleVisual(javax.media.j3d.Texture2D a_texture, yrqFrame a_source, int a_size, int a_mode)
          ...
 
Method Summary
 void addParticle(javax.vecmath.Point3d a_coord, javax.vecmath.Vector3d a_heading, double a_alpha, double a_size)
          This method adds a particle.
 yrqParticleManager getManager()
          ...
 yrqParticle getParticle(int a_idx)
          This function returns a given particle.
 int getSize()
          ...
 yrqFrame getSourceFrame()
          This method sets the source frame for the visual.
 javax.media.j3d.Texture2D getTexture()
          This function returns the texture used by all particles
 int getTransparencyMode()
          Returns the transparency mode of the visual.
 void removeParticle(yrqParticle a_particle)
          This function removes a given particle.
 void setSourceFrame(yrqFrame a_frame)
          This method sets the source frame for the visual.
 void setTexture(javax.media.j3d.Texture2D a_texture)
          This method sets the texture to use for all particles
 void setTransparencyMode(int a_mode)
          Sets the transparency mode for the visual.
 void update(yrqEngine a_engine)
          This method updates the particle set by calling a geometry update for the geometry keeping the particles internally.
 void updateData(javax.media.j3d.Geometry a_geo)
          This method implements the geometryupdater interface to allow for the class to update the particle geometry used.
 
Methods inherited from class yaarq.sys.yrqVisual
attach, detach, getBaseShape3D, getBumpShape3D, getGeometry, getParent, getTexture, getTransparencyValue, setBrightness, setColor, setGeometry, setShininess, setTexture, setTextureAnimation, setTextureAnimation, setTransparency
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

yrqParticleVisual

public yrqParticleVisual(javax.media.j3d.Texture2D a_texture,
                         yrqFrame a_source,
                         int a_size,
                         int a_mode)
...

Parameters:
a_texture - The texture to use for all particles in this set
a_source - The source frame at which to create new particles
a_size - The maximum number of particles in this set
a_mode - The blending mode for particles in this set, one of the MODE_xxx constants
Method Detail

addParticle

public void addParticle(javax.vecmath.Point3d a_coord,
                        javax.vecmath.Vector3d a_heading,
                        double a_alpha,
                        double a_size)
This method adds a particle. It is internally used by the particle manager, applications should only interact with particles via this manager.

Parameters:
a_coord - The coordinates at which the new particle should appear
a_heading - The direction into which the new particle should fly
a_alpha - The initial alpha value of the new particle
a_size - The initial size of the new particle

getManager

public yrqParticleManager getManager()
...

Returns:
The particle manager set for this class

getParticle

public yrqParticle getParticle(int a_idx)
This function returns a given particle. It is internally used by the particle manager, applications should only interact with particles via this manager.

Parameters:
a_idx - The index of the desired particle
Returns:
The particle having the given index in the set

getSize

public int getSize()
...

Returns:
The maximum number of particles in this set

getSourceFrame

public yrqFrame getSourceFrame()
This method sets the source frame for the visual. The position of the frame in world space is used as a starting point for particle creation.

Returns:
a_frame The frame which is the source for particle creation

getTexture

public javax.media.j3d.Texture2D getTexture()
This function returns the texture used by all particles

Returns:
the texture used by the particle visual

getTransparencyMode

public int getTransparencyMode()
Returns the transparency mode of the visual. One of the MODE_xxx constants.

Overrides:
getTransparencyMode in class yrqVisual
Returns:
Global transparency value of the visual

removeParticle

public void removeParticle(yrqParticle a_particle)
This function removes a given particle. It is internally used by the particle manager, applications should only interact with particles via this manager.

Parameters:
a_particle - The particle to be removed

setSourceFrame

public void setSourceFrame(yrqFrame a_frame)
This method sets the source frame for the visual. The position of the frame in world space is used as a starting point for particle creation.

Parameters:
a_frame - The frame which is the source for particle creation

setTexture

public void setTexture(javax.media.j3d.Texture2D a_texture)
This method sets the texture to use for all particles

Parameters:
a_texture - The texture to use for the overlay

setTransparencyMode

public void setTransparencyMode(int a_mode)
Sets the transparency mode for the visual. Transparency can be additive, blended or disabled, pass one of the MODE_xxx constants as the mode parameter to switch modes. Note that for particle visuals, no global transparency value can be passed, transparency is particle-dependent and achieved via per-vertex coloring.

Parameters:
a_mode - Transparency mode for this visual

update

public void update(yrqEngine a_engine)
This method updates the particle set by calling a geometry update for the geometry keeping the particles internally. The engine internally calls this method, applications should not issue calls to it.


updateData

public void updateData(javax.media.j3d.Geometry a_geo)
This method implements the geometryupdater interface to allow for the class to update the particle geometry used.

Specified by:
updateData in interface javax.media.j3d.GeometryUpdater
Parameters:
a_geo - The geometry to update, as passed by J3D according to the call to updateGeometry