Skip to main content
gamedev.net
🔒 Locked

DirectX File Format & KeyFrames

Started by adder_noir Jun 24, 2010 at 6:34 PM 11 replies 3.6k views
Original Post
adder_noir
adder_noir
Hi!

Quick one guys and girls. Looks like I undrestimated how difficult it really is just to get a 3rd party application (3DS, Maya, Blender etc...) made model into DirectX. Seems there are no proper or reliable exporters around at all. I even heard £2000+ 3DS Max copies don't export directly into .x files!!

So it looks like I'm going to have to write some conversion code myself. I've got access to alot of .p3d files which I do have the file format for. I asked on a more code orientated forum they said they believed conversion is entirely possible.

However. With regards to animations stored in DirectX files I am a bit worried. Is it only the keyframes that are stored in .x files or is there some kind of 'extra' matrix information containing intermediate position data between keyframes? If I wrote conversion software would I only have to copy the keyframe data or is it not so simple?

I hope very much DX9's animation controller can just extract keyframes and do the interpolation itself but as I say I don't know if it's that simple.

Could use help here thanks ;o)
Steve_Segreto
Steve_Segreto
The DX9 animation controller can interpolate between 1x4 quaternions or 4x4 matrix rotation keyframes and also 1x3 scale and 1x3 translation keyframes.

Search for "AnimationSet" to see how to describe your keyframe data in the X file format.

I think a bigger problem will be the way your modeling program exports the animation. Most of them store the animation data internally in opaque ways (TCB splines, axis-angle rotations, packed quaternion rotations, etc), and you need some way to sample the animation at fixed intervals and pull out the scale, rotation and translation information at each frame and write it to the X file, which can only accept a small percentage of the many ways to store rotations and translations.
adder_noir
adder_noir
Well I coudln't have asked for a better reply than that. That's very detailed indeed. thanks.

Makes me wonder how to proceed though. Exactly what data is stored in a keyframe? Is it a complete vertex by vertex description of the model's transformation and rotation at that point or is is just a load of rotation and translation matrices for the joints?

If it's just a load of joint data can I manually extract this to then input the keyframe manually into the .x file and leave it up to the animation controller to interpolate? I think my game physics book can show me how to get a quaternion back into a 4x4 matrix too so might have that angle covered.

Crazy stuff. You'd think it would be easier than this to get models in game, especially when you're prepared to actually *buy* software!

I guess as you say the most important thing now is to work out how to extract joint data from an exported animated mesh. Great. Should be a piece of cake. I'll see you early in July...... - next year ;o)
Steve_Segreto
Steve_Segreto
First thing to remember is there are 3 general types of keyframes (Scale, Rotate, Translate) and they operate on a particular joint (a.k.a bone, a.k.a frame) at a particular time value.

Within each of the 3 keyframe types the representation varies quite a bit for at least the rotation keyframes. They can be represented and correctly interpolated by x-files and animation controller as 4x4 S,R,T matrices or 1x4 quaternions (rotation only).

Perhaps the modelling software refers to the target joint for a keyframe by index or by textual name (or even by pointer address), so this might be a tricky first step.

Good luck!
adder_noir
adder_noir
Ok thanks! Maybe if I can get blender to export an animation I can find out what the keyframe data is. Then if I make the model in Milkshape and export it I can load the keyframes into this .x file. It can be done even in notepad.

Blender borks the materials, whilst Milkshape borks the animations on export. Great ;o)

Thanks Steve ;o)
Anddos
Anddos
so cant the panda exporter export animated meshs correctly?, i have no trouble with static meshs
:)
adder_noir
adder_noir
I wasn't even aware of such a thing! Maybe I'm getting tunnel visioned by being over-sensitised to this issue. I think I might be.

I'll check out that Panda thing. Thanks ;o)
Steve_Segreto
Steve_Segreto
There's a big difference between static meshes and skinned meshes. First of all static meshes generally only have Position, Normal and U,V coordinates in their vertex declaration, while a skinned mesh adds blendweights and blendindices and is frequently sub-divided into "skin partitions" to keep the number of blend weights per bone less than or equal to 4.

While technically both kinds of meshes can be represented in a hierarchical scene graph format (which is precisely what the X-file is), skinned meshes usually also have keyframes associated with some of the transformation frames (bones/joints).

So for loading/rendering in a 3-d program it is often possible to optimize a static mesh by transforming all the vertices by their "toRoot" matrix to flatten the static "skeleton" so to speak, this is not possible with a skinned character mesh because animation ceases to function.

I was also aware that Panda worked fine for static meshes (which are trivial), but I was unaware it worked for skinned meshes.
Anddos
Anddos
I am not 100% sure it works for skinned meshs but i cant see why it would'nt
:)
samster581
samster581
Quote:
Original post by adder_noir
So it looks like I'm going to have to write some conversion code myself. I've got access to alot of .p3d files which I do have the file format for. I asked on a more code orientated forum they said they believed conversion is entirely possible.


What are .p3d files?

adder_noir
adder_noir
They're old files from the game Operation Flashpoint. Even if I can get access to them I still can't actually use them for anything as they were made by other people and there's legal issues. I did suggest paying their authors so I could use them but it's just easier to download stuff from Turbosquid - which is what I've decided to do.

I'd just like now to extract them as an academic exercise to improve my coding skills. Also they would be a great reference when making my own models to help guide me through tricky bits. It'd be nice to see how some people made some of the great things they did.
CPPNick
CPPNick
Sorry I don't have time to read the whole post, but if no one has mentioned it yet, have you tried kW X-Port?

http://www.kwxport.org/

I tried the Panda Soft exporter, and it bugged out on really simple things and gave me weird results..
so far kW X-Port is working out well for me.
adder_noir
adder_noir
That's great, thanks for the recommendation ;o)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.