PDA

View Full Version : Animation: Marge Animation problem


Namroth
04-30-2003, 10:35 PM
I am using Character and Marge Animation in max5, and rigg is from Comet Cartoons script.

When I marge a walk that I have saved in *.anm file first time it works ok, but if I try to marge second time and use "Paste to Existing Animation" in "Marge Animation" dialog I get wrong:
"--Runtime error: Illegal self -reference in control script."
and this text:
-------------------------------------------------------------------------
ependsOn $'man_handRCTRL' $'man_elbowRCTRL';

--

-- Wrap this in a cA.get to make sure we have CA's now.

-- Otherwise on a load or merge, 3dsMAX might try to execute

-- this before the CA's get loaded in! This way it waits until

-- everything is fully loaded before -really- calculating.

myD = custAttributes.get $'man_handRCTRL'.Attribute_Holder 1;

if (myD != undefined) then

(

--

-- This script takes two helpers on the wrist to get a

-- local hand "Y" vector, and then unrotates it

-- by the rotation on the lower arm.

-- This way the hand vector is now aligned to the

-- coordinate space of the lower arm.

-- At that point I can get what would be the rotation around

-- the lowerArms X axis using the Y axis as reference

-- (using Y means Y is still correct even if it rotates

-- up/down on the Y axis causing the Z to move)

-- Because we've rotated the hand's world space rotation

-- back by the lower arm readers rotation, this all

-- works in the coordinates of the lower arm, thereby

-- giving us proper values, even though the hand

-- is not in the hierarchy.

-- Using simple trig (SOH CAH TOA) we can get the angle

-- of the twist.

--

coordsys world

(

-- Get rotation in world of lower arm

rotStart = $'man_lowArmReaderRINT'.rotation as eulerangles;

-- where is our wrist axis at?

posEnd = $'man_wristReaderRINT'.position;

-- Get our Y axis for the wrist in world

endY = $'man_wristReaderYRINT'.position - posEnd;

-- Normalize our wrist axis

endY = normalize endY;

)

-- Everything is now normalized for the wrist, so

-- all we have to do now is unrotate by the upperArm angles

-- Make rotation matrices

rotMatX = rotateXmatrix rotStart.x;

rotMatY = rotateYmatrix rotStart.y;

rotMatZ = rotateZmatrix rotStart.z;

rotMat = rotMatX * rotMatY * rotMatZ;

-- Now rotate our Y axis Vector by each x y z of the lowerArm we got

endY = endY * rotMat;

--format "--DEBUG: x=% y=% z=%\n" endX endY endZ;

-- Max atan always in degrees...yay

-- X is axis down bone, Z is up, but will probably move a lot, so look at one back/sideways = Y

autoTwistX = 0.0;

-- First make sure we don't have a divide by 0 error...

if (endY.z != 0) then

autoTwistX = atan (endY.y / endY.z) +90;

-- Then if we have crossed above the Y=0 line, we will have a 180 flip, so handle that...

if (endY.z > 0) then

(

autoTwistX -= 180;

)

autoTwistX = -1*autoTwistX; -- Do this just so things rotate the right way

-- Now add in any manual override the user did using the handCTRL attribute.

autoTwistX *= $'man_handRCTRL'.Attribute_Holder.autoTwistPct / 100.0;

autoTwistX += $'man_handRCTRL'.Attribute_Holder.extraTwist;

--

)

else

0.0;

-- End of autoTwist script

------------------------------------------------------------------------------
Can someone help me with this I have tested with simple animation on other objects and marge animation work fine.

michaelcomet
04-30-2003, 11:21 PM
That's just a script that sets an attribute for wrist twist auto stuff. It seems like something merge anim is doing is messing up the custom attributes or thinking it now has a cycle, even though it doesn't.

I really don't have a solution. If I had time i was going to write my own charRigger related load/save posing and animation export/import routines, but I haven't had a chance. That being said as well, Max still doesn't really handle complex rigs and merging/referencing that well yet At least with script controllers, vs. expression controllers. Expressions are stable, but scripts are needed for some stuff like this, but can easily get broken on an import etc....

CGTalk Moderation
01-15-2006, 12:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.