#XYZ to vector/angle?
2 messages in this thread
Everyone,
I'm working on a script which will load motion capture info and attach it to
mesh in the KF. My question is embedded in the script below. Pardon my possible
ignorance… this is my first attempt with the scripter.
——————————-
DefPosition tran
DefRotate rot
tran = 0
rot = 0
open "o:\scene5b.dat", INPUT, #1
for j = 1 to 1000
tran.time = j
rot.time = j
input #1, node, tran.x, tran.y, tran.z, rot.x, rot.y, rot.z ; this is
the motion capture format.
; why doesn't keyscript like rot.x? how do i translate absolute
angular
; rotation ( x, y, z rotation ) to vector/angle rotation ( 3dstudio )?
CreateKey node, tran
CreateKey node, rot
next j
——————————-
Thanks in advance!
Todd
Mechadeus
Hi Mechadeus,
<< rot x, y, z.. >>
You'll need to convert between your Euler angles to a quaternion. Do you have
access to an Inside 3DS R4 book? Check out the script I wrote called
Camtrack.k3d. There I had to determine the angle between 2 vectors and then
create a valid rotation key for every frame. There's a chunk of code in there
that may be of interest to you..
If you have access to 3D Animation by Vince, you'll find some good insights
into Euler/quaternion conversion. In addition I found some old posts on the
quaternion subject below..
<< You mentioned "Quaternions" in a recent thread. What the heck are they? >>
If you want to see one, rotate an object in the keyframer a bit in the x, the y
and the z and then look at the rotation key in the key info dialog box. You'll
find a normalized vector rotated about an axis by an angle. You ponder and
say.. but I rotated the object 3 times.. and I would say yes..the three
rotations were reduced to a single rotation around this particular axis..
<<How does one compute a quaternion?>>
The best advice is to review "3-D Computer Animation" by Vince.. or "Computer
Graphics" by
Foley, vanDam, Feiner, Hughes.. however, in short given two vectors, you can
solve for the angle between the vectors by using the dot product for vectors.
Given the angle, now you can solve for the cross product which will give you
the normal to the plane that the two vectors pass through. If you used the
object's pivot point as
the shared point between the two vectors the normal to the face can be viewed
as the axis.
<<Why quaternions instead of a matrix?>>
When trying to get smooth camera movement and trying to get ease to and ease
from to work, matrix solutions result in non smooth results while quaternions
offer very smooth interpolated results.