PDA

View Full Version : Setting Vertex Colors in MAXScript


chriskroll
01-16-2008, 05:45 AM
I need to be able to set vertex colors programmatically. Here is an example of the code I am trying to run and the error that I get. Can anyone help me out?

verts = #([1,1,0],[-1,1,0],[-1,-1,0],[1,-1,0])
faces = #([1,2,3],[1,3,4])
m = mesh vertices:verts faces:faces
setvertcolor m 1 [1,50,200]

-- Runtime error: Mesh Color-per-vertex vertex index out of range: 1

dutch_delight
01-16-2008, 09:19 AM
Have a look at setnumcpvverts in the reference.




verts = #([1,1,0],[-1,1,0],[-1,-1,0],[1,-1,0])
faces = #([1,2,3],[1,3,4])
m = mesh vertices:verts faces:faces
setNumCPVVerts m m.numverts
defaultVCFaces m
setvertcolor m 1 [1,50,200]

chriskroll
01-16-2008, 08:09 PM
Thank you for your help dutch delight, that did the trick.

CGTalk Moderation
01-16-2008, 08:09 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.