PDA

View Full Version : Expressions and gaining data from IK and Constraints


Muhneer
11-01-2005, 10:06 PM
Hi,

At the moment i am working on a robot animation.
In this animation i like to have extern engines which rotate 3 times faster as the
joint does. So i read the rotation values of the different robot parts so i can multiply
those and assign to the engines.

I have a bones structure with a IK solver.

When i trie to read the rotation values of the different bones i get no values.
I red on this forum that its impossible to read the values of an IK.

So i tried to use a "look at" constraint which looked at the child joint, the dummy
object rotated so i tried to read with an expression so i could multiply it by tree.
But once again it seems that i cant get info from the dummy.

Which route should i take to get rotation info from objects in a bones/Ik situation ?
The same question but now regarding to a look at constraint.

Is there someone who could point me into the right direction ?

http://www.muhneer.nl/3D/vray_robotic_7.jpg

Thx in advance.

Aearon
11-01-2005, 10:11 PM
if you're using max7 or higher you can use the new expose transforms helper to get at those values

otherwise i'd use a script controller instead of an expression controller

Muhneer
11-01-2005, 10:37 PM
Thanks! that was what i needed.
Im going to take a look into script controller.
Thats an interesting bit.

Aearon
11-02-2005, 06:14 AM
here's a simple trick to get the rotation values of one object in relation to any other object using a script controller:

(this gets the rotation of the 'forearm' in relation to the 'shoulder'
in coordsys $Shoulder $Forearm.rotation.z

at least i think this should work ;)

Kenzor
11-02-2005, 08:27 AM
you can also look at the transform matrix directly

so the shoulder transform in the world is $shoulder.transform
its position is $shoulder.transform.pos
It's rotation is $shoulder.transform.rotation

then if you want to get the transform of the forearm in relation to the shoulder use..

(forearm.transform * inverse shoulder.transform)

the postion would be ..

(forearm.transform * inverse shoulder.transform).pos

and the rotation ..

(forearm.transform * inverse shoulder.transform).rotation

Personally I find this method a bit bit more reliable than 'In coordsys'

PEN
11-02-2005, 12:21 PM
Kens method is the one that you should go with. Multiply the matrix of the object by the inverse of it's parent to get the parent space matrix of the object. Then you can get the rotation values that you need from it.

Are you using Max 7 or higher then definitly just use the Extract Transform Helper. I designed this tool just for this reason and asked them to impliment it. This means that you could just wire to the values that the ExTm helper extracts.

PEN
11-02-2005, 12:27 PM
You should also note that the .rotation suggestion in Kens post will get you a quaternion value and not an euler XYZ value.

You can use quatToEuler quatValue to convert it so you would be looking at something like this.

(quatToEuler ($forarm.transform*inverse $shoulder.transform).rotation).z

this would return the euler Z axis rotation values from the forarm.

Muhneer
11-02-2005, 03:28 PM
thanks so much for the replies.
Im going to try that way also.

I'll post my findings here when i got the time to try it.

Have a nice day..

CGTalk Moderation
11-02-2005, 03:28 PM
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.