Public Member Functions | Properties

CC3PointParticleMesh Class Reference

A mesh whose vertices are used to display point particles. More...

#import <CC3PointParticles.h>

Inheritance diagram for CC3PointParticleMesh:
Inheritance graph
[legend]
Collaboration diagram for CC3PointParticleMesh:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(void) - doNotBufferVertexPointSizes
(GLfloat) - particleSizeAt:
(void) - populateForMaxParticles:containing:
(void) - retainVertexPointSizes
(void) - setParticleSize:at:
(void) - updateParticleSizesGLBuffer

Properties

BOOL hasPointSizes
GLsizei particleCount
CC3VertexPointSizesvertexPointSizes

Detailed Description

A mesh whose vertices are used to display point particles.

This mesh adds the vertexPointSizes property to add a vertex array that manages an optional particle size datum for each vertex.

Each vertex in the vertex arrays defines the visual characteristics for single point particle. This data must include a location, so the vertexLocations array is required by this model (as with any other mesh). In addition, optional characteristics may be specified for each vertex: particle normal, color and size. Therefore, instances of this mesh may also include vertexNormals, vertexColors, and vertexPointSizes arrays (through the CC3VertexArrayMesh superclass).

Since only one vertex is used per point particle, and that data is usually updated frequently by the application, there is little advantage to using indices during drawing. In general, therefore, this mesh will not typically make use of a vertexIndices array.

This subclass also contains several properties and population methods to assist in accessing and managing the data in the vertex arrays.

When creating a particle system, you do not typically need to interact with this class, or create a customized subclass of CC3PointParticleMesh.


Member Function Documentation

- (void) doNotBufferVertexPointSizes

Convenience method to cause the vertex point size data to be skipped when createGLBuffers is invoked.

The vertex data is not buffered to a a GL VBO, is retained in application memory, and is submitted to the GL engine on each frame render.

Only the vertex point sizes will not be buffered to a GL VBO. Any other vertex data, such as locations, or texture coordinates, will be buffered to a GL VBO when createGLBuffers is invoked.

This method causes the vertex data to be retained in application memory, so, if you have invoked this method, you do NOT also need to invoke the retainVertexPointSizes method.

- (GLfloat) particleSizeAt: (GLsizei)  index

Returns the particle size element at the specified index from the vertex data.

The index refers to elements, not bytes. The implementation takes into consideration the elementStride and elementOffset properties to access the correct element.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (void) populateForMaxParticles: (GLuint)  numParticles
containing: (CC3PointParticleVertexContent contentTypes 

Configures this instance to manage the specified maximum number of simultaneous particles.

Each particle will be placed at a vertex in the contained vertex arrays.

The contentTypes parameter is a bitwise-OR of zero or more CC3PointParticleVertexContent values. For example, a value for contentTypes of (kCC3PointParticleContentColor | kCC3PointParticleContentSize) indicates that each particle will be drawn using location, color and size information.

Permitted components for this parameter include:

  • kCC3PointParticleContentLocation
  • kCC3PointParticleContentNormal
  • kCC3PointParticleContentColor
  • kCC3PointParticleContentSize

Since location content is mandatory, the kCC3PointParticleContentLocation does not need to be included in the contentTypes bit-map. Each particle contains at least a location element, so this method always creates and configures a vertexLocations array.

If the kCC3PointParticleContentColor component is specified, the elementType property of the resulting vertexColorArray is set to GL_UNSIGNED_BYTE. However, you may manipulate the data in this array using either byte or float color values, via the setVertexColor4B:at: or setVertexColor4F:at: methods, respectivlely.

Since only one vertex is used per particle, and that data is usually updated frequently by the application, there is little advantage to using indices during drawing. Therefore, drawing is performed by the vertexLocations array, which is configured with a drawingMode property set to GL_POINTS.

Since the vertex data will be frequently updated, the bufferUsage property of the vertexLocations array is set to GL_DYNAMIC_DRAW.

Location, normal, color and size data is interleaved. Therefore, all vertex arrays have the same values in the elements and elementStride properties.

This method automatically allocates memory to hold enough vertex data for the specified maximum number of particles, where each particle contains a location, plus the content indicated by the contentsType parameter.

This method also sets the value of the particleCount property to numParticles.

- (void) retainVertexPointSizes

Convenience method to cause the vertex point size data to be retained in application memory when releaseRedundantData is invoked, even if it has been buffered to a GL VBO.

Only the vertex point sizes will be retained. Any other vertex data, such as locations, or texture coordinates, that has been buffered to GL VBO's, will be released from application memory when releaseRedundantData is invoked.

- (void) setParticleSize: (GLfloat)  aSize
at: (GLsizei)  index 

Sets the particle size element at the specified index in the vertex data to the specified value.

The index refers to elements, not bytes. The implementation takes into consideration the elementStride and elementOffset properties to access the correct element.

When all vertex changes have been made, be sure to invoke the updateParticleSizesGLBuffer method to ensure that the GL VBO that holds the vertex data is updated.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (void) updateParticleSizesGLBuffer

Updates the GL engine buffer with the particle size data in this mesh.


Property Documentation

- (BOOL) hasPointSizes [read, assign]

Indicates whether this mesh contains data for vertex point sizes.

- (GLsizei) particleCount [read, write, assign]

Indicates the number of particles that are alive and being displayed.

This corresponds to the elementCount property of the drawable vertexLocations vertex array. Setting the value of this property modifies the elementCount of all vertex arrays so that only particleCount vertices are drawn.

- (CC3VertexPointSizes *) vertexPointSizes [read, write, retain]

The vertex array instance managing a particle size datum for each particle.

Setting this property is optional. Many particle systems do not require individual sizing for each particle.


The documentation for this class was generated from the following file: