Search - User list
Full Version: Bone angle at different frames.
Root » Technical Discussion » Bone angle at different frames.
Tralen
Greetings,

I'm using the boneangle expression in my rig to drive secondary animation. It works fine, however, I would like to sample the angle between the two bones on different frames, once at frame 0 and again at the current frame, so I can work with the difference in angle between the setup pose and the current pose. How can I do that?


Thank for any help.
Tralen
I would like to add that I managed to get the effect I want by adding “ghost” bones that stay in the original position of the bones I'm measuring, that way I always have a reference for the setup pose. That is far from an elegant solution, however, and a better idea would be most welcome.
Stephen Bester
You could use a chf(“../boneangleparm”, 0) expression on another parm to get the boneangle expression at frame 0. Then subtract it from the current bone angle to get the difference. You could also use fit() on the difference to get a normalized value to drive shapes or other secondaries.

It might not be elegant for all situations, but it works in this case.
Tralen
Thank you, it worked beautifully!
Tralen
Here is a HDA which encapsulates the functionality. Given two bones, it will calculate the angles (absolute and relative to the reference frame), normalize the results given a min and max, and generate attributes for the values.

Edit: In the second (larger) file, I gave up using the boneangle expression because it didn't provide negative ranges, so I built another method with VOPs.
Stephen Bester
Thanks, that's cool.

Interesting how you're using the determinant of your constructed matrix to get a full 0 - 360 deg angle. I don't pretend to understand bit of the math, but it looks very useful!
Tralen
Hey, Stephen,

I don't understand that bit all that well, it is just something that I picked.

One more update to the HDA. I added functionality to deal with unpacked bones and moved all of the calculations to VOPs.

Here is something interesting and perhaps useful. I had to use the chf() function in an inline vop because there isn't a node for that function. To get the reference parm for chf() I had to split the VOP tree into two nodes, that way I could build an attribute for the parm in the first one, and then read it and build the parm proper in the second one. Trying to do both in a single tree generates an infinite recursion error.

Notice that chf() needs a string for its first parameter (the path to the reference parm), so I created a string parm for that, containing the path for the parm built previously.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB