v2.0.2
Instance Methods | Class Methods | Properties | List of all members
CC3FaceArray Class Reference

#import <CC3Mesh.h>

Inheritance diagram for CC3FaceArray:
Inheritance graph
[legend]

Instance Methods

(CC3Vector *) - allocateCenters
 
(CC3FaceIndices *) - allocateIndices
 
(CC3FaceNeighbours *) - allocateNeighbours
 
(CC3Vector *) - allocateNormals
 
(CC3Plane *) - allocatePlanes
 
(CC3Vector- centerAt:
 
(void) - deallocateCenters
 
(void) - deallocateIndices
 
(void) - deallocateNeighbours
 
(void) - deallocateNormals
 
(void) - deallocatePlanes
 
(CC3FaceIndices- indicesAt:
 
(void) - markCentersDirty
 
(void) - markIndicesDirty
 
(void) - markNeighboursDirty
 
(void) - markNormalsDirty
 
(void) - markPlanesDirty
 
(CC3FaceNeighbours- neighboursAt:
 
(CC3Vector- normalAt:
 
(CC3Plane- planeAt:
 
(void) - populateCenters
 
(void) - populateIndices
 
(void) - populateNeighbours
 
(void) - populateNormals
 
(void) - populatePlanes
 
- Instance Methods inherited from CC3Identifiable
(void) - __deprecated
 
(id) - copy
 
(id) - copyAsClass:
 
(void) - copyUserDataFrom:
 
(id) - copyWithName:
 
(id) - copyWithName:asClass:
 
(id) - copyWithZone:withName:
 
(id) - copyWithZone:withName:asClass:
 
(BOOL) - deriveNameFrom:
 
(BOOL) - deriveNameFrom:usingSuffix:
 
(NSString *) - fullDescription
 
(id) - init
 
(id) - initAtIndex:fromPODResource:
 
(void) - initUserData
 
(id) - initWithName:
 
(id) - initWithTag:
 
(id) - initWithTag:withName:
 
(GLuint) - nextTag
 
(void) - populateFrom:
 

Class Methods

(id) + faceArray
 
(id) + faceArrayWithName:
 
(id) + faceArrayWithTag:
 
(id) + faceArrayWithTag:withName:
 
- Class Methods inherited from CC3Identifiable
(GLint) + instanceCount
 
(void) + resetTagAllocation
 

Properties

CC3Vectorcenters
 
GLuint faceCount
 
CC3FaceIndicesindices
 
CC3Meshmesh
 
CC3FaceNeighboursneighbours
 
CC3Vectornormals
 
CC3Planeplanes
 
BOOL shouldCacheFaces
 
- Properties inherited from CC3Identifiable
NSObject *sharedUserData __deprecated
 
NSString * name
 
NSString * nameSuffix
 
GLint podIndex
 
BOOL shouldIncludeInDeepCopy
 
GLuint tag
 
NSObject * userData
 
- Properties inherited from <CC3Cacheable>
NSString * name
 

Detailed Description

CC3FaceArray holds additional cached calculated information about mesh faces, such as the centers, normals, planes and neighbours of each face.

The additional face data is maintained in separate internal arrays, and each type of data is lazily allocated and initialized when accessed the first time. So, requesting information about the center of a face will cause all of the face centers to be calculated and cached, but will not cause the face normals or planes to be calculated and cached. They will be calculated and cached when a face normal or plane is explicitly requested.

Method Documentation

- (CC3Vector*) allocateCenters

Allocates underlying memory for the centers property, and returns a pointer to the allocated memory.

This method will allocate enough memory for the centers property to hold the number of CC3Vector structures specified by the faceCount property.

This method is invoked automatically by the populateCenters method. Usually, the application never needs to invoke this method directly.

It is safe to invoke this method more than once, but understand that any previously allocated memory will be safely released prior to the allocation of the new memory. The memory allocated earlier will therefore be lost and should not be referenced.

The memory allocated will automatically be released when this instance is deallocated.

- (CC3FaceIndices*) allocateIndices

Allocates underlying memory for the indices property, and returns a pointer to the allocated memory.

This method will allocate enough memory for the indices property to hold the number of CC3FaceIndices structures specified by the faceCount property.

This method is invoked automatically by the populateIndices method. Usually, the application never needs to invoke this method directly.

It is safe to invoke this method more than once, but understand that any previously allocated memory will be safely released prior to the allocation of the new memory. The memory allocated earlier will therefore be lost and should not be referenced.

The memory allocated will automatically be released when this instance is deallocated.

- (CC3FaceNeighbours*) allocateNeighbours

Allocates underlying memory for the neighbours property, and returns a pointer to the allocated memory.

This method will allocate enough memory for the normals property to hold the number of CC3FaceNeighbours structures specified by the faceCount property.

This method is invoked automatically by the populateNeighbours method. Usually, the application never needs to invoke this method directly.

It is safe to invoke this method more than once, but understand that any previously allocated memory will be safely released prior to the allocation of the new memory. The memory allocated earlier will therefore be lost and should not be referenced.

The memory allocated will automatically be released when this instance is deallocated.

- (CC3Vector*) allocateNormals

Allocates underlying memory for the normals property, and returns a pointer to the allocated memory.

This method will allocate enough memory for the normals property to hold the number of CC3Vector structures specified by the faceCount property.

This method is invoked automatically by the populateNormals method. Usually, the application never needs to invoke this method directly.

It is safe to invoke this method more than once, but understand that any previously allocated memory will be safely released prior to the allocation of the new memory. The memory allocated earlier will therefore be lost and should not be referenced.

The memory allocated will automatically be released when this instance is deallocated.

- (CC3Plane*) allocatePlanes

Allocates underlying memory for the planes property, and returns a pointer to the allocated memory.

This method will allocate enough memory for the planes property to hold the number of CC3Plane structures specified by the faceCount property.

This method is invoked automatically by the populatePlanes method. Usually, the application never needs to invoke this method directly.

It is safe to invoke this method more than once, but understand that any previously allocated memory will be safely released prior to the allocation of the new memory. The memory allocated earlier will therefore be lost and should not be referenced.

The memory allocated will automatically be released when this instance is deallocated.

- (CC3Vector) centerAt: (GLuint)  faceIndex

Returns the center of the face at the specified index, lazily initializing the centers property if needed.

- (void) deallocateCenters

Deallocates the underlying memory that was previously allocated with the allocateCenters method.

It is safe to invoke this method more than once, or even if the allocateCenters method was not previously invoked.

This method is invoked automatically when allocateCenters is invoked, and when this instance is deallocated. Usually, the application never needs to invoke this method directly.

- (void) deallocateIndices

Deallocates the underlying memory that was previously allocated with the allocateIndices method.

It is safe to invoke this method more than once, or even if the allocateIndices method was not previously invoked.

This method is invoked automatically when allocateIndices is invoked, and when this instance is deallocated. Usually, the application never needs to invoke this method directly.

- (void) deallocateNeighbours

Deallocates the underlying memory that was previously allocated with the allocateNeighbours method.

It is safe to invoke this method more than once, or even if the allocateNeighbours method was not previously invoked.

This method is invoked automatically when allocateNeighbours is invoked, and when this instance is deallocated. Usually, the application never needs to invoke this method directly.

- (void) deallocateNormals

Deallocates the underlying memory that was previously allocated with the allocateNormals method.

It is safe to invoke this method more than once, or even if the allocateNormals method was not previously invoked.

This method is invoked automatically when allocateNormals is invoked, and when this instance is deallocated. Usually, the application never needs to invoke this method directly.

- (void) deallocatePlanes

Deallocates the underlying memory that was previously allocated with the allocatePlanes method.

It is safe to invoke this method more than once, or even if the allocatePlanes method was not previously invoked.

This method is invoked automatically when allocatePlanes is invoked, and when this instance is deallocated. Usually, the application never needs to invoke this method directly.

+ (id) faceArray

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) faceArrayWithName: (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) faceArrayWithTag: (GLuint)  aTag

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

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

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

- (CC3FaceIndices) indicesAt: (GLuint)  faceIndex

Returns the vertex indices of the face at the specified index, lazily initializing the indices property if needed.

- (void) markCentersDirty

Marks the centers data as dirty.

It will be automatically repopulated on the next access.

- (void) markIndicesDirty

Marks the indices data as dirty.

It will be automatically repopulated on the next access.

- (void) markNeighboursDirty

Marks the neighbours data as dirty.

It will be automatically repopulated on the next access.

- (void) markNormalsDirty

Marks the normals data as dirty.

It will be automatically repopulated on the next access.

- (void) markPlanesDirty

Marks the planes data as dirty.

It will be automatically repopulated on the next access.

- (CC3FaceNeighbours) neighboursAt: (GLuint)  faceIndex

Returns the neighbours of the face at the specified index, lazily initializing the neighbours property if needed.

- (CC3Vector) normalAt: (GLuint)  faceIndex

Returns the normal of the face at the specified index, lazily initializing the normals property if needed.

- (CC3Plane) planeAt: (GLuint)  faceIndex

Returns the plane of the face at the specified index, lazily initializing the planes property if needed.

- (void) populateCenters

Populates the contents of the centers property from the associated mesh, automatically allocating memory for the property if needed.

This method is invoked automatically on the first access of the centers property after the mesh property has been set. Usually, the application never needs to invoke this method directly.

However, if the centers property has been set to an array created outside this instance, this method may be invoked to populate that array from the mesh.

In addition, if the mesh is deformed in some way, the application may invoke this method in order to recalculate updated face centers.

- (void) populateIndices

Populates the contents of the indices property from the associated mesh, automatically allocating memory for the property if needed.

This method is invoked automatically on the first access of the indices property after the mesh property has been set. Usually, the application never needs to invoke this method directly.

However, if the indices property has been set to an array created outside this instance, this method may be invoked to populate that array from the mesh.

- (void) populateNeighbours

Populates the contents of the neighbours property from the associated mesh, automatically allocating memory for the property if needed.

This method is invoked automatically on the first access of the neighbours property after the mesh property has been set. Usually, the application never needs to invoke this method directly.

However, if the neighbours property has been set to an array created outside this instance, this method may be invoked to populate that array from the mesh.

- (void) populateNormals

Populates the contents of the normals property from the associated mesh, automatically allocating memory for the property if needed.

This method is invoked automatically on the first access of the normals property after the mesh property has been set, or from the ensureNormals method. Usually, the application never needs to invoke this method directly.

However, if the normals property has been set to an array created outside this instance, this method may be invoked to populate that array from the mesh.

In addition, if the mesh is deformed in some way, the application may invoke this method in order to recalculate updated face normals.

- (void) populatePlanes

Populates the contents of the planes property from the associated mesh, automatically allocating memory for the property if needed.

This method is invoked automatically on the first access of the planes property after the mesh property has been set. Usually, the application never needs to invoke this method directly.

However, if the planes property has been set to an array created outside this instance, this method may be invoked to populate that array from the mesh.

In addition, if the mesh is deformed in some way, the application may invoke this method in order to recalculate updated face planes.

Property Documentation

- (CC3Vector*) centers
readwritenonatomicassign

An array containing the location of the center of each face.

This property will be lazily initialized on the first access after the mesh property has been set, by an automatic invocation of the populateCenters method. When created in this manner, the memory allocated to hold the data in the returned array will be managed by this instance.

Alternately, this property may be set directly to an array that was created externally. In this case, the underlying data memory is not managed by this instance, and it is up to the application to manage the allocation and deallocation of the underlying data memory, and to ensure that the array is large enough to contain the number of CC3Vector structures specified by the faceCount property.

- (GLuint) faceCount
readnonatomicassign

Indicates the number of faces in this array, as retrieved from the mesh.

The value of this property will be zero until the mesh property is set.

- (CC3FaceIndices*) indices
readwritenonatomicassign

An array containing the vertex indices of each face.

This property will be lazily initialized on the first access after the mesh property has been set, by an automatic invocation of the populateIndices method. When created in this manner, the memory allocated to hold the data in the returned array will be managed by this instance.

Alternately, this property may be set directly to an array that was created externally. In this case, the underlying data memory is not managed by this instance, and it is up to the application to manage the allocation and deallocation of the underlying data memory, and to ensure that the array is large enough to contain the number of CC3FaceIndices structures specified by the faceCount property.

- (CC3Mesh*) mesh
readwritenonatomicassign

The mesh containing the vertices for which this face array is managing faces.

Setting this property will cause the centers, normals, planes and neighbours properties to be deallocated and then re-built on the next access.

- (CC3FaceNeighbours*) neighbours
readwritenonatomicassign

An array containing neighbour data for each face.

Each element in this array contains a CC3FaceNeighbours strucutre which keeps track of the indices to the neighbouring faces of each face.

This property will be lazily initialized on the first access after the mesh property has been set, by an automatic invocation of the populateNeighbours method. When created in this manner, the memory allocated to hold the data in the returned array will be managed by this instance.

Alternately, this property may be set directly to an array that was created externally. In this case, the underlying data memory is not managed by this instance, and it is up to the application to manage the allocation and deallocation of the underlying data memory, and to ensure that the array is large enough to contain the number of CC3FaceNeighbours structures specified by the faceCount property.

- (CC3Vector*) normals
readwritenonatomicassign

An array containing the normal vector for each face.

This property will be lazily initialized on the first access after the mesh property has been set, by an automatic invocation of the populateNormals method. When created in this manner, the memory allocated to hold the data in the returned array will be managed by this instance.

Alternately, this property may be set directly to an array that was created externally. In this case, the underlying data memory is not managed by this instance, and it is up to the application to manage the allocation and deallocation of the underlying data memory, and to ensure that the array is large enough to contain the number of CC3Vector structures specified by the faceCount property.

- (CC3Plane*) planes
readwritenonatomicassign

An array containing the plane equation for each face.

This property will be lazily initialized on the first access after the mesh property has been set, by an automatic invocation of the populatePlanes method. When created in this manner, the memory allocated to hold the data in the returned array will be managed by this instance.

Alternately, this property may be set directly to an array that was created externally. In this case, the underlying data memory is not managed by this instance, and it is up to the application to manage the allocation and deallocation of the underlying data memory, and to ensure that the array is large enough to contain the number of CC3Plane structures specified by the faceCount property.

- (BOOL) shouldCacheFaces
readwritenonatomicassign

Indicates whether information about the faces of this mesh should be cached.

If this property is set to NO, accessing information about the faces through the methods indicesAt:, centerAt:, normalAt:, or planeAt:, will be calculated dynamically from the mesh data.

If such data will be accessed frequently, this repeated dynamic calculation may cause a noticable impact to performance. In such a case, this property can be set to YES to cause the data to be calculated once and cached, improving the performance of subsequent accesses to information about the faces.

However, caching information about the faces will increase the amount of memory required by the mesh, sometimes significantly. To avoid this additional memory overhead, in general, you should leave this property set to NO, unless intensive access to face information is causing a performance impact.

An example of a situation where the use of this property may be noticable, is when adding shadow volumes to nodes. Shadow volumes make intense use of accessing face information about the mesh that is casting the shadow.

When the value of this property is set to NO, any data cached during previous access through the indicesAt:, centerAt:, normalAt:, or planeAt:, methods will be cleared.

Because the face neighbour data returned by the neighboursAt: method is a function of the relationship between faces, that data is always cached, and is not affected by the setting of this property.

The initial value of this property is NO.


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