Sign in to follow this  
DXnut

Soap Box Time: DX .x File and Animation Interfaces

Recommended Posts

DXnut    262
I am about to really speal here. I have been working on this since October, and am really frustrated. Soap box time.... I am writing a mesh modeling program. I can now create a mesh, skin it, and create animations from scratch and play those animations (one set at a time) in my own code and with the DirectX AnimationController and AnimationSet classes (where I can blend two together). I can also load an .x file (like Tiny_4anim.x) and play with the animations or create new ones. Yesterday I finally got the code to work to save it all to a .x file (though I haven't figure out how to work with custom data (or UserData in DX). I found a major flaw with the DirectX animation classes. If I load an .x file and play the animations using the controller returned by DX by the D3DXLoadMeshHierarchyFromX function, they play correctly. The controller knows to take the conjugate of the rotation quaternions in the Tiny_4anim.x file and to not do this with all others (not even the Tiny.x file in the other samples). In my code, I must also get the conjugate when creating the SRT keys for each frame when running the sets from the Tiny_4anim.x file. However, when I create the controller and set programatically, DirectX always takes the conjugate when running the animation, regardless of whether I am creating it from an animation I created or just recreating it from the same data from a .x file animation set that I loaded. So, if I were to do the conjugate of all the rotation keys used to create an animation set, DirectX would run the animations correctly. But if I then have DX save the mesh and animations to file and then reload the .x file, it will not take the conjugate and animate it incorrectly. For example, if I load the Tiny.x file, I can play the animation correctly without the conjugate, and DX plays it correctly. However, if I recreate the animation set (without changing anything) DX will do the conjugate when running the animation, and it does not work. In short, for loading a skinned mesh .x file DirectX knows to do the conjugate for only the animations sets from the Tiny_4anim.x file. When creating the animation sets programmatically DirectX always takes the conjugate. So, if I get the conjugate when creating the set to make it run correctly in DX, it will not run correctly when I save the data to file and reload it. Am I the first person to do this? All of the books and tutorials I have seen for DX animation only load a .x file and run the animations from that. It has taken me months to figure out how to go the other way and create it programatically. Even then, I find the .x file interfaces almost impossible to completely understand, since MS never documented them. Now, I find that the Animation interfaces are pretty much unusable for anything but loading and playing an animated mesh that was created in another program (like Maya or Max). Going beyond the basics that many books teach on DX is extremely difficult, since no one else writes any books on it, and MS only provides a reference manual. And when they try to do this (like John Adam's book on Advanced Animation with DirectX) MS changes the interfaces and makes the book worthless. Why they even created the animation controller and set classes is beyond me, since it seems they did so just so people could load and play with the animations in the two Tiny .x files they include with the SDK. I can't see how they created them thinking anyone would use them for any serious 3D development. So, I am thinking that DX's usefulness is pretty much limited to providing the HAL for hardware acceleration, and its biggest strength is with rendering polygons and HLSL. The .x file stuff is too difficult to use, and everyone writes their own home grown way of saving the data to file. The animation stuff is pretty much useless or too limited for serious use. Two MS MVPs on the DirectX MSDN forum also told me exactly this. I see a lot of people on this forum grappling with .x files, skinned meshes, and animation. From my expriences to date, I am exasperated and would recommend that you all give up on trying to understand it and develop the tools to do it yourself. Of course this flies in the face of what I and everyone else wants, which is a standardized file format and animation classes. It wouldn't bother me so much if there wasn't such an obvious flaw with the DX animation classes. This flaw makes me feel like I spent a lot of time learning something that is really useless. What really gnaws at me now, is that MS is spending millions to re-write Internet Explorer just so they can give it away, but they won't provide much needed and useful info for Windows programmers that want to learn DX.

Share this post


Link to post
Share on other sites
don    431
I would imagine that this is why most people write their own exporters using the SDK of their 3D modeling tools and store the data in whatever makes sense for their game's engine.

If it's any consolation, I've heard that the upcoming XNA framework may be more of what you're looking for. You can send feedback to the XNA Team at xna@microsoft.com.

There's also Collada: http://www.khronos.org/collada/.

Share this post


Link to post
Share on other sites
DXnut    262
So, in the end everyone writes their own unique private format for saving geometry and animation data to file and their own code to create animations and effects. So, trying to figure out how to load a skinned mesh from a .x file and how to use the ID3DXAnimationController and ID3DXKeyFramedAnimationSet interfaces is really a huge waste of time.

Doesn't the fact that the animation interfaces have such a stupid flaw with the rotation keys bother anyone else?

I am saying that I have gone the distance to figure out how to load .x files and create and play animations with the DirectX interfaces, only to find that it is seriously flawed. I would think that would matter to all of the people still trying to learn about them.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
With regards to other developers creating their own formats/exporters/tools, its a typical case where "one size fits all" doesn't really work. This is especially the case if you're targetting more than just Direct3D/Windows (e.g. the consoles).

If few professional developers use the library then there won't be so many calls for it to be fixed/changed/replaced (etc..) thus it will get a low(er) priority within the DX team.

Can't hurt to send your comments to directx@microsoft.com. They probably won't be interested in the rant part, but if you can break it down into specific examples and use-cases that are broken or could be improved that might help them.

I don't know what, if anything, will come of it but there were indications recently that the MS developers were at least thinking about the current X-file framework/library. Presumably with the intention of updating/changing it. Thus getting your feedback in may well make a difference [smile]

hth
Jack

Share this post


Link to post
Share on other sites
DXnut    262
Thanks. I am more concerned with the .x file stuff, because I see a need for a common format that can be used to get the data into a form that can be used the DX interfaces. I have emailed MS, using the feedback link in the DirectX SDK documentation, suggesting that a reference manual is not enough, and we need more info. I never even got so much as a form letter response. I would imagine that those emails go into some program that extracts key phrases and counts them. I doubt a person reads them.

I have also posted on the MSDN forum, where Wessam said that he would personally ask the DirectX team to provide more information on how the animation interfaces work. Nothing happened there either.

So, now they are working on DX 10 and XNA. I just hope that there is better documentation for them.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Quote:
Original post by DXnut
I have emailed MS, using the feedback link in the DirectX SDK documentation, suggesting that a reference manual is not enough, and we need more info. I never even got so much as a form letter response. I would imagine that those emails go into some program that extracts key phrases and counts them. I doubt a person reads them.
The documentation team is relatively small by comparison to the dev team - but they are real monkeys people. I've never received any direct reply (automated or otherwise), but I've had a few emails/chats with other people over at MS who've thanked me for sending in feedback.

Quote:
Original post by DXnut
I have also posted on the MSDN forum, where Wessam said that he would personally ask the DirectX team to provide more information on how the animation interfaces work. Nothing happened there either.
Sometimes the MVP's ask for stuff that can only be answered by the MS people, and if they're busy and don't get a chance to reply then neither can we. I'm sure it wasn't intentional on Wessam's part - although you could send him an email to check [smile]

Quote:
Original post by DXnut
So, now they are working on DX 10 and XNA. I just hope that there is better documentation for them.
Given that D3D10 is still very much "Work In Progress" now is the best possible time to hassle them with feedback... I'm not sure, but I think Vista Beta 2 will be public - which means you can get started on D3D10 stuff and check out what they've got. Drop some comments/questions in the beta newsgroup and send off as many emails as you want regarding the documentation...

That's what I was doing until Vista refused to work on my machine [sad]

hth
Jack

Share this post


Link to post
Share on other sites
QuadMV    168
Did you ever look at CAL3D? It's an open source library meant to work with DX, OpenGL, Windows, Consoles and MAC, and might already have many of the things you're looking for. I was planning on looking into it in more detail myself.

http://cal3d.sourceforge.net/index.html

Share this post


Link to post
Share on other sites
DXnut    262
Quote:
Original post by QuadMV
Did you ever look at CAL3D? It's an open source library meant to work with DX, OpenGL, Windows, Consoles and MAC, and might already have many of the things you're looking for. I was planning on looking into it in more detail myself.


No, I think it would a good idea for me to write my own animation stuff. I can already animate a single animation set (which I do in the creation process now before it is registered with DX). It would not be too hard to add events, callbacks for sounds, and blending to it.

I am also going to look into the FBX format that Autodesk products use. I downloaded the SDK for it a while ago and will see if I can understand it. Then I can decide if it is a good idea to try to convert it to the .x file format or just write a loader program that will read the FBX file and create the DX interfaces from it.

My goal with the modeling program I am writing is to provide .x file format support for creating new meshes and animations and possibly converting from other formats. However, the flaws with the animation interfaces make me wonder now why I should even care about the .x file format, being that the D3DXLoad.... function creates and returns the ID3DXAnimationController with all of the animation sets registered and ready to play with DX animation.

TY

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