日々適当

hibitekitou

(メモ)サンプルスクリプトより

xsi |2004-11-17
XSI4.0付属のサンプルスクリプトより

PickElement "Object", "Pick first object", "Pick first object", l_obj1, l_button


書式は

PickElement (SelFilter, LeftMessage, MiddleMessage, [PickedElement], [ButtonPressed], SelRegionMode, [ModifierPressed])


とのこと。
SetFilterではピックするものをフィルタリングできる。サンプルスクリプトでは"Object"タイプのものをピックできる。
"l_obj1"はPickedElementに対応するみたい。ピックされたものがl_obj1に入れられる。
そうすると、"l_button"は ModifierPressed に対応するのだろうか。押されたマウスボタンに応じた値が"l_button"に入れられる。

dim tObj,button

CreatePrim "Sphere", "MeshSurface"

PickElement "Object","Select Obj","Select Obj", tObj, button

if button <> 0 then
MsgBox tObj.Name
end if


この場合、選択されたオブジェクトの名前を返してくる。

PickPositionはもうちょっと簡単。書式は

PickPosition (LeftMessage, MiddleMessage, PosX, PosY, PosZ, ButtonPressed)


たとえば、あまり意味がないけど、ピックしたオブジェクトを、次にピックした位置に移動させる、というスクリプトは

dim tObj,x1,y1,z1,button1,button2

PickElement "Object","Select Obj","Select Obj",tObj,button1

if button1 <> 0 then

PickPosition "Pick a position to move","Pick a position to move",x1,y1,z1,button2

if button2 <> 0 then
SetValue tObj &".kine.local.posx" , x1
SetValue tObj &".kine.local.posy" , y1
SetValue tObj &".kine.local.posz" , z1
end if

end if


こんな感じかな?
コメント ( 0 )|Trackback ( )