User Guide
427
newMesh
Syntax
member(whichCastmember).newMesh(name,numFaces, numVertices,
numNormals,numColors,numTextureCoordinates)
Description
3D command; creates a new mesh model resource using the arguments supplied. Note that after
creating a mesh, you must set values for at least the vertexList and face[index].vertices
properties of the new mesh, followed by a call to its
build() command, in order to actually
generate the geometry.
The parameters of
newMesh are as follows:
• numFaces is the desired total number of triangles you want in the mesh.
• numVertices is the total number of vertices used by all the (triangular) faces. A vertex may be
shared by more than one face.
• numNormals is the optional total number of normals. A normal may be shared by more than
one face. The normal for a corner of a triangle defines which direction is outward, affecting
how that corner is illuminated by lights. Enter 0 or omit this argument if you are going to use
the mesh’s
generateNormals() command to generate normals.
• numColors is the optional total number of colors used by all the faces. A color may be shared
by more than one face. You can specify a color for each corner of each face. Specify colors for
smooth color gradation effects. Enter 0 or omit this argument to get default white color per
face corner.
• numTextureCoordinates is the optional number of user-specified texture coordinates used by
all the faces. Enter 0 or omit this argument to get the default texture coordinates generated via
a planar mapping. (See the explanation of
#planar in the shader.textureWrapMode entry for
more details). Specify texture coordinates when you need precise control over how textures are
mapped onto the faces of the mesh.
Example
This example creates a model resource of the type #mesh, specifies its properties, and then creates
a new model from the model resource. The process is outlined in the following line-by-line
explanation of the example code:
Line 1 creates a mesh containing 6 faces, composed of 5 unique vertices and 3 unique colors. The
number of normals and the number of
textureCoordinates are not set. The normals will be
created by the
generateNormals command.
Line 2 defines the five unique vertices used by the faces of the mesh.
Line 3 defines the three unique colors used by the faces of the mesh.
Lines 4 through 9 assign which vertices to use as the corners of each face in the Pyramid. Note the
clockwise ordering of the vertices.
GenerateNormals() relies on a clockwise ordering.
Lines 10 through 15 assign colors to the corners of each face. The colors will spread across the
faces in gradients.
Line 16 creates the normals of Triangle by calling the generateNormals() command.










