com.threerings.opengl.effect
Class ParticleGeometry

java.lang.Object
  extended by com.threerings.opengl.geometry.Geometry
      extended by com.threerings.opengl.geometry.DynamicGeometry
          extended by com.threerings.opengl.effect.ParticleGeometry
Direct Known Subclasses:
ParticleGeometry.Lines, ParticleGeometry.LineTrails, ParticleGeometry.Meshes, ParticleGeometry.Points, ParticleGeometry.Quads, ParticleGeometry.QuadTrails

public abstract class ParticleGeometry
extends DynamicGeometry

Represents a particle geometry instance.


Nested Class Summary
static class ParticleGeometry.Lines
          Renders particles as single line segments.
static class ParticleGeometry.LineTrails
          Renders particles as multi-segment line trails.
static class ParticleGeometry.Meshes
          Renders particles as meshes.
static class ParticleGeometry.Points
          Renders particles as points.
static class ParticleGeometry.Quads
          Renders particles as single quads.
static class ParticleGeometry.QuadTrails
          Renders particles as multi-segment quad trails.
 
Field Summary
protected  ArrayState[] _arrayStates
          The array states for each pass.
protected  Vector3f _center
          The center of the geometry.
protected  int _colorOffset
          The offset of the color data.
protected  ParticleSystemConfig.Layer _config
          The configuration of the layer.
protected  SimpleBatch.DrawElements _drawCommand
          The draw command shared by all passes.
protected  Vector3f _last
          Used to compute particle positions.
protected  MutableInteger _living
          The number of particles currently active.
protected  Vector3f _n
          Used to compute particle normals.
protected  Vector3f _next
          Used to compute particle positions.
protected  int _normalOffset
          The offset of the normal data, or -1 if not using normals.
protected  Particle[] _particles
          The particles to render.
protected  Vector3f _position
          Used to compute particle positions.
protected  Vector3f _r
          Used to compute particle offsets.
protected  Quaternion _rotation
          Used to compute particle rotations.
protected  Vector3f _s
          Used to compute particle offsets.
protected  int _stride
          The stride (number of floats) between adjacent vertices.
protected  Vector3f _t
          Used to compute particle offsets.
protected  int _texCoordOffset
          The offset of the texture coordinate data.
protected  TransformState _transformState
          The layer's transform state.
protected  int _vertexOffset
          The offset of the vertex data.
protected  Vector3f _view
          Used to store the view vector.
protected  Quaternion _vrot
          Used to compute particle rotations.
protected  Transform3D _xform
          Used to compose particle transforms.
 
Fields inherited from class com.threerings.opengl.geometry.DynamicGeometry
_arrayBuffer, _data, _floatArray, _scratchBuffer
 
Fields inherited from class com.threerings.opengl.geometry.Geometry
EMPTY
 
Constructor Summary
ParticleGeometry(Scope scope)
          Creates a new geometry object.
 
Method Summary
protected static void computeOffset(Vector3f v1, Vector3f v2, float size, Vector3f result)
          Computes an offset vector orthogonal to the two provided vectors with the specified size.
protected  ShortBuffer createIndices()
          Creates and populates the index buffer.
 ArrayState getArrayState(int pass)
          Returns the array state for the specified pass.
 Vector3f getCenter()
          Returns a reference to the location of the center of the geometry (used for depth sorting).
 SimpleBatch.DrawCommand getDrawCommand(int pass)
          Returns the draw command for the specified pass.
protected abstract  int getMode()
          Returns the primitive mode.
protected abstract  int getParticleIndexCount()
          Returns the number of indices in each particle.
protected abstract  int getParticleVertexCount()
          Returns the number of vertices in each particle.
protected abstract  int[] getPrototypeIndices()
          Returns the array of prototype indices that will be replicated at different offsets to create the actual index buffer.
protected  void init(GlContext ctx, PassDescriptor[] passes)
          Initializes the geometry.
 void update()
          Updates the state of the geometry.
protected static int write(float[] data, int idx, int stride, Color4f value)
          Writes a color to the data buffer at the specified position and returns the position advanced by the stride.
protected static int write(float[] data, int idx, int stride, float v0, float v1)
          Writes a pair of values to the data buffer at the specified position and returns the position advanced by the stride (the hope is that these methods will be inlined; if not, they should be expanded manually).
protected static int write(float[] data, int idx, int stride, float v0, float v1, float v2)
          Writes a triplet to the data buffer at the specified position and returns the position advanced by the stride.
protected static int write(float[] data, int idx, int stride, float v0, float v1, float v2, float v3)
          Writes a quadruplet to the data buffer at the specified position and returns the position advanced by the stride.
protected static int write(float[] data, int idx, int stride, Vector3f value)
          Writes a vector to the data buffer at the specified position and returns the position advanced by the stride.
 
Methods inherited from class com.threerings.opengl.geometry.DynamicGeometry
getScratchBuffer, requiresUpdate, updateData
 
Methods inherited from class com.threerings.opengl.geometry.Geometry
getBoneMatrices, getCoordSpace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_config

@Bound
protected ParticleSystemConfig.Layer _config
The configuration of the layer.


_particles

@Bound
protected Particle[] _particles
The particles to render.


_living

@Bound
protected MutableInteger _living
The number of particles currently active.


_transformState

@Bound
protected TransformState _transformState
The layer's transform state.


_center

@Bound
protected Vector3f _center
The center of the geometry.


_stride

protected int _stride
The stride (number of floats) between adjacent vertices.


_texCoordOffset

protected int _texCoordOffset
The offset of the texture coordinate data.


_colorOffset

protected int _colorOffset
The offset of the color data.


_normalOffset

protected int _normalOffset
The offset of the normal data, or -1 if not using normals.


_vertexOffset

protected int _vertexOffset
The offset of the vertex data.


_arrayStates

protected ArrayState[] _arrayStates
The array states for each pass.


_drawCommand

protected SimpleBatch.DrawElements _drawCommand
The draw command shared by all passes.


_xform

protected Transform3D _xform
Used to compose particle transforms.


_position

protected Vector3f _position
Used to compute particle positions.


_last

protected Vector3f _last
Used to compute particle positions.


_next

protected Vector3f _next
Used to compute particle positions.


_view

protected Vector3f _view
Used to store the view vector.


_rotation

protected Quaternion _rotation
Used to compute particle rotations.


_vrot

protected Quaternion _vrot
Used to compute particle rotations.


_s

protected Vector3f _s
Used to compute particle offsets.


_t

protected Vector3f _t
Used to compute particle offsets.


_r

protected Vector3f _r
Used to compute particle offsets.


_n

protected Vector3f _n
Used to compute particle normals.

Constructor Detail

ParticleGeometry

public ParticleGeometry(Scope scope)
Creates a new geometry object.

Method Detail

getCenter

public Vector3f getCenter()
Description copied from class: Geometry
Returns a reference to the location of the center of the geometry (used for depth sorting).

Overrides:
getCenter in class Geometry

getArrayState

public ArrayState getArrayState(int pass)
Description copied from class: Geometry
Returns the array state for the specified pass.

Specified by:
getArrayState in class Geometry

getDrawCommand

public SimpleBatch.DrawCommand getDrawCommand(int pass)
Description copied from class: Geometry
Returns the draw command for the specified pass.

Specified by:
getDrawCommand in class Geometry

update

public void update()
Description copied from class: Geometry
Updates the state of the geometry.

Overrides:
update in class DynamicGeometry

init

protected void init(GlContext ctx,
                    PassDescriptor[] passes)
Initializes the geometry.


createIndices

protected ShortBuffer createIndices()
Creates and populates the index buffer.


getMode

protected abstract int getMode()
Returns the primitive mode.


getParticleVertexCount

protected abstract int getParticleVertexCount()
Returns the number of vertices in each particle.


getParticleIndexCount

protected abstract int getParticleIndexCount()
Returns the number of indices in each particle.


getPrototypeIndices

protected abstract int[] getPrototypeIndices()
Returns the array of prototype indices that will be replicated at different offsets to create the actual index buffer.


computeOffset

protected static void computeOffset(Vector3f v1,
                                    Vector3f v2,
                                    float size,
                                    Vector3f result)
Computes an offset vector orthogonal to the two provided vectors with the specified size.


write

protected static int write(float[] data,
                           int idx,
                           int stride,
                           float v0,
                           float v1)
Writes a pair of values to the data buffer at the specified position and returns the position advanced by the stride (the hope is that these methods will be inlined; if not, they should be expanded manually).


write

protected static int write(float[] data,
                           int idx,
                           int stride,
                           float v0,
                           float v1,
                           float v2)
Writes a triplet to the data buffer at the specified position and returns the position advanced by the stride.


write

protected static int write(float[] data,
                           int idx,
                           int stride,
                           float v0,
                           float v1,
                           float v2,
                           float v3)
Writes a quadruplet to the data buffer at the specified position and returns the position advanced by the stride.


write

protected static int write(float[] data,
                           int idx,
                           int stride,
                           Vector3f value)
Writes a vector to the data buffer at the specified position and returns the position advanced by the stride.


write

protected static int write(float[] data,
                           int idx,
                           int stride,
                           Color4f value)
Writes a color to the data buffer at the specified position and returns the position advanced by the stride.