Modcraft - The community dedicated to quality WoW modding!

Content creation => Modelling and Animation => Topic started by: spik96 on June 07, 2015, 09:15:33 am

Title: [SOLVED] [BUG] In the last anim, the model is rotated !
Post by: spik96 on June 07, 2015, 09:15:33 am
Hi !

I have a model, and when I watch it with MDLVis, every animation works perfectly fine except the last one is turned 90° on its side.
Do you know what cause this and how to prevent/fix it ? Something must have it's coordinates flawed but I don't know what...

MDLVis : http://i.imgur.com/V17qaVk.png (http://i.imgur.com/V17qaVk.png" onclick="window.open(this.href);return false;)
Exported as MDL : https://gist.github.com/Koward/7d3bdbc6f0633c8981ab (https://gist.github.com/Koward/7d3bdbc6f0633c8981ab" onclick="window.open(this.href);return false;)

EDIT : I think it could be some problems with the quaternions used for rotation. The problem is a rotation of -90° around Axis Y and a rotation of -90° around Axis X in the last animation.
Example : while a vertex is "normally' at (12,0,9), it becomes (9,12,0). I want it to stay like he is...
I don't have yet the math knowledge to understand what this means for the values in a quaternion.
I can learn it, but it will take time and if someone had an easy way that would be handy.
EDIT 2 : It seems I was wrong. Even when I put rotations to (0,0,0,0), there still is this little rotation. Damn, if I fix this bug my work will almost be done !

As I work on this while working on my LK>BC converter, I really wonder how a special animation can be affected and if the rotation handling changed between the two expansions.

EDIT Piaf : Solved, see my last post for information.
Title: Re: In the last anim, the model is rotated !
Post by: spik96 on June 09, 2015, 02:46:47 pm
So, nobody could see a reason for this behaviour ? I'm struggling ><"
I guess I'm alone on this one then ;(
Maybe I should also try WC3 forums, this is their software after all, someone there may know what causes this.
Title: Re: [BUG] In the last anim, the model is rotated !
Post by: phucko1 on June 09, 2015, 05:19:22 pm
Well first; How did you convert the model to mdx?
Title: Re: [BUG] In the last anim, the model is rotated !
Post by: spik96 on June 09, 2015, 06:25:34 pm
I converted the model from M2/LK to M2/BC with my own program and MDLVis is able to open these models directly. Then, I can save it as an MDX or MDL.

I know the fault is in my program. It's obvious. When MDLVIS reads the original models even the last animation is perfectly good.
 I'm just trying to find which component is failing (a bone, flags somewhere giving the orthonormal, 3D Witchcraft) and find a way to fix it.

Maybe I should try to convert the LK model to mdx using an other way, then compare the files to see what's wrong with mine ?
Title: Re: [SOLVED] [BUG] In the last anim, the model is rotated !
Post by: spik96 on June 10, 2015, 01:38:39 pm
Okay, I solved my bug.

The quaternions in standard mathematics are (w, x, y, z) with w€R, x,y,z€C
In Blizzard models, they are (x, y, z, w). Since Warcraft 3. It should be mentioned on the Wiki. If it is, I have not seen it.
Sometimes I need to connect the last timestamp to the end timestamp, so I added one. By default, it's zeros.
It works perfectly with translations and scalings because they are 3D. (0,0,0) is fine.
Rotations are 4D and their rules are different. And the neutral is (-1, 32767, 32767, 32767), as they are 16 bits quaternions.
But this is a Blizzard model, so I have to add (32767, 32767, 32767, -1). F*cking fourth dimension.

More information about quaternions here : http://en.wikipedia.org/wiki/Quaternion (http://en.wikipedia.org/wiki/Quaternion" onclick="window.open(this.href);return false;)
And an excellent book (which was fortunately in the library of my university, contains a lot of examples but mainly for physicists, I clearly did not understood everything x) ) : http://www.amazon.fr/exec/obidos/ASIN/0 ... rtinb06-21 (http://www.amazon.fr/exec/obidos/ASIN/0691058725/martinb06-21" onclick="window.open(this.href);return false;)

That's the strangest issue I have ever solved myself.
At least now, my frog is perfect in MDLVis.