v2.0.2
Instance Methods | Properties | List of all members
<CC3MeshParticleProtocol> Protocol Reference

#import <CC3MeshParticles.h>

Inheritance diagram for <CC3MeshParticleProtocol>:
Inheritance graph
[legend]

Instance Methods

(void) - transformVertices
 

Properties

GLuint firstVertexIndexOffset
 
GLuint firstVertexOffset
 
CC3MeshtemplateMesh
 
- Properties inherited from <CC3CommonVertexArrayParticleProtocol>
BOOL hasVertexIndices
 
GLuint vertexCount
 
GLuint vertexIndexCount
 
NSRange vertexIndexRange
 
NSRange vertexRange
 

Detailed Description

CC3MeshParticleProtocol defines the requirements for mesh particles that are emitted and managed by the CC3MeshParticleEmitter class.

Each mesh particle is comprised of an individual mesh. Like any mesh, a mesh particle represents a true 3D object that can have length, width and depth, can be moved, rotated and scaled, and can be colored and covered with a texture.

Each mesh particle uses a CC3Mesh as a template. But, because it is a particle, this basic mesh template is copied into the mesh arrays of the CC3MeshParticleEmitter, where it is merged with the meshes of the other particles managed by the emitter, and is submitted to the GL engine in a single draw call.

Like mesh nodes, mesh particles may be transformed (moved, rotated & scaled). However, unlike mesh nodes, the vertices of a mesh particle are transformed by the CPU in application memory, and the transformed vertices are drawn without further individual transformation by the GPU.

Mesh particles are transformed by the emitter through the transformVertices method on the particle. This method is invoked automatically by the emitter when a particle has been changed, and the mesh particle implementation defines what type of transform occurs when this method is invoked.

This creates a trade-off, where, relative to mesh nodes, the GPU rendering performance is dramatically improved for large numbers of mesh particles, but the CPU load is increased when mesh particles are constantly being transformed, particularly for larger meshes.

Relative to mesh nodes, mesh particles work best when there are many small meshes that are transfomed slowly, where the benefit of drawing in a single call outweighs the cost of processing the vertices in the CPU. For larger meshes, it is more effective to use mesh nodes, where the transformations can be carried out by the GPU.

See the notes of the CC3MeshParticleEmitter class for more info.

Method Documentation

- (void) transformVertices

Transforms the vertices of this particle.

For each emitter, all particles are submitted to the GL engine in a single draw call. This means that all vertices for all particles from that emitter will use the same GL transform matrix, which is defined by the transformation properties of the emitter.

To allow each mesh particle to be transformed independently, the vertices for each particle must be transformed in memory by the CPU.

This method is invoked automatically on any particle that has been updated, when the emitter is transformed. Usually the application never needs to invoke this method directly.

Reimplemented in CC3MeshParticle.

Property Documentation

- (GLuint) firstVertexIndexOffset
readwritenonatomicassign

Returns the index offset, in the underlying mesh vertex index array, of the first vertex index of this particle.

This offset can be used to access the vertex indices directly within the underlying mesh vertex index array.

If the underlying mesh is not using indexed vertices, this property will be set to the same value as the firstVertexOffset property.

- (GLuint) firstVertexOffset
readwritenonatomicassign

Returns the index offset, in the underlying mesh vertex arrays, of the first vertex of this particle.

This offset can be used to access content directly within the underlying mesh vertex arrays.

- (CC3Mesh*) templateMesh
readwritenonatomicretain

The CC3Mesh used as a template for the mesh of this particle.

This particle uses the vertices of this mesh as a starting point. The vertices for the particle are copied into the underlying common mesh that supports all particles emitted by a single emitter. The particle can then manipulate its own copy of the vertices, and can have its own locations, rotations, vertex colors and texture coordinates.

For particles created outside the emitter, and added to the emitter with the emitParticle: method, this property can be set directly by the application to define the mesh of this particle. For particles created within the emitter, and emitted automatically, or via the emitParticle method, this property will be assigned by the emitter, usually from a pre-defined template mesh.


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