hibitekitou
RenderTreeでノードをスクリプトで繋ぐ
xsi |2011-09-10
一昨日のエントリ。
PythonとJscriptと結果が違う
にて、なんでPythonで出来ないの?って疑問について、コメントで教えてもらった方法を試してみました。
まずは、Imageノードを作らずにイメージクリップを直接Phongノードに繋いでしまうって方法。
これすると、Imageノードを自動で作ってくれます。問題は、ambientに繋がっているのとdiffuseに繋がっているのと、Imageノードが二つ作られてしまうことでしょうか。
だから、例えばdiffuseポートに繋がったImageノードができたら、ambientポートとそのImageノードを繋いでやる処理をすべきと言えそうです。
もう一つはDispatchってのを使う方法。
実はこれ、よく分かっておりません(^^; でも、この方法だと、もともとやろうとしていた方法に限りなく近い書式で書くことが出来ます。
ちゃんとお勉強しませんとね。
この辺、やさしく教えてくれる所あるかねー。
PythonとJscriptと結果が違う
にて、なんでPythonで出来ないの?って疑問について、コメントで教えてもらった方法を試してみました。
まずは、Imageノードを作らずにイメージクリップを直接Phongノードに繋いでしまうって方法。
from win32com.client import constants as c app = Application log = app.Logmessage scn = app.ActiveProject.ActiveScene oImageClip = app.CreateImageClip(r"$SI_HOME\Data\XSI_SAMPLES\Pictures\xsilogo.jpg",) matLib = scn.ActiveMaterialLibrary oMat = matLib.CreateMaterial( "Phong", 'PhongMat' ) oShader = oMat.Shaders(0) ambient = oShader.Parameters("ambient") diffuse = oShader.Parameters("diffuse") ambient.Connect( oImageClip ) diffuse.Connect( oImageClip )
これすると、Imageノードを自動で作ってくれます。問題は、ambientに繋がっているのとdiffuseに繋がっているのと、Imageノードが二つ作られてしまうことでしょうか。
だから、例えばdiffuseポートに繋がったImageノードができたら、ambientポートとそのImageノードを繋いでやる処理をすべきと言えそうです。
もう一つはDispatchってのを使う方法。
実はこれ、よく分かっておりません(^^; でも、この方法だと、もともとやろうとしていた方法に限りなく近い書式で書くことが出来ます。
from win32com.client import constants as c
from win32com.client import Dispatch
app = Application
log = app.Logmessage
scn = app.ActiveProject.ActiveScene
oImageClip = app.CreateImageClip(r"$SI_HOME\Data\XSI_SAMPLES\Pictures\xsilogo.jpg",)
matLib = scn.ActiveMaterialLibrary
oMat = matLib.CreateMaterial( "Phong", 'PhongMat' )
oShader = oMat.Shaders(0)
ambient = oShader.Parameters("ambient")
diffuse = oShader.Parameters("diffuse")
imageNode = ambient.ConnectFromPreset( "Image", c.siTextureShaderFamily )
diffuse.Connect(imageNode[0])
Dispatch(imageNode[0]).Parameters("tex").Connect(oImageClip)
ちゃんとお勉強しませんとね。
この辺、やさしく教えてくれる所あるかねー。
コメント ( 5 )|Trackback ( )
・