MD3 Animation In DirectX

Started by
6 comments, last by MeshMan 18 years, 10 months ago
Hi, I've been trying Quake3 MD3 animation for the past 2 days and I'm having really bad problems with the interpolation of the tags. A tag has a 3x3 rotation matrix which i convert to quaternions, do my SLERP and back to a matrix. But as yoy may know, the coordnate system in Q3 is Y on the positive Z and Z being positive Y. No matter what I try, i can't seem to make the rotations of the models happen in the right axis. Like my players head spins around the Y axis when it should be spinning on the Z. I tried swapping the Y-Z axis in the 3x3 TAG matrix before converting to quaternions but it just messes up the animation (it skews and flattens the model), and even tried swapping YZ on the final matrix but this sort of cancels out all the translations of the individual models (head, torso, legs). I cant even find any DirectX samples of MD3 loading and rendering. Can someine please help... Thanks, MeshMan
Advertisement
Why not just swap Y and Z on the final, transformed vertex position, before you put it through the world transform?

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

I've already swapped the YZ of the vertices when I load in the data to conform with my DirectX coordinate system.

I just can't figure out how to correct this rotation matrix into the correct coordinate system I need it in.

Still stuck...
SphereGames has an MD3 sample, written in Direct3D 8. However, it looks like the website's currently down. If it doesn't load for you, contact the author of the article by PM: VisualLR

I wouldn't swap the vertices at load-time because the rotations wouldn't be correct. Just tell the model system that Z is up and Y is forward, and at the last minute go "PSYCHE!" and swap them, just before you do the world transform.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

You can also find some md3 examples in directx at www.auscoders.com, they are quite complete and support all quake3 tags.
To convert a right handed matrix or vector to left handed or vice versa, you have to multiply your vector or matrix by this matrix:

1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1

If it does not work in the first try A x B try B x A. But you need 4x4 matrices. Extend your 3x3 matrix via transpose or invert.
I've managed to get round it by converting the matrices to D3D style matrices as I was already doing, then when I convert them matrices to quaternions, i just swap the Y/Z on the quaternions and my output is all perfect.

Screenies here:

www.meshsoft.net/dragon.jpg
www.meshsoft.net/md3.jpg

:)

This topic is closed to new replies.

Advertisement