Public Member Functions | Static Public Member Functions | Properties

CC3VertexTextureCoordinates Class Reference

A CC3VertexArray that manages the texture coordinates aspect of an array of vertices. More...

#import <CC3VertexArrays.h>

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

List of all members.

Public Member Functions

(void) - alignWithInvertedTexture:
(void) - alignWithInvertedTextureMapSize:
(void) - alignWithTexture:
(void) - alignWithTextureMapSize:
(void) - flipHorizontally
(void) - flipVertically
(id) - initFromSPODMesh:
(id) - initFromSPODMesh:forTextureUnit:
(void) - setTexCoord2F:at:
(ccTex2F) - texCoord2FAt:

Static Public Member Functions

(id) + arrayFromSPODMesh:forTextureUnit:
(void) + unbind
(void) + unbind:
(void) + unbindRemainingFrom:

Properties

CGRect textureRectangle

Detailed Description

A CC3VertexArray that manages the texture coordinates aspect of an array of vertices.

This class supports multi-texturing, and a single CC3VertexTextureCoordinates instance can be applied to multiple texture units.

This class includes several convenience methods that allow the texture coordinates to be adjusted to match the visible area of a particular texture.

This class also supports covering the mesh with only a fractional part of the texture through the use of the textureRectangle property, effectlivly permitting sprite-sheet textures to be used with 3D meshes.


Member Function Documentation

- (void) alignWithInvertedTexture: (CC3Texture *)  texture

Aligns the texture coordinate array with the specfied texture.

The texture coordinates are aligned assuming that the texture is inverted in the Y-direction. Certain texture formats are inverted during loading, and this method can be used to compensate.

Care should be taken when using this method, as it changes the actual vertex data. This may cause mapping conflicts if the same vertex data is shared by other CC3MeshNodes that use different textures.

- (void) alignWithInvertedTextureMapSize: (ccTex2F)  texMapSize

Aligns the texture coordinate array with the specfied texture map size, which is typically extracted from a specific texture.

The texture coordinates are aligned assuming that the texture is inverted in the Y-direction. Certain texture formats are inverted during loading, and this method can be used to compensate.

Care should be taken when using this method, as it changes the actual vertex data. This may cause mapping conflicts if the same vertex data is shared by other CC3MeshNodes that use different textures.

- (void) alignWithTexture: (CC3Texture *)  texture

Aligns the texture coordinate array with the specfied texture.

Care should be taken when using this method, as it changes the actual vertex data. This may cause mapping conflicts if the same vertex data is shared by other CC3MeshNodes that use different textures.

- (void) alignWithTextureMapSize: (ccTex2F)  texMapSize

Aligns the texture coordinate array with the specfied texture map size, which is typically extracted from a specific texture.

Care should be taken when using this method, as it changes the actual vertex data. This may cause mapping conflicts if the same vertex data is shared by other CC3MeshNodes that use different textures.

+ (id) arrayFromSPODMesh: (PODStructPtr aSPODMesh
forTextureUnit: (GLuint)  texUnit 

Allocates and initializes an autoreleased instance from the specified SPODMesh structure, using the specified texture channel.

- (void) flipHorizontally

Convenience method that flips the texture coordinate mapping horizontally.

This has the effect of flipping the texture horizontally on the model.

- (void) flipVertically

Convenience method that flips the texture coordinate mapping vertically.

This has the effect of flipping the texture vertically on the model.

- (id) initFromSPODMesh: (PODStructPtr aSPODMesh

Initializes this instance from the specified SPODMesh structure, using texture channel zero.

- (id) initFromSPODMesh: (PODStructPtr aSPODMesh
forTextureUnit: (GLuint)  texUnit 

Initializes this instance from the specified SPODMesh structure, using the specified texture channel.

- (void) setTexCoord2F: (ccTex2F)  aTex2F
at: (GLsizei)  index 

Sets the texture coordinate element at the specified index in the underlying vertex data to the specified texture coordinate value.

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.

- (ccTex2F) texCoord2FAt: (GLsizei)  index

Returns the texture coordinate element at the specified index in the underlying 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) unbind

Unbinds all texture arrays from all texture units in the GL engine by disabling texture array handling in the GL engine for all texture units.

Implements CC3VertexArray.

+ (void) unbind: (GLuint)  textureUnit

Unbinds all texture arrays from the specified texture unit in the GL engine by disabling texture array handling in the GL engine for that texture unit.

The texture unit value should be set to a number between zero and the maximum number of texture units, which can be read from [CC3OpenGLES11Engine engine].platform.maxTextureUnits.value.

+ (void) unbindRemainingFrom: (GLuint)  textureUnit

Unbinds all texture arrays from the all texture units at or above the specified texture unit.

The texture unit value should be set to a number between zero and the maximum number of texture units, which can be read from [CC3OpenGLES11Engine engine].platform.maxTextureUnits.value.


Property Documentation

- (CGRect) textureRectangle [read, write, assign]

Defines the rectangular area of the texture that should be mapped to the mesh.

This property facilitates the use of sprite-sheets, where the mesh is covered by a small fraction of a larger texture. This technique has many uses, including animating a texture onto a mesh, where each section of the full texture is really a different frame of a texture animation, or simply loading one larger texture and using parts of it to texture many different meshes.

The dimensions of this rectangle are taken as fractional portions of the full area of the texture. Therefore, a rectangle with zero origin, and unit size ((0.0, 0.0), (1.0, 1.0)) indicates that the mesh should be covered with the complete texture.

A rectangle of smaller size, and/or a non-zero origin, indicates that the mesh should be covered by a fractional area of the texture. For example, a rectangular value for this property with origin at (0.5, 0.5), and size of (0.5, 0.5) indicates that only the top-right quarter of the texture will be used to cover this mesh.

The bounds of the texture rectangle must fit within a unit rectangle. Both the bottom-left and top-right corners must lie between zero and one in both the X and Y directions.

The dimensions of the rectangle in this property are independent of the size specified in the alignWithTextureMapSize: and alignWithInvertedTextureMapSize: methods. A unit rectangle value for this property will automatically take into consideration the adjustment made to the mesh by those methods, and will display only the part of the texture defined by them. Rectangular values for this property that are smaller than the unit rectangle will be relative to the displayable area defined by alignWithTextureMapSize: and alignWithInvertedTextureMapSize:.

As an example, if the alignWithTextureMapSize: method was used to limit the mesh to using only 80% of the texture (perhaps when using a non-POT texture), and this property was set to a rectangle with origin at (0.5, 0.0) and size (0.5, 0.5), the mesh will be covered by the bottom-right quarter of the usable 80% of the overall texture.

The initial value of this property is a rectangle with origin at zero, and unit size, indicating that the mesh will be covered with the complete usable area of the texture.


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