Maya Python 在平面上放置图像
我想创建一个NURBS平面,然后在这个平面上放一张图片。我想用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)
1 个回答
2
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)
这段话的意思是,你需要把视口设置为纹理和阴影模式。无论如何,你确实需要把属性连接到一个放置节点,这样才能正确设置。
补充说明:你可能不想这样做,而是应该使用一个图像平面节点。