vendredi 29 mars 2019

Assigning random rgb values for each vert in Maya with Python through polyColorPerVertex command

I am creating an object in Maya as well as a new colorSet for it. Then I'm trying to assign random rgb values for each vert inside that colorSet.

Here is my initial setup for spawning an object and assigning colorSet with color

import maya.cmds as cmds
import functools
import random

colorList =cmds.ls('colorSet*' )
sphereList = cmds.ls( 'mySphere*' )
if len( sphereList ) > 0:
    cmds.delete( sphereList)

result = cmds.polySphere ( r=50, sx=random.randrange(10, 100), sy=random.randrange(10,100), name='mySphere#' )
result = cmds.polyColorSet ( create=True, colorSet='colorSet1')
cmds.polyColorPerVertex('mySphere*',clamped=False, rgb=(1,0,0))

The code runs fine and the ColorSet is created but it doesn't fill the object with color. i.e. the sphere is not red secondly I don't really know how to grab all verts of an object and assign color through the polyColorPerVertex

Each vert should receive a random rgb value and not just be filled with a uniform color across the whole mesh.




Aucun commentaire:

Enregistrer un commentaire