GLLineTrailRenderer Class Reference

A Renderer drawing particles as line trails defined by the positions of particles over time. More...

Inheritance diagram for GLLineTrailRenderer:
GLRenderer Renderer Registerable BufferHandler

List of all members.

Public Member Functions

 GLLineTrailRenderer ()
 Default constructor of GLLineTrailRenderer.
void setNbSamples (size_t nbSamples)
 Sets the number of samples in a trail.
void setWidth (float width)
 Sets the width of a trail.
void setDuration (float duration)
 Sets the duration of a sample.
void setDegeneratedLines (float r, float g, float b, float a)
 Sets the color components of degenerated lines.
virtual void enableBlending (bool blendingEnabled)
 Enables or disables the blending of this GLRenderer.
size_t getNbSamples () const
 Gets the number of samples per trail.
float getWidth () const
 Gets the width of a trail.
float getDuration () const
 Gets the duration of a sample.
virtual void createBuffers (const Group &group)
 Creates the buffers for this buffer handler in the given group.
virtual void destroyBuffers (const Group &group)
 Destroys the buffers for this buffer handler in the given group.
void init (const Group &group)
 Inits all the trails of the particle of the group.
virtual void render (const Group &group)
 Renders a Group of particles.

Static Public Member Functions

static GLLineTrailRenderercreate ()
 Creates and registers a new GLLineTrailRenderer.

Protected Member Functions

virtual bool checkBuffers (const Group &group)
 checks the buffers and prepare them

Detailed Description

A Renderer drawing particles as line trails defined by the positions of particles over time.

The trail coordinates are computed in a procedural manner over time.
A trail i defined by a duration. The faster the particle, the longer the trail. It is defined by a numbers of samples.
The sampling frequency of the trail is therefore computed by nbSamples / duration and defines its resolution.
The higher the sampling frequency, the smoother the trail but the bigger the compution time and the memory consumption.

All the particles of a Group are renderered in a single batch of GL_LINE_STRIP, which means every trails belong to the same object to reduce overhead on GPU side.
To allow that, invisible lines link trails together. They are defined as degenerated lines.
This imposes the alpha value is taken into account and the blending is therefore forced with GLLineTrailRenderer.
The user has the possibility to set the RGBA values of degenerated lines to keep them invisible function of the blending mode and environment.
By default it is set to (0.0f,0.0f,0.0f,0.0f).
Below are the parameters of Particle that are used in this Renderer (others have no effects) :

Since:
1.03.00

Definition at line 60 of file SPK_GLLineTrailRenderer.h.


Constructor & Destructor Documentation

Default constructor of GLLineTrailRenderer.


Member Function Documentation

virtual bool checkBuffers ( const Group group  )  [protected, virtual]

checks the buffers and prepare them

This method has to be implemented in derived class that uses buffers.
true must be returned if the buffers are found and initialized, false otherwise.

Parameters:
group : the group in which to check the buffers
Returns:
true if buffers are ready, false otherwise

Reimplemented from BufferHandler.

GLLineTrailRenderer * create (  )  [static]

Creates and registers a new GLLineTrailRenderer.

Returns:
A new registered GLLineTrailRenderer
Since:
1.04.00

Definition at line 198 of file SPK_GLLineTrailRenderer.h.

virtual void createBuffers ( const Group group  )  [virtual]

Creates the buffers for this buffer handler in the given group.

If the buffers for this type of buffer handler already exists within the Group, they are priorly destroyed.
The type of buffers created depends on the state of the buffer handler at the time this method is called.

This method has to be overridden in derived classes that use buffers

Parameters:
group : the Group in which to create the buffers for this buffer handler

Reimplemented from BufferHandler.

virtual void destroyBuffers ( const Group group  )  [virtual]

Destroys the buffers for this buffer handler in the given group.

if the buffers dont exist, nothing happens.

This method has to be overridden in derived classes that use buffers

Parameters:
group : the Group in which to destroy the buffers for this buffer handler

Reimplemented from BufferHandler.

void enableBlending ( bool  blendingEnabled  )  [virtual]

Enables or disables the blending of this GLRenderer.

Parameters:
blendingEnabled true to enable the blending, false to disable it

Reimplemented from GLRenderer.

Definition at line 205 of file SPK_GLLineTrailRenderer.h.

float getDuration (  )  const

Gets the duration of a sample.

Returns:
the duration of a sample

Definition at line 235 of file SPK_GLLineTrailRenderer.h.

size_t getNbSamples (  )  const

Gets the number of samples per trail.

Returns:
the number of samples per trail

Definition at line 225 of file SPK_GLLineTrailRenderer.h.

float getWidth (  )  const

Gets the width of a trail.

Returns:
the width of a trail (in pixels)

Definition at line 230 of file SPK_GLLineTrailRenderer.h.

void init ( const Group group  ) 

Inits all the trails of the particle of the group.

All the samples are set to the current position of the particle.
The trail of each particle has therefore a length of 0 and is ready for update.
This function allows to clear the buffers for GLLineTrailRenderer of the given group.

Parameters:
group : the Group whose buffers need to be initialized
virtual void render ( const Group group  )  [virtual]

Renders a Group of particles.

Parameters:
group : the Group to render

Implements Renderer.

void setDegeneratedLines ( float  r,
float  g,
float  b,
float  a 
)

Sets the color components of degenerated lines.

Parameters:
r : the red component
g : the green component
b : the blue component
a : the alpha component
void setDuration ( float  duration  ) 

Sets the duration of a sample.

The duration of a sample is defined by its life time from its creation to its destruction.
Note that the alpha of a sample will decrease linearly from its initial alpha to 0.

Parameters:
duration : the duration of a sample

Definition at line 220 of file SPK_GLLineTrailRenderer.h.

void setNbSamples ( size_t  nbSamples  ) 

Sets the number of samples in a trail.

The number of samples defines the number of points used to construct the trail.
The bigger the number of samples, the smoother the trail but the bigger the compution time and the memory consumption.

Parameters:
nbSamples : the number of samples to construct the trails

Definition at line 210 of file SPK_GLLineTrailRenderer.h.

void setWidth ( float  width  ) 

Sets the width of a trail.

Like for GLLineRenderer, the width is defined in pixels and is not dependant of the distance of the trail from the camera

Parameters:
width : the width of trails in pixels

Definition at line 215 of file SPK_GLLineTrailRenderer.h.


Generated on Wed Apr 27 21:09:26 2011 for SPARK Particle Engine by  doxygen 1.6.1