Public Member Functions | Static Public Member Functions | Properties

CC3MeshModel Class Reference

A CC3MeshModel holds the 3D mesh for a CC3MeshNode. More...

#import <CC3MeshModel.h>

Inheritance diagram for CC3MeshModel:
CC3Identifiable CC3VertexArrayMeshModel CC3PODMeshModel

List of all members.

Public Member Functions

(void) - createGLBuffers
(CC3NodeBoundingVolume *) - defaultBoundingVolume
(void) - deleteGLBuffers
(void) - draw

Static Public Member Functions

(void) + initializeSwitching
(id) + mesh
(id) + meshWithName:
(id) + meshWithTag:
(id) + meshWithTag:withName:

Properties

BOOL hasNormals

Detailed Description

The CC3MeshNode enapsulates a reference to the CC3MeshModel.

In 3D models, the mesh model generally remains fixed, and transformations such as translation, rotation, and scaling are applied at the node level. A single CC3MeshModel instance, which typically contains a large set of data points, can be used by many nodes simultaneously, and each node instance can be transformed, colored, and textured independently.

With this in mind, and following best practices to consevere memory and processing time, you should strive to create only one CC3MeshModel instance for each distinct mesh in your application, and assign that single CC3MeshModel instance to any number of separate CC3MeshNode instances that make use of it.

When drawing the mesh to the GL engine, this class remembers which mesh was last drawn and only binds the mesh data to the GL engine when a different mesh is drawn. This allows the application to organize the CC3MeshNodes within the CC3World so that nodes using the same mesh model are drawn together, before moving on to other mesh models. This strategy can minimize the number of mesh switches in the GL engine, which improves performance.

CC3MeshModel is an abstract class. Subclasses can be created for loading and managing meshes from different sources and third-party libraries.


Member Function Documentation

- (void) createGLBuffers

Convenience method to create GL buffers for all vertex arrays used by this mesh.

This method may safely be called more than once, or on more than one mesh that shares vertex arrays, since vertex array GL buffers are only created if they don't already exist.

- (CC3NodeBoundingVolume*) defaultBoundingVolume

Returns an allocated, initialized, autorelease instance of the bounding volume to be used by the CC3MeshNode that wraps this mesh model.

This method is called automatically by the CC3MeshNode instance when this mesh model is attached to the CC3MeshNode.

This abstract implementation always returns nil. Subclasses will override to provide an appropriate and useful bounding volume instance.

- (void) deleteGLBuffers

Convenience method to delete any GL buffers for all vertex arrays used by this mesh.

The arrays may continue to be used, and the arrays will be passed from the client during each draw instead of bound to the GL server as a vertex buffer.

This is a convenience method. Because vertex arrays may be shared between arrays, this method should likely be used when it is known that this mesh is the only user of the array, or to clear GL memory for any rarely used meshes. A more general design is to simply release the vertex array. The GL buffer will be deleted when the vertex array is deallocated.

This method may safely be called more than once, or on more than one mesh that shares vertex arrays, since vertex array GL buffers are only deleted if they exist.

- (void) draw

Draws the mesh data to the GL engine.

If this mesh model is different than the last mesh model drawn, this method binds this mesh data to the GL engine. Otherwise, if this mesh model is the same as the mesh model already bound, it is not bound again, Once binding is complete, this method then performs the GL draw operations.

This is invoked automatically from the draw method of the CC3MeshNode instance that is using this mesh model. Usually, the application never needs to invoke this method directly.

+ (void) initializeSwitching

Initializes the tracking of the mesh switching functionality.

This is invoked automatically by the CC3World at the beginning of each frame drawing cycle. Usually, the application never needs to invoke this method directly.

+ (id) mesh

Allocates and initializes an autoreleased unnamed instance with an automatically generated unique tag value.

The tag value is generated using a call to nextTag.

+ (id) meshWithName: (NSString *)  aName

Allocates and initializes an autoreleased instance with the specified name and an automatically generated unique tag value.

The tag value is generated using a call to nextTag.

+ (id) meshWithTag: (GLuint)  aTag

Allocates and initializes an unnamed autoreleased instance with the specified tag.

+ (id) meshWithTag: (GLuint)  aTag
withName: (NSString *)  aName 

Allocates and initializes an autoreleased instance with the specified tag and name.


Property Documentation

- (BOOL) hasNormals [read, assign]

Indicates whether this mesh model contains data for vertex normals.

This abstract implementation always returns NO. Subclasses will override to return an appropriate value.


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