0

我想创建一个 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)
4

1 回答 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)

这假设您已将视口转换为纹理和着色。无论如何,您确实需要将属性连接到放置节点才能正确完成。

PS:您可能不想这样做,而是打算使用图像平面节点。

于 2013-03-07T20:38:08.283 回答