2013-03-07 18 views
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) 
+0

什麼不工作? – Jesse 2013-03-07 10:40:20

+0

以及它實際上並沒有將圖像添加到nurbsPlane上。我不知道如何使用Python將紋理添加到平面上。 – Tapp 2013-03-07 10:53:46

+0

您可能需要創建着色器,並將其應用於NURBS平面。圖像創建一個圖像小部件。 – Skurmedel 2013-03-07 19:04:55

回答

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:你可能不想這樣做,而是你打算使用圖像平面節點。

+0

我認爲你在最後的筆記中可能是正確的,代碼有效,圖像上升,但它很模糊。你介意告訴我如何用圖像平面節點來做到這一點嗎? :D – Tapp 2013-03-07 23:51:26

+0

由於Maya通常默認使用256個子採樣,因此圖像很模糊,因此您的視口會打開高質量模式並查看會發生什麼情況。這是打算髮生的事情。默認情況下,Mayas不打算成爲wysiwyg程序。所有的數據都在那裏,它只是加速了地獄。 – joojaa 2013-03-08 06:56:55