Scripting Animation Layers

Date : Mon, 16 Apr 2007 18:01:11 +0200
To : xsi(at)Softimage.COM
From : André Adam <a_adam(at)49games.de>
Subject : Scripting Animation Layers
Heya,

what are people's experiences with scripting Animation Layers? I'm just in the middle of designing an offset system and have to plot IK driven animation on top of an FK layer.

*Any* attempt to do a simple SaveKey() inside of a cycle fails miserably, the plottet offsets make no sense at all. *However*, if I move the timeline manually (oPlayCtrl.Parameters("Current").Value = blabla) and call a Refresh() from within the cycle, it works. This must be the most ugly code ever; is this a bug, really meant to work like this or me not getting something? To my understanding the offset keys are solved through the interface?

Thanks in advance if anybody has a little bit of experience to share with this new feature's internals. Oh, and a bit of repro code below...

Cheers!

   -André


//1: Build and animate a skeleton:

//Create Skeleton
Create2DSkeleton(0, 0, 0, 0, 1, -3, 0, 90, 0, 4);
AppendBone("eff", 0, 0, -6);
//Key FK Animation
SaveKey("bone.kine.local.rotx,bone.kine.local.roty,bone.kine.local.rotz,bone1.kine.local.rotx,bone1.kine.local.roty,bone1.kine.local.rotz", 1);
Rotate("bone", 50, 0, 0, siRelative, siGlobal, siObj, siXYZ);
Rotate("bone1", -100, 0, 0, siRelative, siGlobal, siObj, siXYZ);
SaveKey("bone.kine.local.rotx,bone.kine.local.roty,bone.kine.local.rotz,bone1.kine.local.rotx,bone1.kine.local.roty,bone1.kine.local.rotz", 100);
//Key Effector, overriding the FK animation
SaveKey("eff.kine.local.posx,eff.kine.local.posy,eff.kine.local.posz", 1);
Translate("eff", 3, -1.5, 3, siRelative, siGlobal, siObj, siXYZ);
SaveKey("eff.kine.local.posx,eff.kine.local.posy,eff.kine.local.posz", 100);
AddAnimationLayer("Scene_Root");
SelectObj("bone,bone1");


//2.: Trying to plot the delta between FK and IK the straight forward way, does not work:

function fPlotRotationOffsets(cObjs, aInOut){
 var cKeyParams = new ActiveXObject("XSI.Collection");
 var eObjs = new Enumerator(cObjs);
 while(!eObjs.atEnd()){
   cKeyParams.Add(eObjs.item().RotX);
   cKeyParams.Add(eObjs.item().RotY);
   cKeyParams.Add(eObjs.item().RotZ);
   eObjs.moveNext();
 }
 for(var i=aInOut[0]; i<aInOut[1]+1; i++){
   SaveKey(cKeyParams.GetAsText(), i, null, -1, -1, false);
 }
}
fPlotRotationOffsets(Selection, new Array(1,100));

//3.: I have to do this instead:

function fPlotRotationOffsets(cObjs, aInOut){
 var cKeyParams = new ActiveXObject("XSI.Collection");
 var eObjs = new Enumerator(cObjs);
 while(!eObjs.atEnd()){
   cKeyParams.Add(eObjs.item().RotX);
   cKeyParams.Add(eObjs.item().RotY);
   cKeyParams.Add(eObjs.item().RotZ);
   eObjs.moveNext();
 }
 var oPlayCtrl = ActiveProject.Properties.Find("PlayControl");
 for(var i=aInOut[0]; i<aInOut[1]+1; i++){
   oPlayCtrl.Parameters("Current").Value = i; //Bad!
   Refresh(); //Even worse!
   SaveKey(cKeyParams.GetAsText());
 }
}
fPlotRotationOffsets(Selection, new Array(1,100))














--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.