The following methods provide basic access to the Color Per Vertex channel.
For legacy methods providing access only to the Texture Channel 1, see also
Methods:
getNumCPVVerts <mesh>
Returns number of Color-Per-Vertex vertices as an integer, equivalent to using <node>.numcpvverts
setNumCPVVerts <mesh> <integer> [ <boolean> ]
Sets the number of Color-Per-Vertex vertices. If the optional boolean argument is true
, the existing topology remains intact. If it is false
or not supplied, the topology is lost.
When setting the number of CPV vertices using the numCPTVerts
property or setNumCPVVerts
method, the new verts are initialized to [0.,0.,0.]
buildVCFaces <mesh> [ <boolean> ]
Builds the Color-Per-Vertex face array after you have set the c-p-v vertex count. If the optional boolean argument is true
, the existing topology remains intact. If it is false
or not supplied, the topology is lost.
defaultVCFaces <mesh>
Sets the number of Color-Per-Vertex vertices and Color-Per-Vertex faces to match exactly the current mesh's geometry and topology and calls buildVCFaces()
getVertColor <mesh> <CPVvert_index_integer>
Returns the color of the indexed Color-Per-Vertex vertex as a color.
setVertColor <mesh> <CPVvert_index_integer> <color>
Sets the color of the indexed Color-Per-Vertex vertex.
getVCFace <mesh> <CPVface_index_integer>
Returns the topology for the indexed Color-Per-Vertex face as a point3 containing 3 Color-Per-Vertex vertex indexes.
setVCFace <mesh> <CPVface_index_integer> <CPVvert_indices_point3>
Sets the indexed Color-Per-Vertex face topology from a point3 containing 3 Color-Per-Vertex vertex indexes.
setVCFace <mesh> <CPVface_index_integer> <CPVvert_index_integer> <CPVvert_index_integer> <CPVvert_index_integer>
The Color-Per-Vertex vertex and face indexes are 1-based as with other mesh indexes in MAXScript. Remember that you need to call update()
on the mesh after making changes to it for the changes to be reflected in the scene.
The mesh class contains a list of color vertices which are completely independent of the regular vertices in the mesh. There is no correlation between the number of vertices in a mesh and the number of color vertices. In addition to the color vertices there are also color faces. There needs to be one color face for every regular face in the mesh. For details, see Understanding Texture Coordinatesand Vertex Colors topic.
Each color face has three indices into the color vertex array. The coordinates of a color vertex are RGB coordinates, and are accessed as Color values.
The techniques for building and accessing color vertices and faces is virtually identical to the techniques for building and accessing texture vertices and faces. An example script for creating planar texture mapping on an object is shown in Working with Editable Meshes.