Get color per face/vertex?

Get color per face/vertex?

Anonymous
Not applicable
404 Views
3 Replies
Message 1 of 4

Get color per face/vertex?

Anonymous
Not applicable
So I have a sphere that I've assigned the default ramp to (blue - green - red) and I'm trying to obtain the color at each vertex; HOWEVER, when I call cmds.polyColorPerVertex() every vertex's color is black (0,0,0), unless I set it using the same command first.

Is there a way to sample color by vertex (or face) from a poly object stricly based off of it's shader's properties?

- forni
0 Likes
405 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
You should use the colorAtPoint command instead.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Given a point on the surface of my shape (ie. a vertex in this case) how do I obtain the UV coordinates of corresponding point in world space so that I may use color at point? Is there an easy way to do this?
0 Likes
Message 4 of 4

kurianos
Participant
Participant
import maya.cmds as cmds

def getSelectedVertexColor(colorNode):
getCurrentVertex=cmds.ls(sl=True)
for eachVertex in getCurrentVertex:

convertVTX = cmds.polyListComponentConversion(eachVertex,fromVertex=True,toUV=True)

getUVValue = cmds.polyEditUV(convertVTX,q=True)

getVertexColorVal=cmds.colorAtPoint(colorNode,o='RGB',u=getUVValue,v=getUVValue)

print getVertexColorVal

getSelectedVertexColor('ramp1')


hope will help you
0 Likes