我想创建一个nurbsPlane,然后在飞机上放置一个图像。我想在python中这样做,这是我到目前为止所做的:
import maya.cmds as cmds
class image(object):
def __init__(self,name):
cmds.nurbsPlane(axis=(0,0,0),width = 10)
cmds.image( image=name )
name='C:\Desert.jpg'
temp = image(name)
答案 0 :(得分:1)
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:您可能不想这样做,而是打算使用图像平面节点。