pslib
Class ImageParticle

java.lang.Object
  extended by pslib.GenericParticle
      extended by pslib.DynamicParticle
          extended by pslib.ImageParticle
All Implemented Interfaces:
PSConstants

public class ImageParticle
extends DynamicParticle

ImageParticle Class

The ImageParticle object allows an image to be rendered as a billboard within 3D space. By default the object exhibits the usual billboard behaviour; orienting itself towards the camera. Alternatively the particle may exhibit directional behaviour; orienting itself to its current velocity vector. Additionally, rotation and rotation increment may be specified.

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.


Field Summary
 
Fields inherited from interface pslib.PSConstants
CAM2D_LOOK, CAM2D_RIGHT, CAM2D_UP, CORNER, INVERSE, INVERSE_TRIANGULAR, LEADING, LINEAR, MIDPOINT, NONE, STATIC, TRAILING, TRIANGULAR
 
Constructor Summary
ImageParticle(processing.core.PImage t)
          Create a new object instance with the specified texture
ImageParticle(processing.core.PImage t, int d)
          Create a new object instance with the specified texture and decay time
 
Method Summary
 DynamicParticle copy()
          Return a copy of this particle
 processing.core.PImage getTexture()
          Return a reference to the particle image
 void render(processing.opengl.PGraphicsOpenGL glc)
          Render the particle to the specified renderer
 void render(processing.opengl.PGraphicsOpenGL glc, PSVector cpv, PSVector ctv, PSVector cuv)
          Render the particle to the specified renderer
 void setDirectional(boolean b)
          Set directional behaviour for the billboard
 void setRotation(float r)
          Set the image rotation in radians
 void setRotationIncrement(float i)
          Set the rotation increment in radians
 void setTexture(processing.core.PImage t)
          Set the particle image
 
Methods inherited from class pslib.DynamicParticle
clearBehaviour, debug, debug, getBehaviour, getDecay, getDecayTime, getInitialDecayTime, getMass, getRenderAlpha, getRenderSize, getSnapshot, isDead, isDynamic, map, setAlphaEnvelope, setBehaviour, setBehaviour, setDecayTime, setMass, setSizeEnvelope, update
 
Methods inherited from class pslib.GenericParticle
getAlpha, getColour, getPosition, getSize, getVelocity, setAlpha, setColour, setColour, setPosition, setSize, setVelocity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageParticle

public ImageParticle(processing.core.PImage t)
Create a new object instance with the specified texture

Parameters:
t - texture

ImageParticle

public ImageParticle(processing.core.PImage t,
                     int d)
Create a new object instance with the specified texture and decay time

Parameters:
t - texture
d - decay time (ms)
Method Detail

setTexture

public final void setTexture(processing.core.PImage t)
Set the particle image

Parameters:
t - texture

getTexture

public final processing.core.PImage getTexture()
Return a reference to the particle image

Returns:
a reference to the particle image

setDirectional

public final void setDirectional(boolean b)
Set directional behaviour for the billboard

Parameters:
b - true = directional, false = static

setRotation

public final void setRotation(float r)
Set the image rotation in radians

Rotation occurs around the axis defined by difference between particle and camera locations or around the z-axis if the camera location is unspecified.

Parameters:
r - rotation

setRotationIncrement

public final void setRotationIncrement(float i)
Set the rotation increment in radians

The rotation increment is applied to the image rotation on each call to render() and offers a crude mechanism for automatic rotation.

Parameters:
i - increment

render

public void render(processing.opengl.PGraphicsOpenGL glc)
Render the particle to the specified renderer

Overrides:
render in class DynamicParticle
Parameters:
glc - OpenGL renderer

render

public void render(processing.opengl.PGraphicsOpenGL glc,
                   PSVector cpv,
                   PSVector ctv,
                   PSVector cuv)
Render the particle to the specified renderer

Overrides:
render in class DynamicParticle
Parameters:
glc - OpenGL renderer
cpv - camera position vector
ctv - camera target vector
cuv - camera up vector

copy

public DynamicParticle copy()
Return a copy of this particle

The returned copy will use a reference to the texture image of the source particle and take copies of the rotation, rotation increment and directional variables. The returned object will adhere to the rules defined in the DynamicParticle map() function.

Overrides:
copy in class DynamicParticle
Returns:
a copy of this particle
See Also:
DynamicParticle