Help understanding 3D Models' initial rotations

Discussions regarding the development of the mod "Grim Fandango Deluxe"

Moderator: ScummVM Team

Post Reply
Nitrus
Posts: 177
Joined: Wed May 18, 2011 9:49 am

Help understanding 3D Models' initial rotations

Post by Nitrus »

So, I thought about taking another look at those pesky initial rotations which some models have, gatekeeper.3do for instance.

I took another look at cplhenshaw's converter, and I understood how the hierarchy works, quite similar to how a skeleton would work, e.g.: first you position the neck, and then you position the head on top of it, and so on. Only weird thing is sibling handling, I guess that works OK if you imagine sibling nodes being on the same level of e.g. a binary tree, making them have the same parent (while the parent is not referencing all the children).

But when it comes to rotations, I can't quite grasp them. For example, standard rotation around a pivot would include:

- translating to pivot point
- rotating

As cplhenshaw's converter already adds the pivot's offset to the mesh position, I guess the only thing left to do is rotate.

Now for the questions:

As I understand, Grim's rotation is:
- Pitch around X
- Roll around Y
- Yaw around Z

- Is this how it works originally, or is it this way to compensate for left handed / right handed systems in ResidualVM? (Direct3D / OpenGL)

- Are the values in the files (which seem to be degrees) already added to the models (so they would need to be subtracted, or rotated in the opposite directions), or are those values that we need to rotate the mesh with, in order to get to a coherent mesh positioning?

- Are the values cumulative by parent, or individual by mesh?
e.g.: neck rotation is: 90, 0, 0. head rotation is : 90, 0, 0.
Would we need to rotate the head by: 180, 0, 0?

Frankly, I've already got some code that executes rotation transformation on vertices, but I'm unable to get them right. Any insight would be appreciated.

P.S.: I tried looking at how it's handled in ResidualVM, but the inverted up-axis for Grim (or was it EMI?) and all the math which follows because of it is giving me a headache. :)
User avatar
JohnnyWalker2001
Posts: 405
Joined: Mon Oct 16, 2006 1:27 pm
Location: London, UK

Post by JohnnyWalker2001 »

Happy New Year! I hope you get an answer to this. (I'm sure Guicam or Somaen should know?)

I wish I could be of more help in this matter :-/
Nitrus
Posts: 177
Joined: Wed May 18, 2011 9:49 am

Post by Nitrus »

Happy New Year, and Happy Holidays to all of you :)

Actually, I took my own advice after writing this, and saw that there is a documented order and some other stuff I can borrow from in rotation3d.h, but I haven't had any time to check or apply it yet. I will post again when I have news, though I don't know when this will be.
User avatar
JohnnyWalker2001
Posts: 405
Joined: Mon Oct 16, 2006 1:27 pm
Location: London, UK

Post by JohnnyWalker2001 »

Great. Looking forward to it.
Post Reply