Starrider
10-05-2006, 02:01 PM
does anyone know how to mel-code an aim constraint with an up-vector? i want to give it two vectors (aim/up) and get three rotation values back.
what i got so far is:
$locPos = <<locator1.translateX, locator1.translateY, locator1.translateZ>>;
pCube1.rotateZ = atan($locPos.y / $locPos.x) / 2 / 3.14159265 * 360;
if($locPos.x < 0)
pCube1.rotateZ = pCube1.rotateZ -180 ;
pCube1.rotateY = atan(-$locPos.z / sqrt($locPos.x*$locPos.x+$locPos.y*$locPos.y)) / 2 / 3.14159265 * 360;
it constrains the rotation of the pCube to the vector the locator/worldCenter describes. but i wasn't able to figure out how it works with the up-vector.
any ideas?
what i got so far is:
$locPos = <<locator1.translateX, locator1.translateY, locator1.translateZ>>;
pCube1.rotateZ = atan($locPos.y / $locPos.x) / 2 / 3.14159265 * 360;
if($locPos.x < 0)
pCube1.rotateZ = pCube1.rotateZ -180 ;
pCube1.rotateY = atan(-$locPos.z / sqrt($locPos.x*$locPos.x+$locPos.y*$locPos.y)) / 2 / 3.14159265 * 360;
it constrains the rotation of the pCube to the vector the locator/worldCenter describes. but i wasn't able to figure out how it works with the up-vector.
any ideas?
