3D Lingo Dictionary > L-N > newMesh |
![]() ![]() ![]() |
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:
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
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.
Line 17 calls the build
command to construct the mesh.
nm = member("Shapes").newMesh("pyramid",6 , 5, 0, 3) nm.vertexList = [ vector(0,0,0), vector(40,0,0), vector(40,0,40), vector(0,0,40), vector(20,50,20) ] nm.colorList = [ rgb(255,0,0), rgb(0,255,0), rgb(0,0,255) ] nm.face[1].vertices = [ 4,1,2 ] nm.face[2].vertices = [ 4,2,3 ] nm.face[3].vertices = [ 5,2,1 ] nm.face[4].vertices = [ 5,3,2 ] nm.face[5].vertices = [ 5,4,3 ] nm.face[6].vertices = [ 5,1,4 ] nm.face[1].colors = [3,2,3] nm.face[2].colors = [3,3,2] nm.face[3].colors = [1,3,2] nm.face[4].colors = [1,2,3] nm.face[5].colors = [1,3,2] nm.face[6].colors = [1,2,3] nm.generateNormals(#flat) nm.build() nm = member("Shapes").newModel("Pyramid1", nm)
See also
![]() ![]() ![]() |