XSIユーザーから観たMELスクリプトについて 其の十一
つづいてイベントスクリプトについて
SIでいう、イベントスクリプトは「scriptJob」というもので
管理されている。流れ的には
「scriptJob 【-ここにイベント指定文】【イベントとなる対象の値】【処理内容】」
となる。なので、例で解くと↓
scriptJob -attributeChange sphere1.tx X;
関数Xはこんな感じ。
global proc X() { setAttr sphere1.tx 10.0; }
スフィア1のX座標が変更されたら、この関数実行します。って感じ。
でこれの実例が↓
global proc Change() { float $x = `getAttr sphere1.tx`; float $y = `getAttr sphere1.ty`; float $z = `getAttr sphere1.tz`; if( $x > 10.0 ) { setAttr sphere1.tx 10.0; } if( $y > 10.0 ) { setAttr sphere1.ty 10.0; } if( $z > 10.0 ) { setAttr sphere1.tz 10.0; } } sphere -n sphere1; scriptJob -attributeChange sphere1.tx Change; scriptJob -attributeChange sphere1.ty Change; scriptJob -attributeChange sphere1.tz Change;
これでスフィアがXYZ10.0以上に移動したくなりました。
scriptJobがスクリプトオペレーター的な感じなんでしょうか?
ってかこれ重くなるんかな?
でこれをSIでやると、多分スクリプトオペレータを使わないとダメだと思います。
こんな感じかと。。↓
var Sphere = CreatePrim("Sphere", "MeshSurface"); var SetParam = Update.toString() AddScriptedOp(Sphere+".kine.local", SetParam, "sphere.kine.local", null, "JScript", 0); function Update(In_UpdateContext, Out, Inlocal) { var Trans = Inlocal.value.transform; var PosX = Trans.posx; var PosY = Trans.posy; var PosZ = Trans.posz; if(PosX > 10 ) { PosX = 10.0; } if(PosX < -10 ) { PosX = -10.0; } if(PosY > 10) { PosY = 10.0; } if(PosY < -10) { PosY = -10.0; } if(PosZ > 10) { PosZ = 10.0; } if(PosZ < -10) { PosZ = -10.0; } Trans.posx = PosX; Trans.posy = PosY; Trans.posz = PosZ; Out.value.transform = Trans; }
XYZが10もしくは、-10の場合それぞれ10、-10以上以下に行かないようになってます。
MELはスクリプトオペレーターがリアルタイムで動いてるんですね。
これ少しこわいかも。
にしても今後はこのコマンド多様するんで、
下記のイベント郡だけでも覚えておこうかと。
と書こうかと思ったんですが、何故か文字数オーバーで書けなかったんで、ヘルプ見ることにします。
では…