ADOBE AFTER EFFECTS: Forum Expressions Tutorials Podcasts Creative Cloud

Script to bake keyframes into layers from IK rig

COW Forums : Adobe After Effects Expressions

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index


Dan MurthaScript to bake keyframes into layers from IK rig
by on May 2, 2012 at 11:43:04 am

Hi all,

I'm animating characters using an ik rig, with the intention of exporting the animation as XML.

I'm currently using the DuIK system, and I am prototyping at the moment but it seems that I will need to bake the animation into the component layers so that each one is moving independently without expressions or parenting.

This script achieves this for traditionally parented objects, but is not entirely successful when attempted on layers in the IK rig, in some instances achieving correct rotation and in others correct position but never both.

Has anyone made a successful script that does this, or does it require some tweaking of the original script? Or is impossible to successfully bake, and I may need to make manual corrections?

I have put a sample of the IK expression below from the 'L_WRIST' of a test 'arm'.

Thanks,

Dan

boneracine = "L_ARM";
bonebout = "L_WRIST";
zero = "L_HAND";
controleur = "C_L_HAND";
if (thisComp.layer(controleur).effect("IK Orientation L_HAND")(1) == 1) {cw = true}else{cw=false}
function getWorldPos(theLayerName){
L = thisComp.layer(theLayerName);
return L.toWorld(L.anchorPoint);
}
function oriente(a, b, P) {
return ((b[0]-a[0])*(P[1]-a[1]) - (P[0]-a[0])*(b[1]-a[1]) );
}
A = getWorldPos(boneracine);
B = getWorldPos(bonebout);
C = getWorldPos(zero);
E = getWorldPos(controleur);
a = length(B,C);
b = length(E,A);
c = length(A,B);
x = (b*b + c*c - a*a )/(2*b);
alpha = Math.acos(clamp(x/c,-1,1));
y = b - x;
gamma = Math.acos(clamp(y/a,-1,1));
result = (cw ? 1 : -1)*radiansToDegrees(gamma + alpha); V1 = B - A;
adj1 = radiansToDegrees(Math.atan2(V1[1],V1[0]));
V2 = C - B;
adj2 = radiansToDegrees(Math.atan2(V2[1],V2[0]));
result + adj1 - adj2 + value;


Posts Index 


Current Message Thread:
  • Script to bake keyframes into layers from IK rig by Dan Murtha on May 2, 2012 at 11:43:04 am





© 2016 CreativeCOW.net All Rights Reserved
[TOP]