PDA

View Full Version : Flippingless rigs, Euler, Matrix and Quat theory (Tutorial)


phoelix
08-19-2009, 06:08 PM
Hi there!

I have made a tutorial about how to deal with flips that happen in some rigs like shoulder twisbones. It also has some concepts about the math behind the 3d transformations.

Here is the link:
http://joleanes.com/tutorials/flippingless/flippingless_01.html

see ya

Leffler
08-19-2009, 10:30 PM
Great stuff, thanks!

Boucha
08-20-2009, 01:51 AM
Thanks for the share phoelix...:beer:

eek
08-20-2009, 05:35 AM
Hi there!

I have made a tutorial about how to deal with flips that happen in some rigs like shoulder twisbones. It also has some concepts about the math behind the 3d transformations.

Here is the link:
http://joleanes.com/tutorials/flippingless/flippingless_01.html

see ya


Pretty cool man, i do the exact same thing - but a little more convoluted, using slerp an few matrices. Once you understand this you can use it everywhere for handling complex twist stuff. Im gunna see if i can use your method instead.

shalabology
08-20-2009, 05:39 AM
it s precious , no way it really added to me especially regarding to matrix issues , great thanks for sharing, also liked the other stuffs in the site and the gallery.

BadSpleen
08-20-2009, 08:04 AM
:beer:

What more can I say.

phoelix
08-20-2009, 03:04 PM
Hi guys, I'm glad that you like it. If you have any question about the tut don't hesitate to ask me here or by email.

Pretty cool man, i do the exact same thing - but a little more convoluted, using slerp an few matrices. Once you understand this you can use it everywhere for handling complex twist stuff. Im gunna see if i can use your method instead.
it'll be very interesting to hear more about your method eek, i struggled a lot to figure out this solution, it would be nice to know other ways to deal with this :D.

anfes3d
08-20-2009, 05:03 PM
Thank you Phoelix

eek
08-20-2009, 06:40 PM
Hi guys, I'm glad that you like it. If you have any question about the tut don't hesitate to ask me here or by email.


it'll be very interesting to hear more about your method eek, i struggled a lot to figure out this solution, it would be nice to know other ways to deal with this :D.

I basically build a quaternion using a set of matricies that are interpolated as rotations - summing them up into a complete rotation. I call it a 'Cradle' because using it with copies of itself you can basically simulate most of the bodies rotation issues.

Mine's actually a little different to your's i think.

IkerCLoN
08-20-2009, 09:13 PM
Those are beatiful bits of information, Félix. Thanks for sharing them with us :)

Duncs
08-21-2009, 12:35 PM
This stuff is Gold - It will make a big difference to my rigging.

Thanks for sharing...

phoelix
08-23-2009, 07:01 PM
It's great that you found it useful guys!, i'll be publishing another tutorial about some related topic soon...


I basically build a quaternion using a set of matricies that are interpolated as rotations - summing them up into a complete rotation. I call it a 'Cradle' because using it with copies of itself you can basically simulate most of the bodies rotation issues.

I have to digest this, sounds interesting ...


Que tal Iker hace rato que no te veo en el msn :(

ShadowM8
08-25-2009, 01:05 AM
Interesting stuff.
I read through it best I could, but not having access to 3ds max I can't really check how it behaves :( it would be nice if you could record a video showing the range of motion possible with this solution.

Having spent a significant amount of time working out a solution for this issue I am not quite sure the solution you presented for twist bones would be robust enough especially for the shoulder. The two requirements of any solution would be to accurately resolve the true twist value around the twist axis and allow for as much range of motion as possible before any sort of flipping (preferably =- 360 in any axis).

Building the look at constraint using a quaternion on the other hand is super handy for a lot of problems. In fact it could actually be used as a base to solve the twist bones rotation in the shoulder (and elsewhere really) since the shoulder mechanic is basically a look at with no spin around the direction axis.

Looking forward to seeing a video.
Thanks for sharing.

spacegroo
08-25-2009, 01:44 PM
Excellent stuff. Thanks for sharing. And now I know a use for XYX axis ordering.

I'd also be interested to see Eek's method, as I've slowly been absorbing matrix math over time.

phoelix
08-25-2009, 02:27 PM
hi guys, thanks for comment.

Having spent a significant amount of time working out a solution for this issue I am not quite sure the solution you presented for twist bones would be robust enough especially for the shoulder. The two requirements of any solution would be to accurately resolve the true twist value around the twist axis and allow for as much range of motion as possible before any sort of flipping (preferably =- 360 in any axis).
i suggest you to try that solution. With that method you will get the same behavior as using a quat to build the rotation for the twist bone, i included the XYX method in the tut because it was another way to deal with that issue having exactly the same result, i dont know what method is less expensive, but both can be used in different cases depending on the situation.

at the end of the second page of the tut there is a gif animation of a rig that has the quat aim on it, the XYX method will behave just like that while inheriting the orientation of a bone.

PEN
08-26-2009, 12:19 PM
Nice work and a well layed out tutorial.

As for speed any time you are doing complex math it is going to slow it down. Slerp is one of those but you can get tricky and cheat the math by using linear interpolations instead of a curve. Might not be quite as accurate how ever but probably close enough.

In looking more closely at your solution I see that you are using normalize, acos and cross and all of these will slow things down. Nice solutions and I think that the math is as fast as it will get. I have tried writing simpler math solutions in Max script but it usually turns out to be slower then the C++ complex math. I want to try and use dotNet for this one day and see if using system.math will allow for faster calculations. Not sure it will as just converting the values from Max script to dotNet might slow things down.

PEN
08-26-2009, 01:19 PM
Never mind. I just tried a simple test with a distance function as it uses a square root. As you can see the conversion is killing it. Maybe it if was something that used a set of numbers and had to do a pile of calculations on them it would be faster but if you need to keep converting it is way slower. Just look at the times that I had returned.


p0=[0,0,0]
p1=[10,10,10]
numTests=1000000

st=timeStamp()
for i = 1 to numTests do distance p0 p1
format "Time: % sec\n" (((timeStamp())-st)/1000.0)
--0.6 sec

st=timeStamp()
for i = 1 to numTests do sqrt ((p1.x-p0.x)^2+(p1.y-p0.y)^2+(p1.z-p0.z)^2)
format "Time: % sec\n" (((timeStamp())-st)/1000.0)
--4.5 sec


math=dotNetClass "system.math"
st=timeStamp()
for i = 1 to numTests do math.Sqrt ((math.pow (p1.x-p0.x) 2)+(math.pow (p1.y-p0.y) 2)+(math.pow (p1.z-p0.z) 2))
format "Time: % sec\n" (((timeStamp())-st)/1000.0)
--99 sec

phoelix
08-26-2009, 02:30 PM
Hi paul, thanks for comment! , i haven't used the dotnet math before but now that i see your tests i'm not willing to use it. It seems that the fastest maxscript calculation is always the one that is done in only one compiled function, well... depending on how it was programmed.

i have made some test with the quat lookat and the standard lookat constraint and i have got this results:

40 bones with scripted quat lookat
Average of 25 fps

40 bones with standard lookat constraint
Average of 31 fps

made in a machine with the following specs:
intel xeon 2.0 GHz
2.0 GB ram
NVIDIA Quadro FX 570

the scripted controller is always more expensive than constraint, but having a better setup worths the sacrifice. finally it depends on the purposes of the rigger, and if the rigger wants to avoid this kind of issues he or she has to face some kind of complex setup that will be more expensive anyway.

I am thinking about programming a quat lookat controller in C++, it surely will be as faster as the standard lookat constraint. As soon as i have some free time i will be working on that.

eek
09-02-2009, 04:18 PM
Hi paul, thanks for comment! , i haven't used the dotnet math before but now that i see your tests i'm not willing to use it. It seems that the fastest maxscript calculation is always the one that is done in only one compiled function, well... depending on how it was programmed.

i have made some test with the quat lookat and the standard lookat constraint and i have got this results:

40 bones with scripted quat lookat
Average of 25 fps

40 bones with standard lookat constraint
Average of 31 fps

made in a machine with the following specs:
intel xeon 2.0 GHz
2.0 GB ram
NVIDIA Quadro FX 570

the scripted controller is always more expensive than constraint, but having a better setup worths the sacrifice. finally it depends on the purposes of the rigger, and if the rigger wants to avoid this kind of issues he or she has to face some kind of complex setup that will be more expensive anyway.

I am thinking about programming a quat lookat controller in C++, it surely will be as faster as the standard lookat constraint. As soon as i have some free time i will be working on that.

Yep same here, i just got a 60 line function down to 6 lines. :)

zzama
09-03-2009, 09:39 AM
now i wonder...how could i constraint another twist bone that gets the x rotation half from the upperarm and half from the first twist bone
Flippingless, of course
thanks

PEN
09-03-2009, 12:41 PM
Use a Expose Transform helper to expose the values for the non-fllipping twist bone and drive the new one with the local X rotation value.

phoelix
09-03-2009, 01:51 PM
or you can use the orientation constraint

zzama
09-03-2009, 07:40 PM
i had already tried that both solutions, but the "middle" twist bone flips when x rotation reaches +/- 180 degrees

phoelix
09-03-2009, 10:01 PM
well... that flip is another deal.. it has to do with the average constraint within both, the twistbone and the upperarm, and as far as i know the only way to avoid that with the standard tools in max is only using a FK hierarchy in the arm, you can't use ik if you want to avoid that flip because you will need to extract the euler X rotation to get a cumulative rolling value from the arm. a character will never roll its arm more than 180 degrees from its resting pose anyway (humans can only reach 90 degrees), but if the character is a cartoony freak that needs to do so, you can use another setup that triggers in that moment and make use of the fk hierarchy of the arm to extract the rolling value.

zzama
09-04-2009, 09:26 AM
thanks
i don't like to use euler controllers in joints like elbow, wrist etc.. because of the gimbal lock and i use quat rotation (TCB)
it seems that in that case nonflipping middle twistbone should be somehow history dependent i guess :curious:

anoopak
09-06-2009, 11:19 AM
Thats pretty much interesting discussion going on here guys.Thanks phoelix for this amazing tutorial

eek
09-06-2009, 04:27 PM
thanks
i don't like to use euler controllers in joints like elbow, wrist etc.. because of the gimbal lock and i use quat rotation (TCB)
it seems that in that case nonflipping middle twistbone should be somehow history dependent i guess :curious:

I have most animation controls as euler, wrists, elbows, hips etc but most importantly I build a quaternion through script that uses these controls to drive it, an in turn build a rotation from.

This way as phoenix and I , discussed you don't get the flip past 90 degrees, so you could rotate the wrist more than 90 degrees to one side then twist it in that direction and it would still drive the twist down the forearm correctly with no popping etc.

The caveat of this is that its a natural system, its a real-world setup. Our wrists, shoulders, thighs,spine tend to hit a combined rotation of 180 degrees, be that in one direction or many. For example if you rotate your hand forward say 90 degrees the actual twist of forearm is still 0, now if you rotate your hand to the left you've actually twisted the forearm 90 degrees - your see this if you rotate your hand up. You've twisted the forearm about 90 degrees. This is really important to know because you haven't purposefully twisted the forearm - its twist based on the direction of the hand.

Why does this happen is due to structural kinesiology, basically its a fail-save to stop your joints from popping/tearing out of their sockets.

This is why rotation is sort of disingenuous, its really a direction and a spin about that direction.

Going beyond 180 degrees in one direction is possible - one way is to use dirac's quaternion belt-trick. But this is better used for things like tentacles and such.

CGTalk Moderation
09-06-2009, 04:27 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.