Python 获取纹理的问题';给定点的颜色

Python 获取纹理的问题';给定点的颜色,python,maya,Python,Maya,我试图得到一个纹理在u-v坐标下的颜色,这个坐标与多边形的顶点有关。我遇到的问题是,我得到的每个坐标结果都是相同的颜色,即使它不是那样绘制的 我一直在尝试放置一个纹理并在以后绘制它,然后在一个简单的平面中获得每个顶点的颜色。我所能看到的或多或少是我已经拥有的,polyListComponentConversion和colorAtPoint以及uv坐标。 我得到的分数是[0.0,0.0],[1.0,0.0],[0.0,1.0],[1.0,1.0],其中一个角的颜色始终相同。 如果我试着用另一个值来

我试图得到一个纹理在u-v坐标下的颜色,这个坐标与多边形的顶点有关。我遇到的问题是,我得到的每个坐标结果都是相同的颜色,即使它不是那样绘制的

我一直在尝试放置一个纹理并在以后绘制它,然后在一个简单的平面中获得每个顶点的颜色。我所能看到的或多或少是我已经拥有的,
polyListComponentConversion
colorAtPoint
以及uv坐标。 我得到的分数是
[0.0,0.0],[1.0,0.0],[0.0,1.0],[1.0,1.0]
,其中一个角的颜色始终相同。 如果我试着用另一个值来硬编码(比如
[.5,5]
),那么我会得到另一种看起来很准确的颜色

我所做的是:

#Create and place the texture files into the poly
def createShadingEngine(vName):

    vNewShadingGroup = mc.sets(name = '{0}_SG'.format(vName), empty = True, renderable = True, noSurfaceShader = True)
    vNewMaterial = mc.shadingNode('lambert', name = '{0}_mat'.format(vName), asShader = True)
    mc.connectAttr('{0}.outColor'.format(vNewMaterial), '{0}.surfaceShader'.format(vNewShadingGroup))
    vNewTexture = mc.shadingNode('file', name = '{0}_file'.format(vName), asTexture = True)
    vNewUtility = mc.shadingNode('place2dTexture', name = '{0}_tex'.format(vName), asUtility = True)
    mc.connectAttr('{0}.outColor'.format(vNewTexture), '{0}.color'.format(vNewMaterial))

    vConnectAttr = ['coverage', 'translateFrame', 'rotateFrame', 'mirrorU', 'mirrorV', 'stagger', 'wrapU', 'wrapV',
                    'repeatUV', 'offset', 'rotateUV', 'noiseUV', 'vertexUvOne', 'vertexUvTwo', 'vertexUvThree', 'vertexCameraOne']
    for vAttr in vConnectAttr:
        mc.connectAttr('{0}.{1}'.format(vNewUtility, vAttr), '{0}.{1}'.format(vNewTexture, vAttr))
        mc.connectAttr('{0}.outUV'.format(vNewUtility), '{0}.uv'.format(vNewTexture))
        mc.connectAttr('{0}.outUvFilterSize'.format(vNewUtility), '{0}.uvFilterSize'.format(vNewTexture))

    return vNewShadingGroup

#Get the map points for the poly
def getPolyMap(vPoly):

    vPoints = []

    if mc.objExists(vPoly):
        vShape = mc.listRelatives('pPlane1', children = True, fullPath = True, shapes = True)[0]
        vEngine = mc.listConnections(vShape, type = 'shadingEngine')
        vMaterials = mc.ls(mc.listConnections(vEngine), materials = True)
        vTextureFiles = mc.listConnections(vMaterials, type = 'file')

        if vTextureFiles :
            vMapPoints = mc.polyListComponentConversion('{0}.vtx[*]'.format(vPoly), fv = True, tuv = True)
            vMapPoints = mc.ls(vMapPoints, flatten = True)
            for vPoint in vMapPoints:
                vCoord = mc.polyEditUV(vPoint, q = True)
                print vPoint, vCoord
                vPoints.append(vCoord)

    return vPoints

#Get the color at those points
def getColorAtPointUV(vPoly, vUVPoint = [0, 0]):

    vColor = ''

    vShape = mc.listRelatives('pPlane1', children = True, fullPath = True, shapes = True)[0]
    vEngine = mc.listConnections(vShape, type = 'shadingEngine')
    vMaterials = mc.ls(mc.listConnections(vEngine), materials = True)
    vTextureFiles = mc.listConnections(vMaterials, type = 'file')
    if vTextureFiles and len(vUVPoint) == 2:
        vColor = mc.colorAtPoint('{0}.outColor'.format(vTextureFiles ), o = 'RGB', u = vUVPoint[0], v = vUVPoint[1])

    return vColor

#With those functions I execute:
vShape = mc.listRelatives('pPlane1', children = True, fullPath = True, shapes = True)[0]
vEngine = mc.listConnections(vShape, type = 'shadingEngine')
vMaterials = mc.ls(mc.listConnections(vEngine), materials = True)
vTextureFiles = mc.listConnections(vMaterials, type = 'file')
cv = getPolyMap('pPlane1')
for cc in cv:
    print cc, mc.colorAtPoint(vTextureFiles, o = 'RGB', u = cc[0], v = cc[1])
我从中得到的结果是:

[0.0,0.0][0.00784313678741455,0.992156830679407,0.00784313678741455]
[1.0, 0.0] [0.00784313678741455, 0.9921568036079407, 0.00784313678741455]
[0.0, 1.0] [0.00784313678741455, 0.9921568036079407, 0.00784313678741455]
[1.0, 1.0] [0.00784313678741455, 0.9921568036079407, 0.00784313678741455]
uv的每个角落都打印绿色,即使只有一个角落是该颜色。 另一方面,如果我用
u=.5
v=.5
强制它,结果就是正确的(默认灰色
[0.501960754394512,0.501960754394512,0.501960754394512]

无法发布图像,但它是一个灰色正方形,右上角有一个绿点)