3D Lingo Dictionary > C-D > colors |  |

colors

Syntax

    member(whichCastmember).modelResource(whichModelResource).face[faceIndex].colors

Description

3D face property; a linear list of three integers indicating which index positions of the model resource's color list to use for the three vertices of the face. The color list is a linear list of `rgb` values.

The `colors` property is used only with model resources whose type is `#mesh`.

You must use the model resource's `build()` command after setting this property; otherwise, the changes will not take effect.

Example

This example creates a model resource whose type is `#mesh`, specifies its properties, and then creates a new model with it.

Line 1 uses the `newMesh()` command to create a `#mesh` model resource named Triangle, which has one face, three vertices, and a maximum of three colors. The number of normals and the number of texture coordinates are not set.

Line 2 sets the `vertexList` property to a list of three vectors.

Line 3 assigns the vectors of the `vertexList` property to the vertices of the first face of Triangle.

Line 4 sets the color list to three `rgb` values.

Line 5 assigns colors to the first face of Triangle. The third color in the color list is applied to the first vertex of Triangle, the second color to the second vertex, and the first color to the third vertex. The colors will spread across the first face of Triangle in gradients.

Line 6 creates the normals of Triangle with the `generateNormals()` command.

Line 7 uses the `build()` command to construct the mesh.

Line 8 creates a new model named TriModel that uses the new mesh.

    nm = member("Shapes").newMesh("Triangle",1,3,0,3,0)
    nm.vertexList = [vector(0,0,0), vector(20,0,0), vector(20, 20, 0)]
    nm.face[1].vertices = [1,2,3]
    nm.colorList = [rgb(255,255,0), rgb(0, 255, 0), rgb(0,0,255)]
    nm.face[1].colors = [3,2,1]
    nm.generateNormals(#smooth)
    nm.build()
    nm = member("Shapes").newModel("TriModel", nm)

See also

`face`, `vertices`, `colorList`, `flat`