import maya.cmds as cmds
class image(object):
def __init__(self,name):
plane = cmds.nurbsPlane(axis=(0,0,0),width = 10)
shader = cmds.shadingNode('surfaceShader', asShader=True)
SG = cmds.sets(empty=True, renderable=True,
noSurfaceShader=True, name=shader+"SG")
cmds.connectAttr(shader+'.outColor', SG+".surfaceShader",
force=True)
img = cmds.shadingNode('file', asTexture=True)
cmds.setAttr(img+'.fileTextureName', name, type='string')
cmds.connectAttr(img+'.outColor', shader+'.outColor',
force=True)
# you should connect to a texture placement node and
# its numerous connectins here
cmds.sets(plane[0], edit=True, forceElement=SG)
name=r'C:\Desert.jpg'
temp = image(name)
這是假設你已經把視口紋理和陰影。無論如何,您確實需要將屬性連接到展示位置節點才能正確完成。
PS:你可能不想這樣做,而是你打算使用圖像平面節點。
什麼不工作? – Jesse 2013-03-07 10:40:20
以及它實際上並沒有將圖像添加到nurbsPlane上。我不知道如何使用Python將紋理添加到平面上。 – Tapp 2013-03-07 10:53:46
您可能需要創建着色器,並將其應用於NURBS平面。圖像創建一個圖像小部件。 – Skurmedel 2013-03-07 19:04:55