Hi,
unfortunately i used z-up in a scene (stupid, i know). And i can't change to y-up because i used different skeletons, contraints, clusters ... to move objects in this scene.
Now i have to animate a rolling ball in this scene. I tried to use the makeRoll command. I had to realize that the script is made for y-up and doesn't work with z-up.
Ok, i could use Dynamics, but that would be like cracking a nut with a sledgehammer or moving the ball along a path with rotation animated. But for this scene i would like to use the makeRoll script, because i can better adjust the movement.
The problem is that i have no experience in writing mel but want to learn it.
This is the script (the script is assigned to the translateY attribute) when i use makeRoll (makeRoll ball 0.5 false 1):
float $diameter = 1;
ball.translateY = $diameter * 0.5 + 0.5;
float $tx = ball.translateX;
float $tz = ball.translateZ;
if( frame <= 1 ){
float $rx = ball.startRotX;
float $ry = ball.startRotY;
float $rz = ball.startRotZ;
setAttr ball.rx $rx;
setAttr ball.ry $ry;
setAttr ball.rz $rz;
ball.lastX = $tx;
ball.lastZ = $tz;
} else {
float $lx = getAttr "ball.ltx";
float $lz = getAttr "ball.ltz";
float $x = $tx-$lx;
float $z = $tz-$lz;
float $d = sqrt($x * $x + $z*$z);
if( $d > 0.00001 ){
$x /= $d;
$z /= $d;
float $piD = 3.14 * $diameter;
float $xrot = 360.0 * $d/$piD;
float $yrot = rad_to_deg( atan2( $x, $z ));
rotate -ws -r 0 (-$yrot) 0 ball;
rotate -ws -r ($xrot) 0 0 ball;
rotate -ws -r 0 ($yrot) 0 ball;
ball.lastX = $tx;
ball.lastZ = $tz;
}
}
Can somebody tell me what i have to do to make the script work with z-up.
Thanks for your help.
Thomas