Hi all,
I finally got some time to try to get into 3D in director. I have followed
Darrel Plants excellent articles "Rolling (and Pitching and Yawing) the
Bones" on DOUG.
Now I'm playing around with my file. I have been setting restraints to the
rotation in different joints, changing how the rotation is controlled etc.
The addition that is giving me problems is a go to saved position function.
I added a function that saves the rotation of the joints in a list. Now I
want to let Lingo animate a movement from the current position of the arm to
a saved position. I get it to work for some positions but not all. I guess
my problem really is to find the shortest distance between the current
rotation and the saved rotation. My current code only looks at at the x, y
and z values separately.
Ant help as to what I should think about would be welcome,
Thanks in advance,
Martin
Here is the code I have now. It is called from an on EnterFrame handler.
Listan is a list of the joints and their rotations. It could look like this
for example:
put listan
-- "listan = [[2, vector( 115.2130, -52.0513, -145.5742 )], [3, vector(
0.0000, 0.0000, 56.5818 )], [4, vector( 29.2832, -15.9019, -87.0001 )], [6,
vector( 180.0000, 0.0000, 0.0000 )], [7,
vector( -179.9908, -0.0165, -58.3616 )]]"
-----------
on changePos me, listan
repeat with a = 1 to count(listan)
i = listan[a][1]
endRot = listan[a][2]
nowTrans = pArm.bonesplayer.bone[i].transform
nowRot = nowTrans.rotation
if nowRot.x < (endRot.x - 0.5) then
changeRotation me, i, vector( 1, 0, 0 )
else if nowRot.x > (endRot.x +0.5) then
changeRotation me, i, vector( -1, 0, 0 )
end if
if nowRot.y < (endRot.y - 0.5) then
changeRotation me, i, vector( 0, 1, 0 )
else if nowRot.y > (endRot.y + 0.5) then
changeRotation me, i, vector( 0, -1, 0 )
end if
if nowRot.z < (endRot.z - 0.5) then
changeRotation me, i, vector( 0, 0, 1 )
else if nowRot.z > (endRot.z + 0.5) then
changeRotation me, i, vector( 0, 0, -1 )
end if
end repeat
end
on changeRotation me, vBone, vVector
t1 = pArm.bonesplayer.bone[vBone].transform
t = t1.duplicate ()
t.prerotate (vVector)
-- put t
pArm.bonesplayer.bone[vBone].transform = t
end
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]