• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Correctly rotating a bone ?

Status
Not open for further replies.

Ardenian

A

Ardenian

I would like to finally receive some enlightening about the rotation of a bone.
I tried and tested, but I don't get how it works.
I played around with it, but eventually my model started strangely scaling itself
and moving not as supposed from the values I entered.

Could someone please be so kind and explain rotation in Magos to me, please ?
( None, Linear, Hermit, Bezier, using radient or degree)

An example could be rotating an object 360° around itself.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Rotations are expressed as quaternions, 4d vectors that represent points on a hyper sphere.
The group of all normalized 4d vectors (a vector with a length of 1) can be used to represent rotations in 3d space.
They are used instead of eular angles (e.g. a triple of X, Y, and Z angles), because they cause no messy things like gimbal lock, and they can be very easily interpolated to smoothly rotate from some quaternion A to some quaternion B (the operation is called slerp, or spherical linear interpolation, if you care).

That being said, you don't really need to know how they work, just use some angle converter.

If you experience scaling, shearing, or all sorts of weird effects, it means your quaternion isn't normalized.

The None/Linear/etc. option is interpolation.
Suppose you have your bone at position A at frame 0, and you want it to go to position B over 10 frames.
You could change the object position's every frame manually, but that's a lot of boring work.
Instead, you can tell the object that in 10 frames it's going to be at point B, and let the computer calculate where the object is in every frame in between.
This is called interpolation.
There are all sorts of way to let the computer figure where the object is.
Linear interpolation means the object moves at a constant velocity.
For example, if you move over 10 frames 10 units, then every frame the object will move 1 unit.
Bezier/Hermite interpolations are more complicated, and allow you to define a curve that effectively determines the object's speed at any point in the animation.
This is used to make animations more "lively" and not seem like your objects are all robots, moving at the same exact constant velocity.
For example, if you are animating a human rotating his head, most humans don't rotate their head at some constant speed, that will look really odd! instead you start rotating slowly, accelerate, and then slow down upon reaching your target.
That's the kind of stuff you can do with curves.

As to radians and degrees - they are just different ways to express the same things.
360 degrees is equal to 2*pi radians.
180 degrees = pi radians
90 degrees = 1/2*pi radians
etc.
All trigonometry functions use radians, all circle equations use radians, etc.
 

Ardenian

A

Ardenian

Thank you, GhostWolf!

So we need to use radians, since we have circle equations.

But why does this not work ( Linear):
Code:
1: { 0, 0, 0, 1 }
500: { 0, 0, 6.283, 1 }
1000: { 0, 0, 0, 1 }
Shouldn't this rotate my bone in 0.5 second once around itself and in the following 0.5 seconds back ?
It strangely scales my mesh instead ( I used a simple plane and added rotation to its bone).

What is this {x,y,z,1} at the end ?


Could you please, if you don't mind, give some more information and usage example to Bezier and Hermite ?
You already said it has a different speed than Linear.
Is Hermite fast in the beginning and Bezier fast at the end or the other way around ?

How do I correctly enter values there ( upper line, InTan, OutTan) ?
I assume it has to do with the speed and the rotation itself,
the upper line next to the key frame is most likely the rotation,
but what to enter/how to use InTan and OutTan, how do I know what to enter ?
 
Actually if you want an object around it self you might have to use more than those three key frames.
Code is in that case is 'stupid' and does not know where to go when it reached the 180 degree mark. It might go back and might go further on the rotation.

Code:
1: { 0, 0, 0, 1 }
500: { 0, 0, 6.283, 1 }
1000: { 0, 0, 0, 1 }

You might wanna use this kind of process, rotating around like a compass would do. Also you CAN use the keyframe '0'. That way you have exactly 1 second of animation, not just 0,999999... seconds.

Code:
0: { 0, 0, 0, 1 }
250: { 0, 0, 0.707107, 0.707107 }
500: { 0, 0, 1, 0 }
750: { 0, 0, 0.707107, -0.707107 }
1000: { 0, 0, 0, 1 }

Explaination:

0: Rotation start - no rotation.
250: 90deg rotation
500: 180deg rotation
750: 270deg rotation
1000: Rotation start - no rotation.

That way you have a clearly defined rotation.
 

Ardenian

A

Ardenian

Ah, that works like a charm, thank you!

Though, how can I construct this myself ?
0.707107 is 1/4*PI, but what is the other number, at the end ?
Why do I set for 180 degree rotation the z value to 1 ? Shouldn't it be 1,57, as 1/2*PI ?

Seems the last number is if rotation or not, but what is the difference between Z value and that last number ?
Direction ? What if I would rotate around multiple axis ?

I don't understand the relation to the last number.
 

Ardenian

A

Ardenian

Could you link it please ?
I googled it, but I cannot find it.
 
Level 22
Joined
Sep 7, 2013
Messages
235
As Ghostwolf said, these are Quaternions. You could google that word and see that it is a mathematical object that has interesting properties, but since it's 4D it's not really human-readable so you need some converter.

I once made this excel sheet to calculate quaternion for the rotation along any axis and angle, you can try it.

If you wish to animate though, i suggest you try Mdlvis instead of Magos, it allows you to animate bones much more easily with a graphical interface.
 

Attachments

  • QuaternionCalculator.zip
    6.7 KB · Views: 49

Ardenian

A

Ardenian

Ah, thank you, that's handy!

I had a problem with Mdlvis though, it kept scaling the mesh in the past.
Dunno, nowadays I enjoy the text editor more, it is cleaner and allows easy editings.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Like I wrote in my previous message - if you get scaling/shearing/whatever, it's because the quaternion isn't normalized, or in other words, its length isn't equal to 1.
In your case it's clearly larger than 1, since the z value is 6.283.

Again, quaternions are NOT euler angles, writing 2pi in the z axis isn't the same as rotating 360 degrees on the z axis.

About interpolations - the out/in tangents are tangents to the end points of your interpolation, and they define how the curve looks.
I realize this probably means nothing whatsoever to someone that didn't already handle animation curves, so here's an animated gif from BlinkBoy's animation tutorial:

51917-depth-animation-tutorial-3ds-max-curve-editor2.gif


The curve defines the speed of the animation over time.
The three points are your keyframes (rotation, translation, scale, or whatever data you want).
As you can see, each point has two additional points that control how the curve ends up looking, those are your tangents.

Both bezier and hermite interpolations are exactly the same usage-wise. As to the shapes they produce and differences, I don't know. You can search if you want.

Just as an addendum, if you really want to know why the numbers don't necessarily make sense to you, you can read this.
 

Ardenian

A

Ardenian

Thank you guys, I am going to try it and see how it works!
 
Status
Not open for further replies.
Top