Sign in to follow this  
deh0512

interpreting animations from .x files (in a custom parser)

Recommended Posts

A while back I wrote a custom parser for .x files in C# (in a preliminary effort for designing a custom file type). I know how to handle all of the information concerning a mesh from scratch. What I'm having problems with is the animations. I can read the data, but evidently there is some sort of pre-processing that I'm missing. I'm creating KeyQuaternion and KeyVector3 objects based on the input data (easy enough). Each AnimationKey in the .x file thus provides an array of KeyVector3 or KeyQuaternion objects as appropriate (there are no matrices in the files I'm using, although conversions should be fairly straightforward). I am collecting the arrays for an Animation and passing these arrays to the RegisterAnimationKeys method of a KeyframedAnimationSet object (seems logical, right?). I thought it should be that simple, but the outcome is not as expected. The model viewer that comes with the DirectX SDK plays the animations correctly, so apparently the data that is in the file is being altered before it gets put into the AnimationSet. I want to know what they're doing that I'm not. Does anyone have any experience doing this? Any ideas? And sorry there's no code, but it's not hard to visualize.

Share this post


Link to post
Share on other sites
To anyone whose interested, I've made some progress on my problem. I switched to the "tiny.x" example file that comes with the SDK and uses matrices to store the animations. So, when storing the animation keys, conversions to vectors and a quaternion have to be made. The simple part of my problem here could be fixed by normalizing the quaternion after the conversion is made. Using DirectX's native conversion method (Quaternion.RotationMatrix) is problem number two. DirectX (at least the Managed version) does not convert between matrices and quaternions correctly (some values are made negative when they shouldn't be... in the case that the diagonal or trace is greater than 0). So I had to write my own method (there are many quaternion tutorials on the internet that discuss this problem... for instance). The only other little piece of information to remember is that the scale vector has to be adjusted by the original length/magnitude of the quaternion. Then these values can be loaded into the KeyVector3 and KeyQuaternion objects, and from there the KeyframedAnimationSet...

When I finish figuring how to load animation keys specified as vectors and quaternions to begin with, I'll post that also. I would assume that the only problem there is that the quaternion isn't being normalized.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this