com.threerings.opengl.effect
Class BaseParticleSystem.Layer

java.lang.Object
  extended by com.threerings.expr.SimpleScope
      extended by com.threerings.opengl.effect.BaseParticleSystem.Layer
All Implemented Interfaces:
Scope, ScopeUpdateListener
Direct Known Subclasses:
MetaParticleSystem.Layer, ParticleSystem.Layer
Enclosing class:
BaseParticleSystem

public abstract static class BaseParticleSystem.Layer
extends SimpleScope

A single layer of the system.


Field Summary
protected  Box _bounds
          The bounds of the layer.
protected  ColorState _colorState
          The inherited color state.
protected  boolean _completed
          Whether or not the layer has completed.
protected  BaseParticleSystemConfig.Layer _config
          The layer configuration.
protected  Counter _counter
          The particle counter.
protected  GlContext _ctx
          The application context.
protected  float _geometryRadius
          The radius of the geometry (used to expand the bounds).
protected  Influence[] _influences
          The particle influences.
protected  MutableInteger _living
          The number of particles currently alive.
protected  Box _parentBounds
          The parent bounds.
protected  Transform3D _parentViewTransform
          The parent view transform.
protected  Transform3D _parentWorldTransform
          The parent world transform.
protected  Particle[] _particles
          The particles in the layer (first the living particles, then the pre-living particles, then the dead particles).
protected  Placer _placer
          The particle placer.
protected  int _preliving
          The number of particles currently "pre-alive."
protected  Shooter _shooter
          The particle shooter.
protected  float _total
          The total time elapsed since reset.
protected  Transform3D _worldTransform
          The layer's transform in world space.
protected  Transform3D _worldTransformInv
          The inverse of the world space transform.
protected  Quaternion _wrot
          Holds the world/world inverse rotation.
 
Fields inherited from class com.threerings.expr.SimpleScope
_parentScope
 
Fields inherited from interface com.threerings.expr.Scope
EPOCH, NOW
 
Constructor Summary
BaseParticleSystem.Layer(GlContext ctx, Scope parentScope)
          Creates a new layer.
 
Method Summary
protected  void addBounds()
          Adds this layer's bounds to those of its parent.
abstract  void composite()
          Composites the layer for rendering.
 void drawBounds()
          Draws the bounds of the layer.
 Camera getCamera()
          Returns a reference to the camera.
 BaseParticleSystemConfig.Layer getConfig()
          Returns a reference to the layer's config.
 String getScopeName()
          Returns the name of this scope for purposes of qualification.
protected  void initParticle(int idx)
          Initializes the particle at the specified index.
 Vector3f pointToLayer(Vector3f point, boolean emitter)
          Transforms a point in-place from world space or emitter space into the space of the layer (either world space or emitter space, depending on the value of BaseParticleSystemConfig.Layer.moveParticlesWithEmitter).
 void reset()
          Resets the state of the layer.
 Quaternion rotationToLayer(Quaternion rot, boolean emitter)
          Transforms a rotation in-place from world space or emitter space into the space of the layer (either world space or emitter space, depending on the value of BaseParticleSystemConfig.Layer.moveParticlesWithEmitter).
 void setConfig(BaseParticleSystemConfig.Layer config)
          Sets the layer's config.
protected  void swapParticles(int idx0, int idx1)
          Swaps the two particles at the specified indices.
 boolean tick(float elapsed)
          Updates the current particle state based on the elapsed time in seconds.
 Vector3f vectorToLayer(Vector3f vector, boolean emitter)
          Transforms a vector in-place from world space or emitter space into the space of the layer (either world space or emitter space, depending on the value of BaseParticleSystemConfig.Layer.moveParticlesWithEmitter).
 
Methods inherited from class com.threerings.expr.SimpleScope
addListener, dispose, get, getParentScope, removeListener, scopeUpdated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ctx

protected GlContext _ctx
The application context.


_config

@Scoped
protected BaseParticleSystemConfig.Layer _config
The layer configuration.


_parentViewTransform

@Bound(value="viewTransform")
protected Transform3D _parentViewTransform
The parent view transform.


_parentWorldTransform

@Bound(value="worldTransform")
protected Transform3D _parentWorldTransform
The parent world transform.


_parentBounds

@Bound(value="nbounds")
protected Box _parentBounds
The parent bounds.


_colorState

@Bound
protected ColorState _colorState
The inherited color state.


_worldTransform

@Scoped
protected Transform3D _worldTransform
The layer's transform in world space.


_worldTransformInv

protected Transform3D _worldTransformInv
The inverse of the world space transform.


_bounds

@Scoped
protected Box _bounds
The bounds of the layer.


_geometryRadius

protected float _geometryRadius
The radius of the geometry (used to expand the bounds).


_particles

@Scoped
protected Particle[] _particles
The particles in the layer (first the living particles, then the pre-living particles, then the dead particles).


_counter

protected Counter _counter
The particle counter.


_placer

protected Placer _placer
The particle placer.


_shooter

protected Shooter _shooter
The particle shooter.


_influences

protected Influence[] _influences
The particle influences.


_living

@Scoped
protected MutableInteger _living
The number of particles currently alive.


_preliving

protected int _preliving
The number of particles currently "pre-alive."


_total

protected float _total
The total time elapsed since reset.


_completed

protected boolean _completed
Whether or not the layer has completed.


_wrot

protected Quaternion _wrot
Holds the world/world inverse rotation.

Constructor Detail

BaseParticleSystem.Layer

public BaseParticleSystem.Layer(GlContext ctx,
                                Scope parentScope)
Creates a new layer.

Method Detail

setConfig

public void setConfig(BaseParticleSystemConfig.Layer config)
Sets the layer's config.


getConfig

public BaseParticleSystemConfig.Layer getConfig()
Returns a reference to the layer's config.


getCamera

public Camera getCamera()
Returns a reference to the camera.


reset

public void reset()
Resets the state of the layer.


tick

public boolean tick(float elapsed)
Updates the current particle state based on the elapsed time in seconds.

Returns:
true if this layer has completed, false if it is still active.

pointToLayer

public Vector3f pointToLayer(Vector3f point,
                             boolean emitter)
Transforms a point in-place from world space or emitter space into the space of the layer (either world space or emitter space, depending on the value of BaseParticleSystemConfig.Layer.moveParticlesWithEmitter).

Parameters:
emitter - if true, transform from emitter space (else from world space).
Returns:
a reference to the transformed point, for chaining.

vectorToLayer

public Vector3f vectorToLayer(Vector3f vector,
                              boolean emitter)
Transforms a vector in-place from world space or emitter space into the space of the layer (either world space or emitter space, depending on the value of BaseParticleSystemConfig.Layer.moveParticlesWithEmitter).

Parameters:
emitter - if true, transform from emitter space (else from world space).
Returns:
a reference to the transformed vector, for chaining.

rotationToLayer

public Quaternion rotationToLayer(Quaternion rot,
                                  boolean emitter)
Transforms a rotation in-place from world space or emitter space into the space of the layer (either world space or emitter space, depending on the value of BaseParticleSystemConfig.Layer.moveParticlesWithEmitter).

Parameters:
emitter - if true, transform from emitter space (else from world space).
Returns:
a reference to the transformed rotation, for chaining.

drawBounds

public void drawBounds()
Draws the bounds of the layer.


composite

public abstract void composite()
Composites the layer for rendering.


getScopeName

public String getScopeName()
Description copied from interface: Scope
Returns the name of this scope for purposes of qualification. Can return null if qualified symbols cannot specifically address this scope.

Specified by:
getScopeName in interface Scope
Overrides:
getScopeName in class SimpleScope

swapParticles

protected void swapParticles(int idx0,
                             int idx1)
Swaps the two particles at the specified indices.


initParticle

protected void initParticle(int idx)
Initializes the particle at the specified index.


addBounds

protected void addBounds()
Adds this layer's bounds to those of its parent.