CC3MeshNode Class Reference
Inherits from | CC3LocalContentNode : CC3Node : CC3Identifiable : NSObject |
Declared in | CC3MeshNode.h |
Overview
A CC3Node that draws a 3D mesh. This class forms the base of all visible 3D mesh models in the 3D scene.
CC3MeshNode is a type of CC3Node, and will often participate in a structural node assembly. An instance can be the child of another node, and the mesh node itself can have child nodes.
CC3MeshNodes encapsulate a CC3Mesh instance, and a CC3Material instance. The CC3Mesh instance contains the mesh vertex content. The CC3Material instance describes the material and texture properties covering the mesh, which can be affected by lighting conditions.
If it is not explicitly set beforehand, the material will automatically be created and assigned to the mesh node when a texture is added to the mesh node through the texture property or the addTexture: method, or if any of the material properties of the mesh node are set or accessed, including color, opacity, ambientColor, diffuseColor, specularColor, emissionColor, blendFunc, isOpaque, shouldUseLighting, or shouldDrawLowAlpha.
There are a number of populateAs… parametric population methods available in the CC3MeshNode (ParametricShapes) category extension. These methods can be used to populate the vertices of the mesh contained in a new mesh node to create interesting and useful parametric shapes and surfaces.
When this node is drawn, it delegates to the mesh instance to render the mesh vertices. Before drawing the mesh, it delegates to the material to configure the covering of the mesh.
Each CC3MeshNode can have only one material. For large, complicated meshes that are covered by more than one material, the mesh must be broken into smaller meshes, each of which is covered by a single material. These smaller sub-meshes are sometimes referred to as “vertex groups”. Each such sub-mesh is then wrapped in its own CC3MeshNode instance, along with the material that covers that sub-mesh.
These CC3MeshNode instances can then be added as child nodes to a single parent CC3Node instance. This parent CC3Node can then be moved, rotated and scaled, and all of its child nodes will transform in sync. The assembly will behave and be seen as a single object.
When the mesh is set in the mesh property, the CC3MeshNode instance creates and builds a CC3NodeBoundingVolume instance from the mesh data, and sets it into its boundingVolume property.
When a copy is made of a CC3MeshNode instance using the copy method, a copy is made of the material, but the mesh is simply assigned by reference, and is not copied. The result is that the the new and original nodes will have different materials, but will share the same mesh. This design avoids creating multiple copies of volumnious and static mesh data when creating copies of nodes.
Normally, the front faces of a mesh are displayed, and the back faces are culled and not displayed. You can change this behaviour if you need to be changing the values of the shouldCullFrontFaces and shouldCullBackFaces properties. An example might be if you wanted to show the back-side of a planar sign, or if you wanted to show the inside faces of a skybox.
However, be aware that culling is a significant performance-improving technique. You should avoid disabling backface culling except where specifically needed for visual effect. And when you do, if you only need the back faces, turn on front face culling for that mesh by setting the shouldCullFrontFaces property to YES.
CC3MeshNode extension to support bitmapped labels. Extensions to CC3MeshNode to support PVR POD data. CC3MeshNode extension to define polymorphic methods to support vertex skinning.
This CC3MeshNode extension adds a number of methods for populating the mesh of a mesh node programatically to create various parametric shapes and surfaces.
To use the methods in this extension, instantiate a CC3MeshNode, and then invoke one of the methods in this extension of CC3MeshNode in order to populate the mesh vertices.
Depending on the shape of the mesh you are creating, you may want to actually instantiate one of the specialized subclasses of CC3MeshNode, since they often add more functionality to the specific shape.
Tasks
Other Methods
-
mesh
property -
__deprecated
property -
– ensureMesh
-
– makeMesh
-
isUsingGLBuffers
property -
effectiveNormalScalingMethod
property -
material
property -
shouldUseLighting
property -
shouldUseLightProbes
property -
ambientColor
property -
diffuseColor
property -
specularColor
property -
emissionColor
property -
shininess
property -
reflectivity
property -
– ensureMaterial
-
– makeMaterial
-
shaderContext
property -
shaderProgram
property -
– selectShaderProgram
-
– removeLocalShaders
-
– clearShaderProgram
-
color
property -
opacity
property -
isOpaque
property -
blendFunc
property -
shouldDrawLowAlpha
property -
textureCount
property -
texture
property -
– addTexture:
-
– removeAllTextures
-
– textureForTextureUnit:
-
– setTexture:forTextureUnit:
-
expectsVerticallyFlippedTextures
property -
– expectsVerticallyFlippedTextureInTextureUnit:
-
– expectsVerticallyFlippedTexture:inTextureUnit:
-
– flipVerticallyTextureUnit:
-
– flipTexturesVertically
-
– flipHorizontallyTextureUnit:
-
– flipTexturesHorizontally
-
– repeatTexture:forTextureUnit:
-
– repeatTexture:
-
textureRectangle
property -
– textureRectangleForTextureUnit:
-
– setTextureRectangle:forTextureUnit:
-
isDrawingPointSprites
property -
hasTextureAlpha
property -
hasTexturePremultipliedAlpha
property -
shouldApplyOpacityToColor
property -
vertexContentTypes
property -
– moveMeshOriginTo:
-
– moveMeshOriginToCenterOfGeometry
-
– movePivotTo:
-
– movePivotToCenterOfGeometry
-
vertexCount
property -
vertexIndexCount
property -
– vertexLocationAt:
-
– setVertexLocation:at:
-
– vertexHomogeneousLocationAt:
-
– setVertexHomogeneousLocation:at:
-
– vertexNormalAt:
-
– setVertexNormal:at:
-
– vertexTangentAt:
-
– setVertexTangent:at:
-
– vertexBitangentAt:
-
– setVertexBitangent:at:
-
vertexColorType
property -
– vertexColor4FAt:
-
– setVertexColor4F:at:
-
– vertexColor4BAt:
-
– setVertexColor4B:at:
-
vertexBoneCount
property -
– vertexWeightForBoneInfluence:at:
-
– setVertexWeight:forBoneInfluence:at:
-
– vertexBoneWeightsAt:
-
– setVertexBoneWeights:at:
-
– vertexBoneIndexForBoneInfluence:at:
-
– setVertexBoneIndex:forBoneInfluence:at:
-
– vertexBoneIndicesAt:
-
– setVertexBoneIndices:at:
-
vertexBoneIndexType
property -
– vertexTexCoord2FForTextureUnit:at:
-
– setVertexTexCoord2F:forTextureUnit:at:
-
– vertexTexCoord2FAt:
-
– setVertexTexCoord2F:at:
-
– vertexTexCoord2FAt:forTextureUnit:
-
– setVertexTexCoord2F:at:forTextureUnit:
-
– vertexIndexAt:
-
– setVertexIndex:at:
-
– updateVertexLocationsGLBuffer
-
– updateVertexNormalsGLBuffer
-
– updateVertexTangentsGLBuffer
-
– updateVertexBitangentsGLBuffer
-
– updateVertexColorsGLBuffer
-
– updateVertexBoneWeightsGLBuffer
-
– updateVertexBoneIndicesGLBuffer
-
– updateVertexTextureCoordinatesGLBufferForTextureUnit:
-
– updateVertexTextureCoordinatesGLBuffer
-
– updateGLBuffers
-
– updateVertexIndicesGLBuffer
-
shouldCacheFaces
property -
faceCount
property -
– faceCountFromVertexIndexCount:
-
– vertexIndexCountFromFaceCount:
-
– faceCountFromVertexCount:
-
– vertexCountFromFaceCount:
-
– faceAt:
-
– faceFromIndices:
-
– faceIndicesAt:
-
– faceCenterAt:
-
– faceNormalAt:
-
– facePlaneAt:
-
– faceNeighboursAt:
-
– findFirst:intersections:ofLocalRay:acceptBackFaces:acceptBehindRay:
-
– findFirst:globalIntersections:ofGlobalRay:acceptBackFaces:acceptBehindRay:
-
drawingMode
property -
– drawWithVisitor:
-
– vertexWeightForVertexUnit:at:
-
– setVertexWeight:forVertexUnit:at:
-
– vertexWeightsAt:
-
– setVertexWeights:at:
-
– vertexMatrixIndexForVertexUnit:at:
-
– setVertexMatrixIndex:forVertexUnit:at:
-
– vertexMatrixIndicesAt:
-
– setVertexMatrixIndices:at:
-
– updateVertexWeightsGLBuffer
-
– updateVertexMatrixIndicesGLBuffer
BitmapLabel Methods
PFXEffects Methods
DeprecatedParametricShapes Methods
-
– populateAsRectangleWithSize:andPivot:
-
– populateAsRectangleWithSize:andPivot:andTessellation:
-
– populateAsCenteredTexturedRectangleWithSize:
-
– populateAsCenteredTexturedRectangleWithSize:andTessellation:
-
– populateAsTexturedRectangleWithSize:andPivot:
-
– populateAsTexturedRectangleWithSize:andPivot:andTessellation:
-
– populateAsCenteredRectangleWithSize:withTexture:invertTexture:
-
– populateAsCenteredRectangleWithSize:andTessellation:withTexture:invertTexture:
-
– populateAsRectangleWithSize:andPivot:withTexture:invertTexture:
-
– populateAsRectangleWithSize:andPivot:andTessellation:withTexture:invertTexture:
-
– populateAsTexturedBox:
-
– populateAsTexturedBox:withCorner:
PVRPOD Methods
Skinning Methods
-
hasSkeleton
property -
hasRigidSkeleton
property -
– deformedFaceAt:
-
– deformedFaceCenterAt:
-
– deformedFaceNormalAt:
-
– deformedFacePlaneAt:
-
– deformedVertexLocationAt:fromFaceAt:
ParametricShapes Methods
-
– prepareParametricMesh
-
– populateAsTriangle:withTexCoords:andTessellation:
-
– populateAsCenteredRectangleWithSize:
-
– populateAsCenteredRectangleWithSize:andTessellation:
-
– populateAsRectangleWithSize:andRelativeOrigin:
-
– populateAsRectangleWithSize:andRelativeOrigin:andTessellation:
-
– populateAsDiskWithRadius:andTessellation:
-
– populateAsSolidBox:
-
– populateAsCubeMappedSolidBox:
-
– populateAsSolidBox:withCorner:
-
– populateAsWireBox:
-
– populateAsSphereWithRadius:andTessellation:
-
– populateAsHollowConeWithRadius:height:andTessellation:
-
– populateAsLineStripWith:vertices:andRetain:
TemplateMethods Methods
Properties
__deprecated
@deprecated CC3MeshModel renamed to CC3Mesh. Use mesh property instead.
@property (nonatomic, retain) CC3Mesh *__deprecated
Declared In
CC3MeshNode.h
ambientColor
The ambient color of the material of this mesh node.
@property (nonatomic, assign) ccColor4F ambientColor
Discussion
Material color is initially set to kCC3DefaultMaterialColorAmbient. If this instance has no material, this property will return kCCC4FBlackTransparent.
The value of this property is also affected by changes to the color and opacity properties. See the notes for those properties for more information.
Declared In
CC3MeshNode.h
blendFunc
Implementation of the CCBlendProtocol blendFunc property.
@property (nonatomic, assign) ccBlendFunc blendFunc
Discussion
This is a convenience property that gets and sets both the sourceBlend and destinationBlend properties of the material used by this node using a single structure. Changes to this property is also passed along to any child nodes. Querying this property returns {GL_ONE, GL_ZERO} if this node has no material.
Declared In
CC3MeshNode.h
color
The color of this node, as described by the color of the material covering this node.
@property (nonatomic, assign) CCColorRef color
Discussion
Querying this property returns the value of the same property of the enclosed material.
Setting this property sets the same property on the enclosed material, and on the mesh, if the shouldApplyOpacityAndColorToMeshContent property is set to YES, and also sets the same property on all descendant nodes.
Declared In
CC3MeshNode.h
diffuseColor
The diffuse color of the material of this mesh node.
@property (nonatomic, assign) ccColor4F diffuseColor
Discussion
Material color is initially set to kCC3DefaultMaterialColorDiffuse. If this instance has no material, this property will return kCCC4FBlackTransparent.
The value of this property is also affected by changes to the color and opacity properties. See the notes for those properties for more information.
Declared In
CC3MeshNode.h
drawingMode
The drawing mode indicating how the vertices are connected (points, lines, triangles…).
@property (nonatomic, assign) GLenum drawingMode
Discussion
This must be set with a valid GL drawing mode enumeration. The default value is GL_TRIANGLES.
Declared In
CC3MeshNode.h
effectiveNormalScalingMethod
The normal scaling method that is currently in use for this mesh node.
@property (nonatomic, readonly) CC3NormalScaling effectiveNormalScalingMethod
Discussion
This property differs from the normalScalingMethod. The normalScalingMethod is a settable property that is used to indicate the desired scaling method to be used for normals, and can include a setting of kCC3NormalScalingAutomatic, to allow the mesh node to resolve which method to use. This property returns that resolved value.
If the mesh has vertex normals, this property will match the normalScalingMethod for values kCC3NormalScalingNone, kCC3NormalScalingRescale & kCC3NormalScalingNormalize. If the mesh does not contain vertex normals, this property will always return kCC3NormalScalingNone.
Declared In
CC3MeshNode.h
emissionColor
The emission color of the material of this mesh node.
@property (nonatomic, assign) ccColor4F emissionColor
Discussion
Material color is initially set to kCC3DefaultMaterialColorEmission. If this instance has no material, this property will return kCCC4FBlackTransparent.
The value of this property is also affected by changes to the opacity property. See the notes for the opacity property for more information.
Declared In
CC3MeshNode.h
expectsVerticallyFlippedTextures
Indicates whether the texture coordinates of this mesh expects that the texture was flipped upside-down during texture loading.
@property (nonatomic, assign) BOOL expectsVerticallyFlippedTextures
Discussion
The vertical axis of the coordinate system of OpenGL is inverted relative to the CoreGraphics view coordinate system. As a result, some texture file formats may be loaded upside down. Most common file formats, including JPG, PNG & PVR are loaded right-way up, but using proprietary texture formats developed for other platforms may result in textures being loaded upside-down.
The value of this property is used in combination with the value of the isUpsideDown property of a texture to determine whether the texture will be oriented correctly when displayed using these texture coordinates.
When a texture or material is assigned to this mesh node, the value of this property is compared with the isUpsideDown property of the texture to automatically determine whether these texture coordinates need to be flipped vertically in order to display the texture correctly. If needed, the texture coordinates will be flipped automatically. As part of that inversion, the value of this property will also be flipped, to indicate that the texture coordinates are now aligned differently.
If you need to adjust the value of this property, you sould do so before setting a texture or material into this mesh node.
When multi-texturing is being used on this mesh, you can use the expectsVerticallyFlippedTexture:inTextureUnit: method for finer control of orienting textures for each texture unit.
When multi-texturing is being used, setting this value of this property will use the expectsVerticallyFlippedTexture:inTextureUnit: method to set the same value for each texture unit.
Reading the value of this property will return YES if the property-reading method expectsVerticallyFlippedTextureInTextureUnit: returns YES for any texture unit, otherwise this property will return NO.
The initial value of this property is set when the underlying mesh texture coordinates are built or loaded. See the same property on the CC3NodesResource class to understand how this property is set during mesh resource loading.
When building meshes programmatically, you should endeavour to design the mesh so that this property will be YES if you will be using vertically-flipped textures (all texture file formats except PVR). This avoids the texture coordinate having to be flipped automatically when a texture or material is assigned to this mesh node.
Declared In
CC3MeshNode.h
faceCount
Returns the number of faces in this mesh.
@property (nonatomic, readonly) GLuint faceCount
Discussion
This is calculated from the number of vertices, taking into consideration the type of primitives that this mesh is drawing.
Declared In
CC3MeshNode.h
hasRigidSkeleton
Returns whether the skeletal structures controlling any descendant skinned mesh nodes are composed of bones that undergo only rigid transforms, relative to their nearest ancestor soft-body node.
@property (nonatomic, readonly) BOOL hasRigidSkeleton
Discussion
The initial value of this property is NO. It is set to YES when the ensureRigidSkeleton method is invoked on this node, or an ancestor node, and this mesh node has a skeleton (as indicated by the hasSkeleton property of this node).
When the bones in a skeleton contain only rigid transforms, the vertices in the skin-mesh node can be transformed within a shader using rotations and transforms, instead of a full transform matrix. This allows for many more bones to be transferred to the shader program during a single GL draw call, which increases performance in many larger meshes.
Consequently, the value of this property affects the choice of shader that will be selected automatically for this node.
Declared In
CC3VertexSkinning.h
hasSkeleton
Returns whether the vertices of this mesh node are influenced by a skeleton of bones.
@property (nonatomic, readonly) BOOL hasSkeleton
Discussion
Vertex skinning (also known as bone-rigging) is a technique of manipulating, or deforming, the vertices of a mesh through the movement of a skeleton of bones.
This implementation returns NO. Subclasses that support vertex skinning (notably the CC3SkinMeshNode subclass) will return YES if the vertices are influenced by a skeleton of bone nodes.
Declared In
CC3VertexSkinning.h
hasTextureAlpha
Returns whether any of the textures used by this material have an alpha channel, representing opacity.
@property (nonatomic, readonly) BOOL hasTextureAlpha
Discussion
Returns YES if any of the textures contained in this instance has an alpha channel.
See also the notes of the shouldBlendAtFullOpacity property for the effects of using a texture with an alpha channel.
Declared In
CC3MeshNode.h
hasTexturePremultipliedAlpha
Returns whether the alpha channel has already been multiplied into each of the RGB color channels, in any of the textures used by this material.
@property (nonatomic, readonly) BOOL hasTexturePremultipliedAlpha
Discussion
Returns YES if any of the textures contained in this instance has pre-mulitiplied alpha.
See also the notes of the shouldApplyOpacityToColor property for the effects of using textures with pre-multiplied alpha.
Declared In
CC3MeshNode.h
isDrawingPointSprites
Returns whether this mesh is being drawn as point sprites.
@property (nonatomic, readonly) BOOL isDrawingPointSprites
Discussion
This property returns YES if this mesh node has a texture and the drawingMode property is set to GL_POINTS, otherwise this property returns NO.
Declared In
CC3MeshNode.h
isOpaque
Indicates whether the material of this mesh node is opaque.
@property (nonatomic, assign) BOOL isOpaque
Discussion
If this node has a material, returns the value of the same property on the material, otherwise return YES.
Setting this property sets the same property in the material and in all descendants.
See the notes for this property on CC3Material for more information on how this property interacts with the other material properties.
Setting this property should be thought of as a convenient way to switch between the two most common types of blending combinations. For finer control of blending, set specific blending properties on the CC3Material instance directly, and avoid making changes to this property.
Declared In
CC3MeshNode.h
isUsingGLBuffers
Returns whether the underlying vertex content has been loaded into GL engine vertex buffer objects. Vertex buffer objects are engaged via the createGLBuffers method.
@property (nonatomic, readonly) BOOL isUsingGLBuffers
Declared In
CC3MeshNode.h
material
The material covering this mesh node.
@property (nonatomic, retain) CC3Material *material
Discussion
When querying this property, if a material does not yet exist, this method invokes the makeMaterial method to create a suitable material, and sets it into this property.
Declared In
CC3MeshNode.h
mesh
The mesh that holds the vertex content for this mesh node.
@property (nonatomic, retain) CC3Mesh *mesh
Discussion
When this property is set, if this node has a boundingVolume, it is forced to rebuild itself, otherwise, if this node does not have a boundingVolume, a default bounding volume is created from the mesh. In addition, if the mesh does not have normals, the shouldUseLighting property of this node is set to NO, and if the mesh does not have texture coordinates, the texture property of this node is set to nil.
Declared In
CC3MeshNode.h
opacity
The opacity of this node, as described by the opacity of the material covering this mesh.
@property (nonatomic, assign) CCOpacity opacity
Discussion
Querying this property returns the value of the same property of the enclosed material.
Setting this property sets the same property on the enclosed material, and on the mesh, if the shouldApplyOpacityAndColorToMeshContent property is set to YES, and also sets the same property on all descendant nodes.
See the notes for this property on CC3Material for more information on how this property interacts with the other material properties.
Setting this property should be thought of as a convenient way to switch between the two most common types of blending combinations. For finer control of blending, set specific blending properties on the CC3Material instance directly, and avoid making changes to this property.
Declared In
CC3MeshNode.h
podMaterialIndex
The index of the material in the POD file used by this node.
@property (nonatomic, assign) int podMaterialIndex
Declared In
CC3PODMeshNode.h
reflectivity
The reflectivity of the material of this mesh node.
@property (nonatomic, assign) GLfloat reflectivity
Discussion
This property can be used when the material is covered by an environmental reflection cube-map texture to indicate the weighting that should be applied to the reflection texture, relative to any other textures on the material. A value of zero indicates that the surface should be completely unreflective, and a value of one indicates that the surface is entirely reflective.
This property requires a programmable pipeline and has no effect when running OpenGL ES 1.1.
The value of this property is clamped to between zero and one. The initial value of this property is kCC3DefaultMaterialReflectivity (zero).
Declared In
CC3MeshNode.h
shaderContext
The GLSL shader program context containing the GLSL program (vertex & fragment shaders) used to draw this node.
@property (nonatomic, retain) CC3ShaderContext *shaderContext
Discussion
A single CC3ShaderProgram object can be used by many nodes. The CC3ShaderContext instance in this property contains state and behaviour specific to the use of the shader program by this mesh node.
Each shader program typically makes use of many uniform variables. In most, or many, cases, each uniform will have a semantic defined, and the content of the uniform will automatically be extracted from the environment, including from this mesh node itself. So, in most cases, once the semantic is defined, the application needs pay no further attention to the uniform.
The shader context can be used to modify this standard semanitic-driven behaviour in two ways. This shader context can be used to assign a value to a specialized or custom shader uniform whose value is not derived semantically from the node or the environment, and it can be used to override the value of an otherwise semantically-derived uniform, if needed.
If this property is not set directly, it is automatically initialized to a new shader context instance on first access (typically when the shaderProgram property is established, or a uniform override is added). Unless you have a need to set the value of this property directly, you can simply let it be managed automatically.
This property is used only when running under OpenGL ES 2.
Declared In
CC3MeshNode.h
shaderProgram
The GLSL program (vertex & fragment shaders) used to draw this node.
@property (nonatomic, retain) CC3ShaderProgram *shaderProgram
Discussion
The program is held in the shader context in the shaderContext property. This is a convenience property that allows the shader program to be accessed from the shaderContext.
Setting the value of this property will set the specified program into the context in the shaderContext property, creating a new shader context if necessary.
As an alternative to setting this property directly, you can either access this property, or invoke the selectShaderProgram method (or let it be invoked automatically during the first draw), to have an appropriate shader program automatically selected for use by this node, and assigned to this property,
This property is used only when running under OpenGL ES 2.
Declared In
CC3MeshNode.h
shininess
The shininess of the material of this mesh node.
@property (nonatomic, assign) GLfloat shininess
Discussion
The value of this property is clamped to between zero and kCC3MaximumMaterialShininess. The initial value of this property is kCC3DefaultMaterialShininess (zero).
Declared In
CC3MeshNode.h
shouldApplyOpacityToColor
Returns whether the opacity of each of the material colors (ambient, diffuse, specular and emission) should be blended (multiplied) by its alpha value prior to being submitted to the GL engine, and whether the alpha component of any vertex color should be blended into the vertex color.
@property (nonatomic, readonly) BOOL shouldApplyOpacityToColor
Discussion
This property returns the value of the same property of the material of this node.
If this property returns YES, each of the material colors will automatically be blended with its alpha component prior to being submitted to the GL engine, and any vertex color set using the setVertexColor4B:at: or setVertexColor4F:at: methods will automatically have its alpha value blended into (multiplied into) each of the red, green and blue components of that vertex color, before the color is set into the vertex.
Declared In
CC3MeshNode.h
shouldCacheFaces
Indicates whether information about the faces of this mesh should be cached.
@property (nonatomic, assign) BOOL shouldCacheFaces
Discussion
If this property is set to NO, accessing information about the faces through the methods faceAt:, faceIndicesAt:, faceCenterAt:, faceNormalAt:, or facePlaneAt:, 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 faceIndicesAt:, faceCenterAt:, faceNormalAt:, or facePlaneAt:, methods will be cleared.
The initial value of this property is NO.
Declared In
CC3MeshNode.h
shouldDrawLowAlpha
Indicates whether alpha testing should be used to determine if pixels with lower alpha values should be drawn.
@property (nonatomic, assign) BOOL shouldDrawLowAlpha
Discussion
Setting or reading the value of this property will set or return the value of the same property on the material covering this mesh.
If the value of this property is set to YES, each pixel will be drawn regardless of the value of its alpha component. If the value of this property is set to NO, the value of the alpha component of each pixel will be compared against the value in the alphaTestReference property of the material, and only those pixel alpha values that are greater than that reference value will be drawn. You can set the value of the alphaTestReference property of the material to determine the cutoff level.
The initial value of this property is YES, indicating that pixels with lower alpha values will be drawn.
For most situations, alpha testing is not necessary, and you can leave the value of this property set to YES. Alpha testing can sometimes be useful when drawing overlapping objects that each contain transparency, and it is not possible to rely only on drawing order and depth testing to mediate whether a pixel should be drawn.
Declared In
CC3MeshNode.h
shouldUseLightProbes
If this value is set to YES, this mesh node will ignore the lights in the scene and will, instead, determine the lighting of the mesh node using textures held by light probes in the scene.
@property (nonatomic, assign) BOOL shouldUseLightProbes
Discussion
This property only has effect if the shouldUseLighting property is set to YES.
The initial value of this property is NO.
See the notes of the CC3LightProbe class to learn more about using light probes to illuminate models within the scene.
Declared In
CC3MeshNode.h
shouldUseLighting
If this value is set to YES, current lighting conditions (from either lights or light probes) will be taken into consideration when drawing colors and textures.
@property (nonatomic, assign) BOOL shouldUseLighting
Discussion
If this value is set to NO, lighting conditions will be ignored when drawing colors and textures, and the emissionColor will be applied to the mesh surface, without regard to lighting. Blending will still occur, but the other material aspects, including ambientColor, diffuseColor, specularColor, and shininess will be ignored. This is useful for a cartoon effect, where you want a pure color, or the natural colors of the texture, to be included in blending calculations, without having to arrange lighting, or if you want those colors to be displayed in their natural values despite current lighting conditions.
Be aware that the initial value of the emissionColor property is normally black. If you find your node disappears or turns black when you set this property to NO, try changing the value of the emissionColor property.
Setting the value of this property sets the same property in the contained material. Reading the value of this property returns the value of the same property in the contained material.
The initial value of this property is YES.
Declared In
CC3MeshNode.h
specularColor
The specular color of the material of this mesh node.
@property (nonatomic, assign) ccColor4F specularColor
Discussion
Material color is initially set to kCC3DefaultMaterialColorSpecular. If this instance has no material, this property will return kCCC4FBlackTransparent.
The value of this property is also affected by changes to the opacity property. See the notes for the opacity property for more information.
Declared In
CC3MeshNode.h
texture
When the material covering this mesh contains a single texture, this property references that texture. When multi-texturing is in use, and the material holds more than one texture, this property references the texture that will be processed by GL texture unit zero.
@property (nonatomic, retain) CC3Texture *texture
Discussion
If a material does not yet exist in this mesh node, a new material will be created and the texture will be attached to it.
Under iOS, during loading, textures are padded to dimensions of a power-of-two (POT) and, because vertical OpenGL coordinates are inverted relative to iOS view coordinates, most texture formats are loaded updside-down.
To compensate, when a texture is attached to a mesh node, the texture coordinates of the mesh are automatically adjusted to correctly display the texture, taking into consideration POT padding and vertical orientation.
When building for iOS, raw PNG and TGA images are pre-processed by Xcode to pre-multiply alpha, and to reorder the pixel component byte order, to optimize the image for the iOS platform. If you want to avoid this pre-processing for PNG or TGA files, for textures such as normal maps or lighting maps, that you don’t want to be modified, you can prepend a ‘p’ to the file extension (“ppng” or “ptga”) to cause Xcode to skip this pre-processing and to use a loader that does not pre-multiply the alpha. You can also use this for other file types as well. See the notes for the CC3STBImage useForFileExtensions class-side property for more info.
Declared In
CC3MeshNode.h
textureCount
Returns the number of textures covering this mesh, regardless of whether the textures were attached using the texture property or the addTexture: method.
@property (nonatomic, readonly) GLuint textureCount
Declared In
CC3MeshNode.h
textureRectangle
Defines the rectangular area of the textures, for all texture units, that should be mapped to the mesh used by this node.
@property (nonatomic, assign) CGRect textureRectangle
Discussion
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.
This property affects all texture units used by this mesh, to query or change this property for a single texture unit only, use the textureRectangleForTextureUnit: and setTextureRectangle:forTextureUnit: methods.
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.
Declared In
CC3MeshNode.h
vertexBoneCount
Returns the number of bones that influence each vertex in this mesh. This value defines the number of bone weights and bone indices that are attached to each vertex.
@property (nonatomic, readonly) GLuint vertexBoneCount
Declared In
CC3MeshNode.h
vertexBoneIndexType
Returns the type of data element used to store each bone index.
@property (nonatomic, readonly) GLenum vertexBoneIndexType
Discussion
The value returned by this property will be either GL_UNSIGNED_SHORT or GL_UNSIGNED_BYTE, corresponding to each bone index being stored in either a type GLushort or type GLubyte, respectively.
You can use the value of this property to determine how to cast the data arrays used by the vertexBoneIndicesAt: and setVertexBoneIndices:at: methods.
Declared In
CC3MeshNode.h
vertexColorType
Returns the symbolic content type of the vertex color, which indicates the range of values stored for each vertex color.
@property (nonatomic, readonly) GLenum vertexColorType
Discussion
This property will return one of the values: GL_FLOAT, GL_UNSIGNED_BYTE, or GL_FIXED, or will return GL_FALSE if this node does not have a mesh, or if that mesh does not support individual vertex colors.
You can use the value returned by this property to select whether to access individual vertex color content as bytes or floats, in order to retain accuracy and avoid unnecessary type conversions.
Declared In
CC3MeshNode.h
vertexContentTypes
Indicates the types of content contained in each vertex of this mesh.
@property (nonatomic, assign) CC3VertexContent vertexContentTypes
Discussion
Each vertex can contain several types of content, optionally including location, normal, color, texture coordinates, along with other specialized content for certain specialized meshes. To identify this various content, this property is a bitwise-OR of flags that enumerate the types of content contained in each vertex of this mesh.
Valid component flags of this property include: – kCC3VertexContentLocation – kCC3VertexContentNormal – kCC3VertexContentTangent – kCC3VertexContentBitangent – kCC3VertexContentColor – kCC3VertexContentTextureCoordinates – kCC3VertexContentBoneWeights – kCC3VertexContentBoneIndices – kCC3VertexContentPointSize
To indicate that this mesh should contain particular vertex content, construct a bitwise-OR combination of one or more of the component types listed above, and set this property to that combined value.
Setting this property affects the underlying mesh. When this property is set, if a mesh has not yet been set in the mesh property of this node, a new CC3Mesh, set to interleave vertex content, will automatically be created and set into the mesh property of this node.
When setting this property, if the kCC3VertexContentTextureCoordinates component is not included, the texture property will be set to nil. If the kCC3VertexContentNormal component is not included, the shouldUseLighting property will be set to NO automatically.
This property is a convenience property. You can also construct the mesh by managing the vertex content directly by assigning specific vertex arrays to the appropriate properties on the underlying mesh.
The mesh constructed by this property will be configured to use interleaved data if the shouldInterleaveVertices property of the mesh is set to YES. You should ensure the value of the shouldInterleaveVertices property of the underlying mesh is set to the desired value before setting the value of this property. The initial value of the shouldInterleaveVertices property is YES.
If the content is interleaved, for each vertex, the content is held in the structures identified in the list above, in the order that they appear in the list. You can use this consistent organization to create an enclosing structure to access all data for a single vertex, if it makes it easier to access vertex content that way. If vertex content is not specified, it is simply absent, and the content from the following type will be concatenated directly to the content from the previous type.
For instance, in a typical textured and illuminated mesh, you might not require per-vertex color, tangent and bitangent content. You would therefore omit the kCC3VertexContentColor, kCC3VertexContentTangent and kCC3VertexContentBitangent values in the bitmask when setting this property, and the resulting structure for each vertex would be a location CC3Vector, followed by a normal CC3Vector, followed immediately by a texture coordinate ccTex2F. You can then define an enclosing structure to hold and manage all content for a single vertex. In this particular example, this is already done for you with the CC3TexturedVertex structure.
You can declare and use such a custom vertex structure even if you have constructed the vertex arrays directly, without using this property. The structure of the content of a single vertex is the same in either case.
The vertex arrays created in the underlying mesh by this property cover the most common use cases and data formats. If you require more customized vertex arrays, you can use this property to create the typical mesh content, and then customize the mesh, by accessing the vertex arrays individually through their respective properties on the mesh. After doing so, if the vertex content is interleaved, you should invoke the updateVertexStride method on the mesh to automatically align the elementOffset and vertexStride properties of all of the vertex arrays. After setting this property, you do not need to invoke the updateVertexStride method unless you subsequently make changes to the constructed vertex arrays.
It is safe to set this property more than once. Doing so will remove any existing vertex arrays and replace them with those indicated by this property.
When reading this property, the appropriate bitwise-OR values are returned, corresponding to the mesh vertex arrays, even if those arrays were constructed directly, instead of through setting this property. If this mesh contains no vertex arrays, this property will return kCC3VertexContentNone.
Declared In
CC3MeshNode.h
vertexCount
Indicates the number of vertices in this mesh.
@property (nonatomic, assign) GLuint vertexCount
Discussion
Usually, you should treat this property as read-only. However, there may be occasions with meshes that contain dynamic content, such as particle systems, where it may be appropriate to set the value of this property.
Setting the value of this property changes the amount of vertex content that will be submitted to the GL engine during drawing.
When setting this property, care should be taken to ensure that the value is not set larger than the number of vertices that were allocated for this mesh.
Declared In
CC3MeshNode.h
vertexIndexCount
If indexed drawing is used by this mesh, indicates the number of vertex indices in the mesh.
@property (nonatomic, assign) GLuint vertexIndexCount
Discussion
If indexed drawing is not used by this mesh, this property has no effect, and reading it will return zero.
Usually, you should treat this property as read-only. However, there may be occasions with meshes that contain dynamic content, such as particle systems, where it may be appropriate to set the value of this property.
Setting the value of this property changes the amount of vertex content that will be submitted to the GL engine during drawing.
When setting this property, care should be taken to ensure that the value is not set larger than the number of vertices that were allocated for this mesh.
Declared In
CC3MeshNode.h
Instance Methods
addTexture:
In most situations, the material will use a single CC3Texture in the texture property. However, if multi-texturing is used, additional CC3Texture instances can be provided by adding them using this method.
- (void)addTexture:(CC3Texture *)aTexture
Discussion
If a material does not yet exist in this mesh node, a new material will be created and the texture will be attached to it.
When multiple textures are attached to a material, when drawing, the material will combine these textures together using configurations contained in the textureUnit property of each texture.
As a consistency convenience, if the texture property has not yet been set directly, the first texture added using this method will appear in that property.
Textures are processed by GL texture units in the order they are added to the material. The first texture added (or set directly into the texture property) will be processed by GL texture unit zero. Subsequent textures added with this method will be processed by subsequent texture units, in the order they were added.
The maximum number of texture units available is platform dependent, but will be at least two. The maximum number of texture units available can be read from the CC3OpenGL.sharedGL.maxNumberOfTextureUnits property. If you attempt to add more than this number of textures to the material, the additional textures will be ignored, and an informational message to that fact will be logged.
Under iOS, during loading, textures are padded to dimensions of a power-of-two (POT) and, because vertical OpenGL coordinates are inverted relative to iOS view coordinates, most texture formats are loaded updside-down.
To compensate, when a texture is attached to a mesh node, the texture coordinates of the mesh are automatically adjusted to correctly display the texture, taking into consideration POT padding and vertical orientation.
When building for iOS, raw PNG and TGA images are pre-processed by Xcode to pre-multiply alpha, and to reorder the pixel component byte order, to optimize the image for the iOS platform. If you want to avoid this pre-processing for PNG or TGA files, for textures such as normal maps or lighting maps, that you don’t want to be modified, you can prepend a ‘p’ to the file extension (“ppng” or “ptga”) to cause Xcode to skip this pre-processing and to use a loader that does not pre-multiply the alpha. You can also use this for other file types as well. See the notes for the CC3STBImage useForFileExtensions class-side property for more info.
Declared In
CC3MeshNode.h
applyEffectNamed:inPFXResourceFile:
Applies the PFX effect with the specified name, found in the CC3PFXResource loaded from the specfied file, to all descendant mesh nodes.
- (void)applyEffectNamed:(NSString *)effectName inPFXResourceFile:(NSString *)filePath
Discussion
Sets the shader program to that defined by the retrieved PFX effect, and sets the textures of the material in each mesh node to those defined by the retrieved PFX effect
Raises an assertion error if the PFX resource file could not be loaded, or if that PFX resource does not contain an effect with the specified effect name.
Declared In
CC3PFXResource.h
applyEffectNamed:inPFXResourceNamed:
Applies the PFX effect with the specified name, found in the cached CC3PFXResource with the specifed name, to all descendant mesh nodes.
- (void)applyEffectNamed:(NSString *)effectName inPFXResourceNamed:(NSString *)rezName
Discussion
Sets the shader program to that defined by the retrieved PFX effect, and sets the textures of the material in each mesh node to those defined by the retrieved PFX effect
Raises an assertion error if a PFX resource with the specified name cannot be found in the PFX resource cache, or if that PFX resource does not contain an effect with the specified effect name.
Declared In
CC3PFXResource.h
clearShaderProgram
@deprecated Renamed to removeLocalShaders.
- (void)clearShaderProgram
Declared In
CC3MeshNode.h
deformedFaceAt:
Returns the face from the mesh at the specified index.
- (CC3Face)deformedFaceAt:(GLuint)faceIndex
Discussion
If the vertices of this mesh node represent the skin covering the bones of a soft-body, the vertex locations of the returned face take into consideration the current deformation caused by motion of the bones underlying the this skin mesh. Otherwise, this method returns the same value as the faceAt: method.
In either case, the vertex locations of the returned face are specified in the local coordinate system of this node.
The specified faceIndex value refers to the index of the face, not the vertices themselves. So, a value of 5 will retrieve the three vertices that make up the fifth triangular face in this mesh. The specified index must be between zero, inclusive, and the value of the faceCount property, exclusive.
The returned face structure contains only the locations of the vertices. If the vertex locations are interleaved with other vertex data, such as color or texture coordinates, or other padding, that data will not appear in the returned face structure. For that remaining vertex data, you can use the faceIndicesAt: method to retrieve the indices of the vertex data, and then use the vertex accessor methods to retrieve the individual vertex data components.
Declared In
CC3VertexSkinning.h
deformedFaceCenterAt:
Returns the center of the mesh face at the specified index.
- (CC3Vector)deformedFaceCenterAt:(GLuint)faceIndex
Discussion
If the vertices of this mesh node represent the skin covering the bones of a soft-body, the returned location takes into consideration the current deformation caused by motion of the bones underlying the this skin mesh. The returned location is the center of the face in its location and orientation after the skin has been deformed by the current position of the underlying bones. Otherwise, this method returns the same value as the faceCenterAt: method.
In either case, the returned face center is specified in the local coordinate system of this node.
Declared In
CC3VertexSkinning.h
deformedFaceNormalAt:
Returns the normal of the mesh face at the specified index.
- (CC3Vector)deformedFaceNormalAt:(GLuint)faceIndex
Discussion
If the vertices of this mesh node represent the skin covering the bones of a soft-body, the returned normal takes into consideration the current deformation caused by motion of the bones underlying the this skin mesh. The returned vector is the normal of the face in its orientation after the skin has been deformed by the current position of the underlying bones. Otherwise, this method returns the same value as the faceNormalAt: method.
In either case, the returned face normal is specified in the local coordinate system of this node.
Declared In
CC3VertexSkinning.h
deformedFacePlaneAt:
Returns the plane of the mesh face at the specified index.
- (CC3Plane)deformedFacePlaneAt:(GLuint)faceIndex
Discussion
If the vertices of this mesh node represent the skin covering the bones of a soft-body, the returned plane takes into consideration the current deformation caused by motion of the bones underlying the this skin mesh. The returned plane is the plane of the face in its location and orientation after the skin has been deformed by the current position of the underlying bones. Otherwise, this method returns the same value as the facePlaneAt: method.
In either case, the returned face plane is specified in the local coordinate system of this node.
Declared In
CC3VertexSkinning.h
deformedVertexLocationAt:fromFaceAt:
Returns the vertex from the mesh at the specified vtxIndex, that is within the face at the specified faceIndex.
- (CC3Vector)deformedVertexLocationAt:(GLuint)vertexIndex fromFaceAt:(GLuint)faceIndex
Discussion
If the vertices of this mesh node represent the skin covering the bones of a soft-body, the returned vertex location takes into consideration the current deformation caused by motion of the bones underlying the this skin mesh. Otherwise, this method returns the same value as the vertexLocationAt: method.
In either case, the returned vertex location is specified in the local coordinate system of this node.
The specified faceIndex value refers to the index of the face that contains the vertex. It is required to determine the skin section whose bones are deforming the vertex location at the specified vertex index. The specified faceIndex must be between zero, inclusive, and the value of the faceCount property, exclusive.
The specified vtxIndex must be between zero, inclusive, and the value of the vertexCount property, exclusive.
Declared In
CC3VertexSkinning.h
drawWithVisitor:
Draws the local content of this mesh node by following these steps: –# If the shouldDecorateNode property of the visitor is YES, and this node has a material, invokes the drawWithVisitor method of the material. Otherwise, invokes the CC3Material class-side unbind method. –# Invokes the drawWithVisitor: method of the encapsulated mesh.
- (void)drawWithVisitor:(CC3NodeDrawingVisitor *)visitor
Discussion
This method is called automatically from the transformAndDrawWithVisitor: method of this node. Usually, the application never needs to invoke this method directly.
Declared In
CC3MeshNode.h
ensureMaterial
@deprecated The material property now performs this functionality lazily.
- (CC3Material *)ensureMaterial
Declared In
CC3MeshNode.h
ensureMesh
If a mesh does not yet exist, this method invokes the makeMesh method to create a suitable mesh, and sets it into the mesh property. Does nothing if this mesh node already has a mesh. Returns the mesh (existing or new).
- (CC3Mesh *)ensureMesh
Discussion
This method is invoked whenever a property is set that would affect the mesh. Usually, you will never need to invoke this method.
Declared In
CC3MeshNode.h
expectsVerticallyFlippedTexture:inTextureUnit:
Sets whether the texture coordinates for the specfied texture unit expects that the texture was flipped upside-down during texture loading.
- (void)expectsVerticallyFlippedTexture:(BOOL)expectsFlipped inTextureUnit:(GLuint)texUnit
Discussion
See the notes of the expectsVerticallyFlippedTextureInTextureUnit: method for a discussion of texture coordinate orientation.
Setting the value of this property will change the way the texture coordinates are aligned when a texture is assigned to cover this texture unit for this mesh.
Declared In
CC3MeshNode.h
expectsVerticallyFlippedTextureInTextureUnit:
Returns whether the texture coordinates for the specfied texture unit expects that the texture was flipped upside-down during texture loading.
- (BOOL)expectsVerticallyFlippedTextureInTextureUnit:(GLuint)texUnit
Discussion
The vertical axis of the coordinate system of OpenGL is inverted relative to the iOS view coordinate system. This results in textures from most file formats being oriented upside-down, relative to the OpenGL coordinate system. All file formats except PVR format will be oriented upside-down after loading.
The value of this property is used in combination with the value of the isUpsideDown property of a texture to determine whether the texture will be oriented correctly when displayed using these texture coordinates.
When a texture or material is assigned to this mesh node, the value of this property is compared with the isUpsideDown property of the texture to automatically determine whether these texture coordinates need to be flipped vertically in order to display the texture correctly, and if needed, the texture coordinates will be flipped automatically. As part of that inversion, the value of this property will also be flipped, to indicate that the texture coordinates are now aligned differently.
If you need to adjust the value of this property, you sould do so before setting a texture or material into this mesh node.
The initial value of this property is set when the underlying mesh texture coordinates are built or loaded. See the expectsVerticallyFlippedTextures property on the CC3NodesResource class to understand how this property is set during mesh resource loading from model files.
When building meshes programmatically, you should endeavour to design the mesh so that this property will be YES if you will be using vertically-flipped textures (all texture file formats except PVR).
Declared In
CC3MeshNode.h
faceAt:
Returns the face from the mesh at the specified index.
- (CC3Face)faceAt:(GLuint)faceIndex
Discussion
The specified faceIndex value refers to the index of the face, not the vertices themselves. So, a value of 5 will retrieve the three vertices that make up the fifth triangular face in this mesh. The specified index must be between zero, inclusive, and the value of the faceCount property, exclusive.
The returned face structure contains only the locations of the vertices. If the vertex locations are interleaved with other vertex content, such as color or texture coordinates, or other padding, that data will not appear in the returned face structure. For that remaining vertex content, you can use the faceIndicesAt: method to retrieve the indices of the vertex content, and then use the vertex accessor methods to retrieve the individual vertex content components.
If you will be invoking this method frequently, you can optionally set the shouldCacheFaces property to YES to speed access, and possibly improve performance. However, be aware that setting the shouldCacheFaces property to YES can significantly increase the amount of memory used by the mesh.
Declared In
CC3MeshNode.h
faceCenterAt:
Returns the center of the mesh face at the specified index.
- (CC3Vector)faceCenterAt:(GLuint)faceIndex
Discussion
If you will be invoking this method frequently, you can optionally set the shouldCacheFaces property to YES to speed access, and possibly improve performance. However, be aware that setting the shouldCacheFaces property to YES can significantly increase the amount of memory used by the mesh.
Declared In
CC3MeshNode.h
faceCountFromVertexCount:
@deprecated Renamed to faceCountFromVertexIndexCount:.
- (GLuint)faceCountFromVertexCount:(GLuint)vc
Declared In
CC3MeshNode.h
faceCountFromVertexIndexCount:
Returns the number of faces to be drawn from the specified number of vertex indices, based on the type of primitives that this mesh is drawing.
- (GLuint)faceCountFromVertexIndexCount:(GLuint)vc
Declared In
CC3MeshNode.h
faceFromIndices:
Returns the mesh face that is made up of the three vertices at the three indices within the specified face indices structure.
- (CC3Face)faceFromIndices:(CC3FaceIndices)faceIndices
Discussion
The returned face structure contains only the locations of the vertices. If the vertex locations are interleaved with other vertex content, such as color or texture coordinates, or other padding, that data will not appear in the returned face structure. For that remaining vertex content, you can use the faceIndicesAt: method to retrieve the indices of the vertex content, and then use the vertex accessor methods to retrieve the individual vertex content components.
Declared In
CC3MeshNode.h
faceIndicesAt:
Returns the face from the mesh at the specified index, as indices into the mesh vertices.
- (CC3FaceIndices)faceIndicesAt:(GLuint)faceIndex
Discussion
The specified faceIndex value refers to the index of the face, not the vertices themselves. So, a value of 5 will retrieve the three vertices that make up the fifth triangular face in this mesh. The specified index must be between zero, inclusive, and the value of the faceCount property, exclusive.
The returned structure reference contains the indices of the three vertices that make up the triangular face. These indices index into the actual vertex content within the layout of the mesh.
This method takes into consideration any padding (stride) between the vertex indices.
If you will be invoking this method frequently, you can optionally set the shouldCacheFaces property to YES to speed access, and possibly improve performance. However, be aware that setting the shouldCacheFaces property to YES can significantly increase the amount of memory used by the mesh.
Declared In
CC3MeshNode.h
faceNeighboursAt:
Returns the indices of the neighbours of the mesh face at the specified index.
- (CC3FaceNeighbours)faceNeighboursAt:(GLuint)faceIndex
Declared In
CC3MeshNode.h
faceNormalAt:
Returns the normal of the mesh face at the specified index.
- (CC3Vector)faceNormalAt:(GLuint)faceIndex
Discussion
If you will be invoking this method frequently, you can optionally set the shouldCacheFaces property to YES to speed access, and possibly improve performance. However, be aware that setting the shouldCacheFaces property to YES can significantly increase the amount of memory used by the mesh.
Declared In
CC3MeshNode.h
facePlaneAt:
Returns the plane of the mesh face at the specified index.
- (CC3Plane)facePlaneAt:(GLuint)faceIndex
Discussion
If you will be invoking this method frequently, you can optionally set the shouldCacheFaces property to YES to speed access, and possibly improve performance. However, be aware that setting the shouldCacheFaces property to YES can significantly increase the amount of memory used by the mesh.
Declared In
CC3MeshNode.h
findFirst:globalIntersections:ofGlobalRay:acceptBackFaces:acceptBehindRay:
Populates the specified array with information about the intersections of the specified ray and this mesh, up to the specified maximum number of intersections.
- (GLuint)findFirst:(GLuint)maxHitCount globalIntersections:(CC3MeshIntersection *)intersections ofGlobalRay:(CC3Ray)aRay acceptBackFaces:(BOOL)acceptBackFaces acceptBehindRay:(BOOL)acceptBehind
Discussion
This is a convenience method that converts the specified global ray to the local coordinate system of this node, and invokes the findFirst:intersections:ofLocalRay:acceptBackFaces:acceptBehindRay: method, and converts the location and distance components of each of the elements in the intersections array to the global coordinate system.
See the notes for the findFirst:intersections:ofLocalRay:acceptBackFaces:acceptBehindRay: method to understand more about how to use this method.
Declared In
CC3MeshNode.h
findFirst:intersections:ofLocalRay:acceptBackFaces:acceptBehindRay:
Populates the specified array with information about the intersections of the specified ray and this mesh, up to the specified maximum number of intersections.
- (GLuint)findFirst:(GLuint)maxHitCount intersections:(CC3MeshIntersection *)intersections ofLocalRay:(CC3Ray)aRay acceptBackFaces:(BOOL)acceptBackFaces acceptBehindRay:(BOOL)acceptBehind
Discussion
This method returns the actual number of intersections found (up to the specified maximum). This value indicates how many of the elements of the specifed intesections array were populated during the execution of this method. The contents of elements beyond that number are undefined.
Each of the populated elements of the intersections array contains information about the face on which the intersection occurred, the location of the intersection, and the distance from the ray startLocation where the intersection occurred. The location and distance components are specified in the local coordinates system of this mesh.
The intersections array is not sorted in any way. In particular, when the array contains multiple entries, the first element in the array does not necessily contain the closest intersection. If you need to determine the closest intersection, you can iterate the intersections array and compare the values of the location element of each intersection.
To use this method, allocate an array of CC3MeshIntersection structures, pass a reference to it in the intersections parameter, and indicate the size of that array in the maxHitCount parameter.
The method iterates through the faces in the mesh until the indicated number of intersections are found, or until all the faces in the mesh have been inspected. Therefore, to keep performance high, you should set the maxHitCount parameter no higher than the number of intersections that are useful to you. For example, specifiying a value of one for the maxHitCount parameter will cause this method to return as soon as the first intersection is found. In most cases, this is all that is needed.
The allowBackFaces parameter is used to indicate whether to include intersections where the ray pierces a face from its back face. Typically, this means that the ray has intersected the face as the ray exits on the far side of the mesh. In most cases you will interested only where the ray intersects the near side of the mesh, in which case you can set this parameter to NO.
The allowBehind parameter is used to indicate whether to include intersections that occur behind the startLocation of the ray, in the direction opposite to the direction of the ray. Typically, this might mean the mesh is located behind the ray startLocation, or it might mean the ray starts inside the mesh. Again,in most cases, you will be interested only in intersections that occur in the direction the ray is pointing, and can ususally set this parameter to NO.
Declared In
CC3MeshNode.h
flipHorizontallyTextureUnit:
Convenience method that flips the texture coordinate mapping horizontally for the specified texture channels. This has the effect of flipping the texture for that texture channel horizontally on the model. and can be useful for creating interesting effects, or mirror images.
- (void)flipHorizontallyTextureUnit:(GLuint)texUnit
Discussion
This implementation flips correctly if the mesh is mapped to only a section of the texture (a texture atlas).
Declared In
CC3MeshNode.h
flipTexturesHorizontally
Convenience method that flips the texture coordinate mapping horizontally for all texture units. This has the effect of flipping the textures horizontally on the model. and can be useful for creating interesting effects, or mirror images.
- (void)flipTexturesHorizontally
Discussion
This implementation flips correctly if the mesh is mapped to only a section of the texture (a texture atlas).
This has the same effect as invoking the flipHorizontallyTextureUnit: method for all texture units.
This method will also invoke the superclass behaviour to invoke the same method on each child node.
Declared In
CC3MeshNode.h
flipTexturesVertically
Convenience method that flips the texture coordinate mapping vertically for all texture units. This has the effect of flipping the textures vertically on the model. and can be useful for creating interesting effects, or mirror images.
- (void)flipTexturesVertically
Discussion
This implementation flips correctly if the mesh is mapped to only a section of the texture (a texture atlas).
This has the same effect as invoking the flipVerticallyTextureUnit: method for all texture units.
This method will also invoke the superclass behaviour to invoke the same method on each child node.
Declared In
CC3MeshNode.h
flipVerticallyTextureUnit:
Convenience method that flips the texture coordinate mapping vertically for the specified texture channels. This has the effect of flipping the texture for that texture channel vertically on the model. and can be useful for creating interesting effects, or mirror images.
- (void)flipVerticallyTextureUnit:(GLuint)texUnit
Discussion
This implementation flips correctly if the mesh is mapped to only a section of the texture (a texture atlas).
Declared In
CC3MeshNode.h
initAtIndex:fromPODResource:
Initializes this instance from the data of this type at the specified index within the specified POD resource.
- (id)initAtIndex:(GLint)aPODIndex fromPODResource:(CC3PODResource *)aPODRez
Declared In
CC3IdentifiablePODExtensions.h
makeMaterial
Creates and returns a suitable material for this mesh node.
- (CC3Material *)makeMaterial
Discussion
This method is invoked automatically by the material property accessor method if a material is needed, but has not yet been established.
This implementation returns an instance of CC3Material initialized with the default initializer method. Subclasses may override to provide a different material.
Declared In
CC3MeshNode.h
makeMesh
This template method creates a suitable mesh for this mesh node.
- (CC3Mesh *)makeMesh
Discussion
This implementation invokes [CC3Mesh mesh], and returns the result. Subclasses may override to provide a different mesh.
This method is invoked automatically by the ensureMesh method if a mesh is needed, but has not yet been established. Usually, you will never need to invoke this method.
Declared In
CC3MeshNode.h
moveMeshOriginTo:
Changes the mesh vertices so that the origin of the mesh is at the specified location.
- (void)moveMeshOriginTo:(CC3Vector)aLocation
Discussion
The origin of the mesh is the location (0,0,0) in the local coordinate system, and is the location around which all transforms are performed.
This method can be used to adjust the mesh structure to make it easier to apply transformations, by moving the origin of the transformations to a more convenient location in the mesh.
This method changes the location component of every vertex in the mesh. This can be quite costly, and should only be performed once, to adjust a mesh so that it is easier to manipulate. As an alternate, you should consider changing the origin of the mesh at development time using a 3D editor.
Do not use this method to move your model around. Instead, use the transform properties (location, rotation and scale) of this node, and let the GL engine do the heavy lifting of transforming the mesh vertices.
This method automatically invokes the markBoundingVolumeDirty method, to ensure that the boundingVolume encompasses the new vertex locations.
This method also ensures that the GL VBO that holds the vertex content is updated.
Declared In
CC3MeshNode.h
moveMeshOriginToCenterOfGeometry
Changes the mesh vertices so that the origin of the mesh is at the center of geometry of the mesh.
- (void)moveMeshOriginToCenterOfGeometry
Discussion
The origin of the mesh is the location (0,0,0) in the local coordinate system, and is the location around which all transforms are performed.
This method can be used to adjust the mesh structure to make it easier to apply transformations, by moving the origin of the transformations to the center of the mesh.
This method changes the location component of every vertex in the mesh. This can be quite costly, and should only be performed once, to adjust a mesh so that it is easier to manipulate. As an alternate, you should consider changing the origin of the mesh at development time using a 3D editor.
Do not use this method to move your model around. Instead, use the transform properties (location, rotation and scale) of this node, and let the GL engine do the heavy lifting of transforming the mesh vertices.
This method automatically invokes the markBoundingVolumeDirty method, to ensure that the boundingVolume encompasses the new vertex locations.
This method also ensures that the GL VBO that holds the vertex content is updated.
Declared In
CC3MeshNode.h
movePivotTo:
@deprecated Renamed to moveMeshOriginTo:.
- (void)movePivotTo:(CC3Vector)aLocation
Declared In
CC3MeshNode.h
movePivotToCenterOfGeometry
@deprecated Renamed to moveMeshOriginToCenterOfGeometry.
- (void)movePivotToCenterOfGeometry
Declared In
CC3MeshNode.h
nodePODStructAtIndex:fromPODResource:
Returns the underlying SPODNode data structure from the specified resource, for the SPODNode at the specified index.
- (PODStructPtr)nodePODStructAtIndex:(uint)aPODIndex fromPODResource:(CC3PODResource *)aPODRez
Discussion
The returned pointer must be cast to SPODNode before accessing any internals of the data structure.
Declared In
CC3NodePODExtensions.h
populateAsBitmapFontLabelFromString:fromFontFile:andLineHeight:andTextAlignment:andRelativeOrigin:andTessellation:
Populates this instance as a rectangular mesh displaying the text of the specified string, built from bitmap character images taken from a texture atlas as defined by the bitmpped font configuration loaded from the specified font configuration file.
- (void)populateAsBitmapFontLabelFromString:(NSString *)lblString fromFontFile:(NSString *)fontFileName andLineHeight:(GLfloat)lineHeight andTextAlignment:(NSTextAlignment)textAlignment andRelativeOrigin:(CGPoint)origin andTessellation:(CC3Tessellation)divsPerChar
Discussion
A compatible bitmap font configuration file, and associated texture, can be created using any of these editors: http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) http://www.bmglyph.com/ (Commercial, Mac OS X – also available through AppStore) http://www.n4te.com/hiero/hiero.jnlp (Free, Java) http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) http://www.angelcode.com/products/bmfont/ (Free, Windows only)
The texture that matches the specified font configuration (and identified in the font configuration), is automatically loaded and assigned to the texture property of this mesh node.
The text may be multi-line, and can be left-, center- or right-aligned, as specified.
The specified lineHeight define the height of a line of text in the coordinate system of this mesh node. This parameter can be set to zero to use the natural line height of the font.
For example, a font with font size of 16 might have a natural line height of 19. Setting the lineHeight parameter to zero would result in a mesh where a line of text would be 19 units high. On the other hand, setting this property to 0.2 will result in a mesh where the same line of text has a height of 0.2 units. Depending on the size of other models in your scene, you may want to set this lineHeight to something compatible. In addition, the visual size of the text will also be affected by the value of the scale or uniformScale properties of this node. Both the lineHeight and scale properties work to establish the visual size of the label text.
For a more granular mesh, each character rectangle can be divided into many smaller divisions. Building a rectanglular surface from more than one division can dramatically improve realism when the surface is illuminated with specular lighting or a tightly focused spotlight, or if the mesh is to be deformed in some way by a later process (such as wrapping the text texture around some other shape).
The divsPerChar argument indicates how to break each character rectangle into multiple faces. The X & Y elements of the divsPerChar argument indicate how each axis if the rectangle for each character should be divided into faces. The number of faces in the rectangle for each character will therefore be the multiplicative product of the X & Y elements of the divsPerChar argument.
For example, a value of {3,2} for the divsPerChar argument will result in each character being divided into 6 smaller rectangular faces, arranged into a 3x2 grid.
The relative origin defines the location of the origin for texture alignment, and is specified as a fraction of the size of the overall label layout, starting from the bottom-left corner.
For example, origin values of (0, 0), (0.5, 0.5), and (1, 1) indicate that the label mesh should be aligned so that the bottom-left corner, center, or top-right corner, respectively, should be located at the local origin of the corresponding mesh.
The vertexContentType property of this mesh may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate), and the mesh will be populated with location, normal and texture coordinates for each vertex.
This method may be invoked repeatedly to change the label string. The mesh will automomatically be rebuilt to the correct number of vertices required to display the currently specified string.
Declared In
CC3BitmapLabelNode.h
populateAsCenteredRectangleWithSize:
Populates this instance as a simple rectangular mesh of the specified size, centered at the origin, and laid out on the X-Y plane.
- (void)populateAsCenteredRectangleWithSize:(CGSize)rectSize
Discussion
The rectangular mesh contains only one face with two triangles. The result is the same as invoking populateAsCenteredRectangleWithSize:andTessellation: with the divsPerAxis argument set to {1,1}.
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this node to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh node may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
Declared In
CC3ParametricMeshNodes.h
populateAsCenteredRectangleWithSize:andTessellation:
Populates this instance as a simple rectangular mesh of the specified size, centered at the origin, and laid out on the X-Y plane.
- (void)populateAsCenteredRectangleWithSize:(CGSize)rectSize andTessellation:(CC3Tessellation)divsPerAxis
Discussion
The large rectangle can be divided into many smaller divisions. Building a rectanglular surface from more than one division can dramatically improve realism when the surface is illuminated with specular lighting or a tightly focused spotlight, because increasing the face count increases the number of vertices that interact with the specular or spot lighting.
The divsPerAxis argument indicates how to break this large rectangle into multiple faces. The X & Y elements of the divsPerAxis argument indicate how each axis if the rectangle should be divided into faces. The total number of faces in the rectangle will therefore be the multiplicative product of the X & Y elements of the divsPerAxis argument.
For example, a value of {5,5} for the divsPerAxis argument will result in the rectangle being divided into 25 faces, arranged into a 5x5 grid.
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this node to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh node may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
Declared In
CC3ParametricMeshNodes.h
populateAsCenteredRectangleWithSize:andTessellation:withTexture:invertTexture:
@deprecated Use the populateAsCenteredRectangleWithSize:andTessellation: method instead, and then use the texture property of this node to set the texture.
- (void)populateAsCenteredRectangleWithSize:(CGSize)rectSize andTessellation:(CC3Tessellation)divsPerAxis withTexture:(CC3Texture *)texture invertTexture:(BOOL)shouldInvert
Declared In
CC3ParametricMeshNodes.h
populateAsCenteredRectangleWithSize:withTexture:invertTexture:
@deprecated Use the populateAsCenteredRectangleWithSize: method instead, and then use the texture property of this node to set the texture.
- (void)populateAsCenteredRectangleWithSize:(CGSize)rectSize withTexture:(CC3Texture *)texture invertTexture:(BOOL)shouldInvert
Declared In
CC3ParametricMeshNodes.h
populateAsCenteredTexturedRectangleWithSize:
@deprecated Use populateAsCenteredRectangleWithSize:, as it creates a rectangular mesh that can be covered with either a texture or a solid color.
- (void)populateAsCenteredTexturedRectangleWithSize:(CGSize)rectSize
Declared In
CC3ParametricMeshNodes.h
populateAsCenteredTexturedRectangleWithSize:andTessellation:
@deprecated Use populateAsCenteredRectangleWithSize:andTessellation:, as it creates a rectangular mesh that can be covered with either a texture or a solid color.
- (void)populateAsCenteredTexturedRectangleWithSize:(CGSize)rectSize andTessellation:(CC3Tessellation)divsPerAxis
Declared In
CC3ParametricMeshNodes.h
populateAsCubeMappedSolidBox:
Populates this instance as a simple rectangular box mesh from the specified bounding box, which contains two of the diagonal corners of the box.
- (void)populateAsCubeMappedSolidBox:(CC3Box)box
Discussion
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this node to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh node may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
If a texture is to be wrapped around this mesh, since the single texture is wrapped around all six sides of the box, the texture will be mapped according to the layout illustrated in the texture file BoxTexture.png, included in the distribution.
The “front” of the box is the side that faces towards the positive-Z axis, the “top” of the box is the side that faces towards the positive-Y axis, and the “right” side of the box is the side that faces towards the positive-X axis.
For the purposes of wrapping the texture around the box, this method assumes that the texture is an unfolded cube. The box can be created with any relative dimensions, but if it is not a cube, the texture may appear stretched or shrunk on two or more sides. The texture will still fully wrap all six sides of the box, but the texture is stretched or shrunk to fit each side according to its dimension relative to the other sides. The appearance will be as if you had started with a textured cube and then pulled one or two of the dimensions out further.
For higher fidelity in applying textures to non-cube boxes, so that the texture will not be stretched to fit, use either of the populateAsSolidBox: or populateAsSolidBox:withCorner: methods, with a texture whose layout is compatible with the aspect ratio of the box.
Thanks to Cocos3D user andyman for contributing the prototype code and texture template file for this method.
Declared In
CC3ParametricMeshNodes.h
populateAsDiskWithRadius:andTessellation:
Populates this instance as a flat, single-sided circular disk mesh of the specified radius, centered at the origin, and laid out on the X-Y plane.
- (void)populateAsDiskWithRadius:(GLfloat)radius andTessellation:(CC3Tessellation)radialAndAngleDivs
Discussion
The surface of the disk is divided into many smaller divisions, both in the radial and angular dimensions.
The radialAndAngleDivs argument indicates how to divide the surface of the disks into divisions. The X element of the radialAndAngleDivs argument indicates how many radial divisions will occur from the center and the circuferential edge. A value of one means that the mesh will consist of a series of radial triangles from the center of the circle to the edge. A larger value for the X element of the radialAndAngleDivs argument will structure the mesh as a series of concentric rings. This value must be at least one.
The Y element of the radialAndAngleDivs argument indicates how many angular divisions will occur around the circumference. This value must be at least three, which will essentially render the circle as a triangle. But, typically, this value will be larger.
For example, a value of {4,24} for the radialAndAngleDivs argument will result in the disk being divided into four concentric rings, each divided into 24 segments around the circumference of the circle.
Each segement, except those in the innermost disk is trapezoidal, and will be constructed from two triangular mesh faces. Therefore, the number of triangles in the mesh will be (2X – 1) * Y, where X = radialAndAngleDivs.x and Y = radialAndAngleDivs.y.
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this node to set the texture. If a solid color is desired, leave the texture property unassigned.
The texture is mapped to the tessellated disk as if a tagential square was overlaid over the circle, starting from the lower left corner, where both X and Y are at a minimum. The center of the disk maps to the center of the texture.
The vertexContentType property of this mesh node may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
Declared In
CC3ParametricMeshNodes.h
populateAsHollowConeWithRadius:height:andTessellation:
Populates this instance as a conical mesh of the specified radius and height.
- (void)populateAsHollowConeWithRadius:(GLfloat)radius height:(GLfloat)height andTessellation:(CC3Tessellation)angleAndHeightDivs
Discussion
The mesh is constructed so that the base of the cone is centered on the origin of the X-Z plane, and the apex is on the positive Y-axis at the specified height. The cone is open and does not have a bottom.
The surface of the cone is divided into many smaller divisions, as specified by the angleAndHeightsDivs parameter. The X-coordinate of this parameter indicates how many angular divisions are created around the circumference of the base, and the Y-coordinate of this parameter indicates how many vertical divisions are created between the base and the apex.
For example, a value of {12,8} for the angleAndHeightsDivs parameter will result in a cone with 12 divisions around the circumference of the base, and 8 divisions along the Y-axis to the apex.
By reducing the number of angular divisions to 3 or 4, you can use this method to create a tetrahedron or square pyramid, respectively.
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this mesh to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
If a texture is applied to this mesh, it is mapped to the cone with a simple horizontal projection. Horizontal lines in the texture will remain parallel, but vertical lines will converge at the apex. Texture wrapping begins at the negative Z-axis, so the center of the texture will be positioned at the point where the cone intersects the positive Z-axis, and the conceptual seam (where the left and right edges of the texture are stitched together) will occur where the cone intersects the negative-Z axis. This texture orientation means that the center of the texture will face the forwardDirection of the cone node.
Declared In
CC3ParametricMeshNodes.h
populateAsLineStripWith:vertices:andRetain:
Populates this instance as a line strip with the specified number of vertex points. The data for the points that define the end-points of the lines are contained within the specified vertices array. The vertices array must contain at least vertexCount elements.
- (void)populateAsLineStripWith:(GLuint)vertexCount vertices:(CC3Vector *)vertices andRetain:(BOOL)shouldRetainVertices
Discussion
The lines are specified and rendered as a strip, where each line is connected to the previous and following lines. Each line starts at the point where the previous line ended, and that point is defined only once in the vertices array. Therefore, the number of lines drawn is equal to one less than the specified vertexCount.
The shouldRetainVertices flag indicates whether the data in the vertices array should be retained by this instance. If this flag is set to YES, the data in the vertices array will be copied to an internal array that is managed by this instance. If this flag is set to NO, the data is not copied internally and, instead, a reference to the vertices data is established. In this case, it is up to you to manage the lifespan of the data contained in the vertices array.
If you are defining the vertices data dynamically in another method, you may want to set this flag to YES to have this instance copy and manage the data. If the vertices array is a static array, you can set this flag to NO.
This is a convenience method for creating a simple, but useful, shape.
Declared In
CC3ParametricMeshNodes.h
populateAsRectangleWithSize:andPivot:
@deprecated Renamed to populateAsRectangleWithSize:andRelativeOrigin:.
- (void)populateAsRectangleWithSize:(CGSize)rectSize andPivot:(CGPoint)pivot
Declared In
CC3ParametricMeshNodes.h
populateAsRectangleWithSize:andPivot:andTessellation:
@deprecated Renamed to populateAsRectangleWithSize:andRelativeOrigin:andTessellation.
- (void)populateAsRectangleWithSize:(CGSize)rectSize andPivot:(CGPoint)pivot andTessellation:(CC3Tessellation)divsPerAxis
Declared In
CC3ParametricMeshNodes.h
populateAsRectangleWithSize:andPivot:andTessellation:withTexture:invertTexture:
@deprecated Use the populateAsCenteredRectangleWithSize:andRelativeOrigin:andTessellation: method instead, and then use the texture property of this node to set the texture.
- (void)populateAsRectangleWithSize:(CGSize)rectSize andPivot:(CGPoint)pivot andTessellation:(CC3Tessellation)divsPerAxis withTexture:(CC3Texture *)texture invertTexture:(BOOL)shouldInvert
Declared In
CC3ParametricMeshNodes.h
populateAsRectangleWithSize:andPivot:withTexture:invertTexture:
@deprecated Use the populateAsRectangleWithSize:andRelativeOrigin: method instead, and then use the texture property of this node to set the texture.
- (void)populateAsRectangleWithSize:(CGSize)rectSize andPivot:(CGPoint)pivot withTexture:(CC3Texture *)texture invertTexture:(BOOL)shouldInvert
Declared In
CC3ParametricMeshNodes.h
populateAsRectangleWithSize:andRelativeOrigin:
Populates this instance as a simple rectangular mesh of the specified size, with the specified relative origin, and laid out on the X-Y plane.
- (void)populateAsRectangleWithSize:(CGSize)rectSize andRelativeOrigin:(CGPoint)origin
Discussion
The rectangular mesh contains only one face with two triangles. The result is the same as invoking the populateAsRectangleWithSize:andRelativeOrigin:andTessellation: with the divsPerAxis argument set to {1,1}.
The relative origin is a fractional point that is relative to the rectangle’s extent, and indicates where the origin of the rectangular mesh is to be located. The mesh origin is the origin of the local coordinate system of the mesh, and is the basis for all transforms applied to the mesh (including the location and rotation properties).
The specified relative origin should be a fractional value. If it is {0, 0}, the rectangle will be laid out so that the bottom-left corner is at the origin. If it is {1, 1}, the rectangle will be laid out so that the top-right corner of the rectangle is at the origin. If it is {0.5, 0.5}, the rectangle will be laid out with the origin at the center, as in the populateAsCenteredRectangleWithSize: method.
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this mesh to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate), and the mesh will be populated with location, normal and texture coordinates for each vertex.
Declared In
CC3ParametricMeshNodes.h
populateAsRectangleWithSize:andRelativeOrigin:andTessellation:
Populates this instance as a simple rectangular mesh of the specified size, with the specified relative origin, and laid out on the X-Y plane.
- (void)populateAsRectangleWithSize:(CGSize)rectSize andRelativeOrigin:(CGPoint)origin andTessellation:(CC3Tessellation)divsPerAxis
Discussion
The large rectangle can be divided into many smaller divisions. Building a rectanglular surface from more than one division can dramatically improve realism when the surface is illuminated with specular lighting or a tightly focused spotlight, because increasing the face count increases the number of vertices that interact with the specular or spot lighting.
The divsPerAxis argument indicates how to break this large rectangle into multiple faces. The X & Y elements of the divsPerAxis argument indicate how each axis if the rectangle should be divided into faces. The total number of faces in the rectangle will therefore be the multiplicative product of the X & Y elements of the divsPerAxis argument.
For example, a value of {5,5} for the divsPerAxis argument will result in the rectangle being divided into 25 faces, arranged into a 5x5 grid.
The relative origin is a fractional point that is relative to the rectangle’s extent, and indicates where the origin of the rectangular mesh is to be located. The mesh origin is the origin of the local coordinate system of the mesh, and is the basis for all transforms applied to the mesh (including the location and rotation properties).
The specified relative origin should be a fractional value. If it is {0, 0}, the rectangle will be laid out so that the bottom-left corner is at the origin. If it is {1, 1}, the rectangle will be laid out so that the top-right corner of the rectangle is at the origin. If it is {0.5, 0.5}, the rectangle will be laid out with the origin at the center, as in the populateAsCenteredRectangleWithSize: method.
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this mesh to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate), and the mesh will be populated with location, normal and texture coordinates for each vertex.
Declared In
CC3ParametricMeshNodes.h
populateAsSolidBox:
Populates this instance as a simple rectangular box mesh from the specified bounding box, which contains two of the diagonal corners of the box.
- (void)populateAsSolidBox:(CC3Box)box
Discussion
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this node to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh node may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
If a texture is to be wrapped around this mesh, since the single texture is wrapped around all six sides of the box, the texture will be mapped according to the layout illustrated in the texture file BoxTexture.png, included in the distribution.
The “front” of the box is the side that faces towards the positive-Z axis, the “top” of the box is the side that faces towards the positive-Y axis, and the “right” side of the box is the side that faces towards the positive-X axis.
For the purposes of wrapping a texture around the box, the texture will wrap uniformly around all sides, and the texture will not appear stretched between any two adjacent sides. This is useful when you are texturing the box with a simple rectangular repeating pattern and want the texture to appear consistent across the sides, for example, a brick pattern wrapping around all four sides of a house.
Depending on the relative aspect of the height and width of the box, the texture may appear distorted horizontal or vertically. If you need to correct that, you can use the repeatTexture: method, and adjust one of the dimensions.
For higher fidelity in applying textures to non-cube boxes, so that the texture will not be stretched to fit, use the populateAsSolidBox:withCorner: method.
Thanks to Cocos3D user andyman for contributing the prototype code and texture template file for this method.
Declared In
CC3ParametricMeshNodes.h
populateAsSolidBox:withCorner:
Populates this instance as a simple rectangular box mesh from the specified bounding box, which contains two of the diagonal corners of the box, and configures the mesh texture coordinates so that the entire box can be wrapped in a single texture.
- (void)populateAsSolidBox:(CC3Box)box withCorner:(CGPoint)corner
Discussion
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this node to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh node may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
If a texture is to be wrapped around this mesh, since the single texture is wrapped around all six sides of the box, the texture will be mapped according to the layout illustrated in the texture file BoxTexture.png, included in the distribution.
The “front” of the box is the side that faces towards the positive-Z axis, the “top” of the box is the side that faces towards the positive-Y axis, and the “right” side of the box is the side that faces towards the positive-X axis.
For the purposes of wrapping the texture around the box, the corner argument specifies the relative point in the texture that will map to the corner of the box that is at the juncture of the “left”, “front” and “bottom” sides (see the BoxTexture.png image for a better understanding of this point). The corner argument is specified as a fraction in each of the S & T dimensions of the texture. In the CGPoint that specifies the corner, the x & y elements of the CGPoint correspond to the S & T dimensions of this left-front-bottom corner mapping, with each value being between zero and one.
Since, by definition, opposite sides of the box have the same dimensions, this single corner point identifies the S & T dimensions of all six of the sides of the box. A value of (¼, 1/3) for the corner is used when the box is a cube. A smaller value for the x-element would move the corner to the left in the texture layout, indicating that the left and right sides are shallower than they are in a cube, and that the front and back are wider than in a cube, and vice-versa for a larger value in the x-element of the corner. Similarly for the y-element. A y-element that is smaller than 1/3, moves the corner point downwards on the texture, indicating that the bottom and top are shallower than they are in a cube, or that the front and back are higher than they are in a cube.
The two axes defined by the corner are interrelated, because the sides need to be the same depth as the top and bottom. The best way to determine the values to use in the corner is to use the measure of this point (where the “left”, “front”, and “bottom” sides meet) from the layout of the texture. If the aspect of the corner on the texture does not align with the aspect of the width, height and depth of the box, the texture will appear stretched on one or two sides relative to the others.
Thanks to Cocos3D user andyman for contributing the prototype code and texture template file for this method.
Declared In
CC3ParametricMeshNodes.h
populateAsSphereWithRadius:andTessellation:
Populates this instance as a spherical mesh of the specified radius, centered at the origin.
- (void)populateAsSphereWithRadius:(GLfloat)radius andTessellation:(CC3Tessellation)divsPerAxis
Discussion
The surface of the sphere is divided into many smaller divisions, similar to latitude and longtitude divisions. The sphere mesh contains two poles, where the surface intersects the positive and negative Y-axis.
The divsPerAxis argument indicates how to divide the surface of the sphere into divisions. The X element of the divsPerAxis argument indicates how many longtitude divisions will occur around one circumnavigation of the equator. The Y element of the divsPerAxis argument indicates how many latitude divisions will occur between the north pole and the south pole.
For example, a value of {12,8} for the divsPerAxis argument will result in the sphere being divided into twelve divisions of longtitude around the equator, and eight divisions of latitude between the north and south poles.
Except at the poles, each division is roughly trapezoidal and is drawn as two triangles. At the poles, each division is a single triangle.
This mesh can be covered with a solid material or a single texture. If this mesh is to be covered with a texture, use the texture property of this node to set the texture. If a solid color is desired, leave the texture property unassigned.
The vertexContentType property of this mesh node may be set prior to invoking this method, to define the content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and kCC3VertexContentTextureCoordinate are populated by this method.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
If a texture is applied to this mesh, it is mapped to the sphere with a simple cylindrical projection around the equator (similar to Mercator projection without the north-south stretching). This type of projection is typical of maps of the earth taken from space, and results in the smooth curving of any texture around the sphere from the equator to the poles. Texture wrapping begins at the negative Z-axis, so the center of the texture will be positioned at the point where the sphere intersects the positive Z-axis, and the conceptual seam (where the left and right edges of the texture are stitched together) will occur where the sphere intersects the plane (X = 0) along the negative-Z axis. This texture orientation means that the center of the texture will face the forwardDirection of the sphere node.
The boundingVolume of this node is automatically set to a spherical shape (an instance of CC3NodeSphericalBoundingVolume) to match the shape of this mesh.
Declared In
CC3ParametricMeshNodes.h
populateAsTexturedBox:
@deprecated Use populateAsSolidBox:, as it creates a box mesh that can be covered with either a texture or a solid color.
- (void)populateAsTexturedBox:(CC3Box)box
Declared In
CC3ParametricMeshNodes.h
populateAsTexturedBox:withCorner:
@deprecated Renamed to populateAsSolidBox:withCorner:.
- (void)populateAsTexturedBox:(CC3Box)box withCorner:(CGPoint)corner
Declared In
CC3ParametricMeshNodes.h
populateAsTexturedRectangleWithSize:andPivot:
@deprecated Use populateAsRectangleWithSize:andRelativeOrigin:, as it creates a rectangular mesh that can be covered with either a texture or a solid color.
- (void)populateAsTexturedRectangleWithSize:(CGSize)rectSize andPivot:(CGPoint)pivot
Declared In
CC3ParametricMeshNodes.h
populateAsTexturedRectangleWithSize:andPivot:andTessellation:
@deprecated Use populateAsRectangleWithSize:andRelativeOrigin:andTessellation:, as it creates a rectangular mesh that can be covered with either a texture or a solid color.
- (void)populateAsTexturedRectangleWithSize:(CGSize)rectSize andPivot:(CGPoint)pivot andTessellation:(CC3Tessellation)divsPerAxis
Declared In
CC3ParametricMeshNodes.h
populateAsTriangle:withTexCoords:andTessellation:
- Populates this instance as a simple triangular mesh. *
- The specified face defines the three vertices at the corners of the triangular mesh in 3D space.
- The vertices within the CC3Face structure are specified in the winding order of the triangular
- face. The winding order of the specified face determines the winding order of the vertices in
- the mesh, and the direction of the normal vector applied to each of the vertices. Since the
- resulting triangular mesh is flat, all vertices will have the same normal vector.
- (void)populateAsTriangle:(CC3Face)face withTexCoords:(ccTex2F *)texCoords andTessellation:(GLuint)divsPerSide
Discussion
- Although the triangle can be created with the corners can be anywhere in 3D space, for
- simplicity of construction, it is common practice, when using this method, to specify the
- mesh in the X-Y plane (where all three corners have a zero Z-component), and then rotate
- this node to an orientation in 3D space. *
- The texCoords parameter is an array of ccTex2F structures, providing the texture coordinates for
- the cooresponding vertices of the face. This array must have three elements, one for each vertex
- in the specified face. If the mesh will not be covered with a texture, you can pass in any values
- in the elements of this array. *
- The tessellation property determines how the mesh will be tessellated into smaller faces. The
- specified tessellation value indicates how many divisions each side of the main triangle should
- be divided into. Each side of the triangular mesh is tessellated into the same number of divisions. *
- This mesh can be covered with a solid material or a single texture. If this mesh is to be covered
- with a texture, use the texture property of this mesh to set the texture. If a solid color is
- desired, leave the texture property unassigned. *
- The vertexContentType property of this mesh may be set prior to invoking this method, to define the
- content type for each vertex. Content types kCC3VertexContentLocation, kCC3VertexContentNormal, and
- kCC3VertexContentTextureCoordinate are populated by this method. *
- If the vertexContentType property has not already been set, that property is set to a value of
- (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate), and
- the mesh will be populated with location, normal and texture coordinates for each vertex.
Declared In
CC3ParametricMeshNodes.h
populateAsWireBox:
Populates this instance as a wire-frame box with the specified dimensions.
- (void)populateAsWireBox:(CC3Box)box
Discussion
As this node is translated, rotate and scaled, the wire-frame box will be re-oriented in 3D space.
This is a convenience method for creating a simple, but useful, shape.
Declared In
CC3ParametricMeshNodes.h
prepareParametricMesh
Ensures that the contained mesh has been created and has vertexContentType defined.
- (CC3Mesh *)prepareParametricMesh
Discussion
This method is invoked by each of the populateAs… family of methods, prior to populating the mesh contents.
The vertexContentType property of this mesh node may be set prior to invoking any of the populateAs… family of methods, to define the content type for each vertex.
If the vertexContentType property has not already been set, that property is set to a value of (kCC3VertexContentLocation | kCC3VertexContentNormal | kCC3VertexContentTextureCoordinate). and the mesh will be populated with location, normal and texture coordinates for each vertex.
If you do not need either of the normal or texture coordinates, set the vertexContentTypes property accordingly prior to invoking any of the populateAs… methods.
Declared In
CC3ParametricMeshNodes.h
removeAllTextures
Removes all textures from the material covering this mesh.
- (void)removeAllTextures
Declared In
CC3MeshNode.h
removeLocalShaders
Removes the shaders from this mesh node, allowing new shaders to be selected, either directly by subsequently invoking the selectShaderProgram method, or automatically the next time this mesh node is drawn.
- (void)removeLocalShaders
Discussion
Shader selection is driven by the characteristics of the mesh node and its material, including the number of textures, whether alpha testing is used, etc. If you change any of these characteristics that affect the shader selection, you can invoke the removeLocalShaders method to cause a different shader program to be selected, based on the new mesh node and material characteristics.
This method is equivalent to setting the shaderProgram property to nil.
This method differs from the removeShaders method in that this method does not propagate to any descendant nodes.
Declared In
CC3MeshNode.h
repeatTexture:
Configures the mesh so that the textures in all texture units will be repeated the specified number of times across the mesh, in each dimension. The repeatFactor argument contains two numbers, corresponding to how many times in each dimension the texture should be repeated.
- (void)repeatTexture:(ccTex2F)repeatFactor
Discussion
This has the same effect as invoking the repeatTexture:forTextureUnit: method for each texture unit.
Declared In
CC3MeshNode.h
repeatTexture:forTextureUnit:
Configures the mesh so that a texture applied to the specified texture unit will be repeated the specified number of times across the mesh, in each dimension. The repeatFactor argument contains two numbers, corresponding to how many times in each dimension the texture should be repeated.
- (void)repeatTexture:(ccTex2F)repeatFactor forTextureUnit:(GLuint)texUnit
Discussion
As an example, a value of (1, 2) for the repeatValue indicates that the texture should repeat twice vertically, but not repeat horizontally.
When a texture is repeated, the corresponding side of the texture covering this mesh must have a length that is a power-of-two, otherwise the padding added by iOS to convert it to a power-of-two length internally will be visible in the repeating pattern across the mesh.
For a side that is not repeating, the corresponding side of the texture covering this mesh does not require a length that is a power-of-two.
The textureParameters property of any texture covering this mesh should include the GL_REPEAT setting in each of its texture wrap components that correspond to a repeatFactor greater than one. The GL_REPEAT setting is the default setting for CC3Texture.
For example, if you want to repeat your texture twice in one dimension, but only once in the other, then you would use a repeatFactor of (1, 2) or (2, 1). For the side that is repeating twice, the length of that side of the texture must be a power-of-two. But the other side may have any dimension. The textureParameters property of the CC3Texture should include the GL_REPEAT setting for the corresponding texture dimension.
You can specify a fractional value for either of the components of the repeatFactor to expand the texture in that dimension so that only part of the texture appears in that dimension, while potentially repeating multiple times in the other dimension.
Declared In
CC3MeshNode.h
selectShaderProgram
Selects an appropriate shader program for this mesh node, and returns that shader program.
- (CC3ShaderProgram *)selectShaderProgram
Discussion
When running under a programmable rendering pipeline, such as OpenGL ES 2.0 or OpenGL, all mesh nodes require shaders to be assigned. This can be done directly using the shaderProgram property. Or a shader program can be selected automatically based on the characteristics of the mesh node by invoking this method.
Since all mesh nodes require shaders, if this method is not invoked, and a shader program was not manually assigned via the shaderProgram property, a shaders will be automatically assigned to each mesh node the first time it is rendered. The automatic selection is the same, whether this method is invoked, or the selection is made lazily. However, if the shaders must be loaded and compiled, there can be a noticable pause in drawing a mesh node for the first time if lazy assignment is used.
Shader selection is driven by the characteristics of the mesh node and its material, including the number of textures, whether alpha testing is used, etc. If you change any of these characteristics that affect the shader selection, you can invoke the removeLocalShaders method to cause a different shader program to be selected, based on the new mesh node and material characteristics.
Shader selection is handled by an implementation of the CC3ShaderMatcher held in the CC3ShaderProgram shaderMatcher class-side property. The application can therefore customize shader program selection by establishing a custom instance in the CC3ShaderProgram shaderMatcher class-side property
This method differs from the selectShaders method in that this method does not propagate to any descendant nodes.
Declared In
CC3MeshNode.h
setTexture:forTextureUnit:
Sets the texture that will be processed by the texture unit with the specified index, which should be a number between zero, and the value of the textureCount property.
- (void)setTexture:(CC3Texture *)aTexture forTextureUnit:(GLuint)texUnit
Discussion
If the specified index is less than the number of texture units added already, the specified texture will replace the one assigned to that texture unit. Otherwise, this implementation will invoke the addTexture: method to add the texture to this material.
If the specified texture unit index is zero, the value of the texture property will be changed to the specified texture.
If a material does not yet exist in this mesh node, a new material will be created and the texture will be attached to it.
Under iOS, during loading, textures are padded to dimensions of a power-of-two (POT) and, because vertical OpenGL coordinates are inverted relative to iOS view coordinates, most texture formats are loaded updside-down.
To compensate, when a texture is attached to a mesh node, the texture coordinates of the mesh are automatically adjusted to correctly display the texture, taking into consideration POT padding and vertical orientation.
Declared In
CC3MeshNode.h
setTextureRectangle:forTextureUnit:
Sets the textureRectangle property from the texture coordinates that are mapping the specified texture unit index.
- (void)setTextureRectangle:(CGRect)aRect forTextureUnit:(GLuint)texUnit
Discussion
See the notes for the textureRectangle property of this class for an explanation of the use of this property.
Declared In
CC3MeshNode.h
setVertexBitangent:at:
Sets the bitangent element at the specified index in the vertex content to the specified value.
- (void)setVertexBitangent:(CC3Vector)aTangent at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
When all vertex changes have been made, be sure to invoke the updateVertexNormalsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexBoneIndex:forBoneInfluence:at:
Sets the index of the bone, that provides the influence at the specified influence index within a vertex, for the vertex at the specified index within the underlying vertex content.
- (void)setVertexBoneIndex:(GLuint)boneIndex forBoneInfluence:(GLuint)influenceIndex at:(GLuint)vtxIndex
Discussion
The bone index indicates which bone provides the particular influence for the movement of the particular vertex. Several bone indices are stored for each vertex, one for each bone that influences the movement of that vertex. The specified influenceIndex parameter must be between zero, and the vertexBoneCount property (inclusive/exclusive respectively).
The vertex index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
When all vertex changes have been made, be sure to invoke the updateVertexBoneIndicesGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexBoneIndices:at:
Sets the indices of all of the bones that influence the movement of the vertex at the specified index within the underlying vertex content.
- (void)setVertexBoneIndices:(GLvoid *)boneIndices at:(GLuint)vtxIndex
Discussion
Several indices are stored for each vertex, one for each bone that influences the movement of the vertex. The number of elements in the specified input array must therefore be at least as large as the value of the vertexBoneCount property.
The bone indices can be stored in each vertx as either type GLushort or type GLubyte. The specified array must be of the type of index stored by the verties in this mesh, and it is up to the application to know which type is required, and provide that type of array accordingly. The type can be determined by the vertexBoneIndexType property of this mesh, which will return one of GL_UNSIGNED_SHORT or GL_UNSIGNED_BYTE, respectively.
To avoid checking the elementType altogether, you can use the setVertxBoneIndex:forBoneInfluence:at: method, which sets the bone index values one at a time, and automatically converts the input type to the correct stored type.
The vertex index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
When all vertex changes have been made, be sure to invoke the updateVertexBoneIndicesGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexBoneWeights:at:
Sets the weights of all of the bones that influence the movement of the vertex at the specified index within the underlying vertex content.
- (void)setVertexBoneWeights:(GLfloat *)weights at:(GLuint)vtxIndex
Discussion
Several weights are stored for each vertex, one for each bone that influences the movement of the vertex. The number of elements in the specified input array must therefore be at least as large as the value of the vertexBoneCount property.
The vertex index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
When all vertex changes have been made, be sure to invoke the updateVertexBoneWeightsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexColor4B:at:
Sets the color element at the specified index in the vertex content to the specified value.
- (void)setVertexColor4B:(ccColor4B)aColor at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the shouldApplyOpacityToColor property of this node returns YES, each of the red, green and blue components of the specified color will be multiplied by the alpha component of the specified color before the color is set into the vertex. This occurs when the texture attached to this mesh contains pre-multiplied alpha. When this occurs, the value retrieved using the vertexColor4F: method will not be the same as the value set with this method, if the color contained an alpha value less than 255. See the notes of the shouldApplyOpacityToColor property for more on using pre-multiplied alpha.
When all vertex changes have been made, be sure to invoke the updateVertexColorsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexColor4F:at:
Sets the color element at the specified index in the vertex content to the specified value.
- (void)setVertexColor4F:(ccColor4F)aColor at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the shouldApplyOpacityToColor property of this node returns YES, each of the red, green and blue components of the specified color will be multiplied by the alpha component of the specified color before the color is set into the vertex. This occurs when the texture attached to this mesh contains pre-multiplied alpha. When this occurs, the value retrieved using the vertexColor4F: method will not be the same as the value set with this method, if the color contained an alpha value less than one. See the notes of the shouldApplyOpacityToColor property for more on using pre-multiplied alpha.
When all vertex changes have been made, be sure to invoke the updateVertexColorsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexHomogeneousLocation:at:
Sets the location element at the specified index in the underlying vertex content to the specified four-dimensional location in the 4D homogeneous coordinate space.
- (void)setVertexHomogeneousLocation:(CC3Vector4)aLocation at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
This implementation takes into consideration the dimensionality of the underlying data. If the dimensionality is 3, the W component of the specified vector will be ignored. If the dimensionality is 2, both the W and Z components of the specified vector will be ignored.
When all vertex changes have been made, be sure to invoke the updateVertexLocationsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
This method automatically invokes the markBoundingVolumeDirty method, to ensure that the boundingVolume encompasses the new vertex locations.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexIndex:at:
Sets the index element at the specified index in the vertex content to the specified value.
- (void)setVertexIndex:(GLuint)vertexIndex at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
When all vertex changes have been made, be sure to invoke the updateVertexIndicesGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexLocation:at:
Sets the location element at the specified index in the vertex content to the specified value.
- (void)setVertexLocation:(CC3Vector)aLocation at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
This implementation takes into consideration the dimensionality of the underlying vertex content. If the dimensionality is 2, the Z component of the specified vector will be ignored. If the dimensionality is 4, the specified vector will be converted to a 4D vector, with the W component set to one, before storing.
When all vertex changes have been made, be sure to invoke the updateVertexLocationsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
This method automatically invokes the markBoundingVolumeDirty method, to ensure that the boundingVolume encompasses the new vertex locations.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexMatrixIndex:forVertexUnit:at:
*@deprecated Renamed to setVertexBoneIndex:forBoneInfluence:at:.
- (void)setVertexMatrixIndex:(GLuint)aMatrixIndex forVertexUnit:(GLuint)vertexUnit at:(GLuint)index
Declared In
CC3MeshNode.h
setVertexMatrixIndices:at:
*@deprecated Renamed to setVertexBoneIndices:at:.
- (void)setVertexMatrixIndices:(GLvoid *)mtxIndices at:(GLuint)index
Declared In
CC3MeshNode.h
setVertexNormal:at:
Sets the normal element at the specified index in the vertex content to the specified value.
- (void)setVertexNormal:(CC3Vector)aNormal at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
When all vertex changes have been made, be sure to invoke the updateVertexNormalsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexTangent:at:
Sets the tangent element at the specified index in the vertex content to the specified value.
- (void)setVertexTangent:(CC3Vector)aTangent at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
When all vertex changes have been made, be sure to invoke the updateVertexNormalsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexTexCoord2F:at:
Sets the texture coordinate element at the specified index in the vertex content, at the commonly used texture unit zero, to the specified texture coordinate value.
- (void)setVertexTexCoord2F:(ccTex2F)aTex2F at:(GLuint)index
Discussion
This is a convenience method that delegates to the setVertexTexCoord2F:forTextureUnit:at: method, passing in zero for the texture unit index.
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
When all vertex changes have been made, be sure to invoke the updateVertexTextureCoordinatesGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexTexCoord2F:at:forTextureUnit:
@deprecated Use the setVertexTexCoord2F:forTextureUnit:at: method instead,
- (void)setVertexTexCoord2F:(ccTex2F)aTex2F at:(GLuint)index forTextureUnit:(GLuint)texUnit
Declared In
CC3MeshNode.h
setVertexTexCoord2F:forTextureUnit:at:
Sets the texture coordinate element at the specified index in the vertex content, at the specified texture unit index, to the specified texture coordinate value.
- (void)setVertexTexCoord2F:(ccTex2F)aTex2F forTextureUnit:(GLuint)texUnit at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
When all vertex changes have been made, be sure to invoke the updateVertexTextureCoordinatesGLBufferForTextureUnit: method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexWeight:forBoneInfluence:at:
Sets the weight value, for the specified influence index within the vertex, for the vertex at the specified index within the underlying vertex content.
- (void)setVertexWeight:(GLfloat)weight forBoneInfluence:(GLuint)influenceIndex at:(GLuint)vtxIndex
Discussion
The weight indicates how much a particular bone influences the movement of the particular vertex. Several weights are stored for each vertex, one for each bone that influences the movement of that vertex. The specified influenceIndex parameter must be between zero, and the vertexBoneCount property (inclusive/exclusive respectively).
The vertex index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
When all vertex changes have been made, be sure to invoke the updateVertexBoneWeightsGLBuffer method to ensure that the GL VBO that holds the vertex content is updated.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
setVertexWeight:forVertexUnit:at:
*@deprecated Renamed to setVertexWeight:forBoneInfluence:at:.
- (void)setVertexWeight:(GLfloat)aWeight forVertexUnit:(GLuint)vertexUnit at:(GLuint)index
Declared In
CC3MeshNode.h
setVertexWeights:at:
*@deprecated Renamed to setVertexBoneWeights:at:.
- (void)setVertexWeights:(GLfloat *)weights at:(GLuint)index
Declared In
CC3MeshNode.h
textureForTextureUnit:
Returns the texture that will be processed by the texture unit with the specified index, which should be a number between zero, and one less than the value of the textureCount property.
- (CC3Texture *)textureForTextureUnit:(GLuint)texUnit
Discussion
The value returned will be nil if this node has no material, or if that material has no textures.
This method is a convenience. It simply delegates to the same method on the material covering this mesh node, creating the material first, if needed.
Declared In
CC3MeshNode.h
textureRectangleForTextureUnit:
Returns the textureRectangle property from the texture coordinates that are mapping the specified texture unit index.
- (CGRect)textureRectangleForTextureUnit:(GLuint)texUnit
Discussion
See the notes for the textureRectangle property of this class for an explanation of the use of this property.
Declared In
CC3MeshNode.h
updateGLBuffers
Convenience method to update the GL engine buffers with the vertex content in this mesh.
- (void)updateGLBuffers
Discussion
This updates the content of each vertex. It does not update the vertex indices. To update the vertex index data to the GL engine, use the updateVertexIndicesGLBuffer method.
Declared In
CC3MeshNode.h
updateVertexBitangentsGLBuffer
Updates the GL engine buffer with the vertex tangent content in this mesh.
- (void)updateVertexBitangentsGLBuffer
Declared In
CC3MeshNode.h
updateVertexBoneIndicesGLBuffer
Updates the GL engine buffer with the vertex bone indices content in this mesh.
- (void)updateVertexBoneIndicesGLBuffer
Declared In
CC3MeshNode.h
updateVertexBoneWeightsGLBuffer
Updates the GL engine buffer with the vertex bone weight content in this mesh.
- (void)updateVertexBoneWeightsGLBuffer
Declared In
CC3MeshNode.h
updateVertexColorsGLBuffer
Updates the GL engine buffer with the vertex color content in this mesh.
- (void)updateVertexColorsGLBuffer
Declared In
CC3MeshNode.h
updateVertexIndicesGLBuffer
Updates the GL engine buffer with the vertex index content in this mesh.
- (void)updateVertexIndicesGLBuffer
Declared In
CC3MeshNode.h
updateVertexLocationsGLBuffer
Updates the GL engine buffer with the vertex location content in this mesh.
- (void)updateVertexLocationsGLBuffer
Declared In
CC3MeshNode.h
updateVertexMatrixIndicesGLBuffer
*@deprecated Renamed to updateVertexBoneIndicesGLBuffer.
- (void)updateVertexMatrixIndicesGLBuffer
Declared In
CC3MeshNode.h
updateVertexNormalsGLBuffer
Updates the GL engine buffer with the vertex normal content in this mesh.
- (void)updateVertexNormalsGLBuffer
Declared In
CC3MeshNode.h
updateVertexTangentsGLBuffer
Updates the GL engine buffer with the vertex tangent content in this mesh.
- (void)updateVertexTangentsGLBuffer
Declared In
CC3MeshNode.h
updateVertexTextureCoordinatesGLBuffer
Updates the GL engine buffer with the vertex texture coord content from texture unit zero in this mesh.
- (void)updateVertexTextureCoordinatesGLBuffer
Declared In
CC3MeshNode.h
updateVertexTextureCoordinatesGLBufferForTextureUnit:
Updates the GL engine buffer with the vertex texture coord content from the specified texture unit in this mesh.
- (void)updateVertexTextureCoordinatesGLBufferForTextureUnit:(GLuint)texUnit
Declared In
CC3MeshNode.h
updateVertexWeightsGLBuffer
*@deprecated Renamed to updateVertexBoneWeightsGLBuffer.
- (void)updateVertexWeightsGLBuffer
Declared In
CC3MeshNode.h
vertexBitangentAt:
Returns the tangent element at the specified index from the vertex content.
- (CC3Vector)vertexBitangentAt:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexBoneIndexForBoneInfluence:at:
Returns the index of the bone, that provides the influence at the specified influence index within a vertex, for the vertex at the specified index within the underlying vertex content.
- (GLuint)vertexBoneIndexForBoneInfluence:(GLuint)influenceIndex at:(GLuint)vtxIndex
Discussion
The bone index indicates which bone provides the particular influence for the movement of the particular vertex. Several bone indices are stored for each vertex, one for each bone that influences the movement of that vertex. The specified influenceIndex parameter must be between zero, and the vertexBoneCount property (inclusive/exclusive respectively).
The vertex index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexBoneIndicesAt:
Returns the indices of all of the bones that influence the movement of the vertex at the specified index within the underlying vertex content.
- (GLvoid *)vertexBoneIndicesAt:(GLuint)vtxIndex
Discussion
Several indices are stored for each vertex, one for each bone that influences the movement of the vertex. The number of elements in the returned array is the same for each vertex in this vertex array, as defined by the vertexBoneCount property.
The bone indices can be stored in each vertex as either type GLushort or type GLubyte. The returned array will be of the type of index stored by the verties in this mesh, and it is up to the application to know which type will be returned, and cast the returned array accordingly. The type can be determined by the vertexBoneIndexType property of this mesh, which will return one of GL_UNSIGNED_SHORT or GL_UNSIGNED_BYTE, respectively.
The vertex index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexBoneWeightsAt:
Returns the weights of all of the bones that influence the movement of the vertex at the specified index within the underlying vertex content.
- (GLfloat *)vertexBoneWeightsAt:(GLuint)vtxIndex
Discussion
Several weights are stored for each vertex, one for each bone that influences the movement of the vertex. The number of elements in the returned array is the same for each vertex in this vertex array, as defined by the vertexBoneCount property.
The vertex index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexColor4BAt:
Returns the color element at the specified index from the vertex content.
- (ccColor4B)vertexColor4BAt:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexColor4FAt:
Returns the color element at the specified index from the vertex content.
- (ccColor4F)vertexColor4FAt:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexCountFromFaceCount:
@deprecated Renamed to vertexIndexCountFromFaceCount:.
- (GLuint)vertexCountFromFaceCount:(GLuint)fc
Declared In
CC3MeshNode.h
vertexHomogeneousLocationAt:
Returns the location element at the specified index in the underlying vertex content, as a four-dimensional location in the 4D homogeneous coordinate space.
- (CC3Vector4)vertexHomogeneousLocationAt:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
This implementation takes into consideration the elementSize property. If the value of the elementSize property is 3, the returned vector will contain one in the W component. If the value of the elementSize property is 2, the returned vector will contain zero in the Z component and one in the W component.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexIndexAt:
Returns the index element at the specified index from the vertex content.
- (GLuint)vertexIndexAt:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexIndexCountFromFaceCount:
Returns the number of vertex indices required to draw the specified number of faces, based on the type of primitives that this mesh is drawing.
- (GLuint)vertexIndexCountFromFaceCount:(GLuint)fc
Declared In
CC3MeshNode.h
vertexLocationAt:
Returns the location element at the specified index from the vertex content.
- (CC3Vector)vertexLocationAt:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
This implementation takes into consideration the dimensionality of the underlying vertex content. If the dimensionality is 2, the returned vector will contain zero in the Z component.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexMatrixIndexForVertexUnit:at:
*@deprecated Renamed to vertexBoneIndexForBoneInfluence:at:.
- (GLuint)vertexMatrixIndexForVertexUnit:(GLuint)vertexUnit at:(GLuint)index
Declared In
CC3MeshNode.h
vertexMatrixIndicesAt:
*@deprecated Renamed to vertexBoneIndicesAt:.
- (GLvoid *)vertexMatrixIndicesAt:(GLuint)index
Declared In
CC3MeshNode.h
vertexNormalAt:
Returns the normal element at the specified index from the vertex content.
- (CC3Vector)vertexNormalAt:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexTangentAt:
Returns the tangent element at the specified index from the vertex content.
- (CC3Vector)vertexTangentAt:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexTexCoord2FAt:
Returns the texture coordinate element at the specified index from the vertex content at the commonly used texture unit zero.
- (ccTex2F)vertexTexCoord2FAt:(GLuint)index
Discussion
This is a convenience method that is equivalent to invoking the vertexTexCoord2FForTextureUnit:at: method, with zero as the texture unit index.
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexTexCoord2FAt:forTextureUnit:
@deprecated Use the vertexTexCoord2FForTextureUnit:at: method instead,
- (ccTex2F)vertexTexCoord2FAt:(GLuint)index forTextureUnit:(GLuint)texUnit
Declared In
CC3MeshNode.h
vertexTexCoord2FForTextureUnit:at:
Returns the texture coordinate element at the specified index from the vertex content at the specified texture unit index.
- (ccTex2F)vertexTexCoord2FForTextureUnit:(GLuint)texUnit at:(GLuint)index
Discussion
The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h
vertexWeightForBoneInfluence:at:
Returns the weight value, for the specified influence index within the vertex, for the vertex at the specified index within the underlying vertex content.
- (GLfloat)vertexWeightForBoneInfluence:(GLuint)influenceIndex at:(GLuint)vtxIndex
Discussion
The weight indicates how much a particular bone influences the movement of the particular vertex. Several weights are stored for each vertex, one for each bone that influences the movement of that vertex. The specified influenceIndex parameter must be between zero, and the vertexBoneCount property (inclusive/exclusive respectively).
The vertex index refers to vertices, not bytes. The implementation takes into consideration whether the vertex content is interleaved to access the correct vertex content component.
If the releaseRedundantContent method has been invoked and the underlying vertex content has been released, this method will raise an assertion exception.
Declared In
CC3MeshNode.h