acmclellen at January 13th, 2004 08:57 — #1
I've been looking for 3 days now and just haven't been able to get any closer to solving the problem I've been trying to solve. I've been able to display in my app, using DirectX 9.0 and c#, the model exported from 3D studio max in .X file format. But now I'm trying to get the whole animation thing going and I know the .X file has animation cause I've actually just used the .X file that has come with the ...\DX90SDK\Samples\C++\Direct3D\MultiAnimation app. I've tried to follow what they've done in the example...but it's a bit too hectic...surely there must be a simpler, easier example to follow to get my model to animate. Please, if any one could direct me to a more simpler example related to animation and .X files uisng DirectX, I'd really appreciate it. I've looked on flipcode, gamedev.net, and a quite a few other game programming sites but with no success in finding what I'm looking for.
anubis at January 13th, 2004 09:18 — #2
afaik the dx sdk examples are relatively well written...
anwys, i'm not sure if you can find information there but devmaster hosts a site called tripplebuffer. it's a site dedicated to directx deving, so i'd check it if i was you. hmm, probably bladder will even answer you here if he's around...
bladder at January 14th, 2004 22:53 — #3
There is a much simpler example that comes with the sdk then the multianimation one. Look for the SkinnedMesh app. That just loads in a single character and animates that one.
To make things easier for yourself, Id suggest you first learn how to parse X files and build a frame hierarchy of the object. I also suggest you read the SDK docs over and over until they start making sence. I remember when I first started trying to figure out X files it took me months to get something animating (yes months, Im that stupid). In the SDK docs you should check out:
DirectX Graphics -> Programming Guide -> Getting Started -> XFiles
DirectX Graphics -> Reference -> X Files.
Technically everything you'll even need to work with X Files is within those pages. Once you understand how an X Files works internally, then loading/parsing them starts to become more clear, which makes getting animations data easier. When you start reading you wont necessarily understand whats said until you've read everything and are going through the second time though.
acmclellen at January 15th, 2004 06:12 — #4
Thanks for the replies...much appreciated. I've looked at the references you guys gave. The thing is, I'm not trying to learn how to parse an .X file, cause I'm using the Mesh.LoadHierarchyFromFile function to load the .X file and I assume this function loads all the animation too. What I need is a simple example using X files and the AnimationRootFrame.AnimationController.AdvanceTime function to figure out how to get my model animated. The SkinnedMesh example is gr8, but doesn't have the code related to animating animated models loaded up from an .X file. I hope I'm making sense. Any suggestions, tips, references, etc. would be much appreciated.
Thanks in advance.
bladder at January 17th, 2004 07:47 — #5
Sorry man, I wish I could help with managed DX, but cant. I dont think Ive seen any small samples other then the ones that come with the SDK. However, have you downloaded and installed the summer update SDK? It comes with a major improvement in the managed directx documentation. You'll probably find the answer you're looking for in the docs somewhere.
acmclellen at January 19th, 2004 02:07 — #6
I've looked all over and can't seem to find anything. And yes, I do have the summer update SDK. Thanks anyway for your time and effort replying...it's much appreciated. I've tried working from the C++ MultiAnimation sample...will persist.
phlaz at June 30th, 2004 02:16 — #7
I've just been through exactly the same process. The DX sample is cryptic to say the least but I spent a few days working through the code until finally I understood it with the help of a tut on gamedev. Unfortunately the site is down at the mo so I can't post the link but its called "Working with the DirectX X File Format and Animation in DirectX 9.0". I'll endeavor to explain how I understand it.
Calling the AdvanceTime function will automatically update the TransformationMatrix member of every frame in the heirarchy. You then need to update the array of matrices which represents the mesh in its current animtion state. This is done by setting each frames CombinedMatrix to the TransformationMatrix multiplied by the frames parent CombinedMatrix. Once this has been done the MESHCONTAINER object has a member, ppBoneMatrixPtrs, which points to all of the frames CombinedMatrix members so you don't need to iterate through all the frames again to use them. So, once you have the updated state of the mesh matrices you loop through all of the bones in the mesh, which will be equal to the number of frames and thus there'll be one ppBoneMatrixPtrs element per bone, and multiply this matrix by the bone offset matrix, pBoneOffset. This transforms into the bone space. The result of this matrix multiplication is stored in each element of the Application member m_pBoneMatrices. Its then just a question of locking the meshes vertex buffer and calling UpdateSkinnedMesh, passing the m_pBoneMatrices array so it can transform the vertices correctly. The mesh vertex buffer will now hold the new mesh data to represent the mesh in the current frame of animation.
Reading back on what I've just written it seems just as complicated to me lol. Also I see now the date of your post so may already have figured this all out by now. But anyway I know what a pain it is trying to understand this reasonably complex topic so I thought I'd contribute. Hope this helps. Oh btw, I did this all in C++ so I'm not sure how much different the C# implementation is.