I'm trying to export animation from Maya 5; thankfully the API makes this pretty easy. However, I'm a bit uncomfortable with the bone- and model- space information.

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Cool thing, your exporter! Do you do that in MEL or as a compiled plugin? I don´t have much experience with Maya. Would that even be possible in MEL?

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

**Quote:**

I´d rather see it as

**Code:**

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

**Code:**

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

I'm currently writing a compiled plug-in, but once it's finished, I'll look into writing it in MEL.

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

"You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

anim_matrix = bone_world_matrix * inverted parentbone_world_matrix

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

**Quote:**

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

Thanks for the quick response.

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

Cat, I understand C++, and readup and understand MEL. I have not really worked with it, but the understanding is there. (I use to do alot of basic programming) and MEL is not very hard and C++ is close.

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

I'm not sure what you mean, but if you need info about the md5 syntax, it's all been done:

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

I was just asking you of the process you went through.

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

This thread is still alive?

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

hello Cat,

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

I'm trying to export animation from Maya 5; thankfully the API makes this pretty easy. However, I'm a bit uncomfortable with the bone- and model- space information.

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Cool thing, your exporter! Do you do that in MEL or as a compiled plugin? I don´t have much experience with Maya. Would that even be possible in MEL?

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

**Quote:**

I´d rather see it as

**Code:**

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

**Code:**

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

I'm currently writing a compiled plug-in, but once it's finished, I'll look into writing it in MEL.

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

"You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

anim_matrix = bone_world_matrix * inverted parentbone_world_matrix

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

**Quote:**

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

Thanks for the quick response.

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

Cat, I understand C++, and readup and understand MEL. I have not really worked with it, but the understanding is there. (I use to do alot of basic programming) and MEL is not very hard and C++ is close.

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

I'm not sure what you mean, but if you need info about the md5 syntax, it's all been done:

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

I was just asking you of the process you went through.

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

This thread is still alive?

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

hello Cat,

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

I'm trying to export animation from Maya 5; thankfully the API makes this pretty easy. However, I'm a bit uncomfortable with the bone- and model- space information.

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Cool thing, your exporter! Do you do that in MEL or as a compiled plugin? I don´t have much experience with Maya. Would that even be possible in MEL?

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

**Quote:**

I´d rather see it as

**Code:**

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

**Code:**

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

I'm currently writing a compiled plug-in, but once it's finished, I'll look into writing it in MEL.

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

"You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

anim_matrix = bone_world_matrix * inverted parentbone_world_matrix

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

**Quote:**

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

Thanks for the quick response.

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

Cat, I understand C++, and readup and understand MEL. I have not really worked with it, but the understanding is there. (I use to do alot of basic programming) and MEL is not very hard and C++ is close.

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

I'm not sure what you mean, but if you need info about the md5 syntax, it's all been done:

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

I was just asking you of the process you went through.

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

This thread is still alive?

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

hello Cat,

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 10:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 8:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 1:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 6:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 6:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 7:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 11:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 11:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 11:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 5:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 10:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 10:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 8:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 1:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 6:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 6:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 7:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 11:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 11:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 11:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 5:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 10:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm Post subject: Maya 5 md5mesh exporter complete, working on md5anim: I'm trying to export animation from Maya 5; thankfully the API makes this pretty easy. However, I'm a bit uncomfortable with the bone- and model- space information.

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skeletal_animation/md5mesh_skeleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skeletal_animation/maya_skeleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am Post subject: : Cool thing, your exporter! Do you do that in MEL or as a compiled plugin? I donÃÂ´t have much experience with Maya. Would that even be possible in MEL?

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But thatÃÂ´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didnÃÂ´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe thereÃÂ´s some info of interest.

Quote: |

weight.position = ( absolute_position - T ) * inverse(R) |

IÃÂ´d rather see it as

Code: |

position = abs_position * inverse(bone-matrix) |

so that the boneÃÂ´s transformation is included in the bone-matrix. ItÃÂ´s mathematically the same, but itÃÂ´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when youÃÂ´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

YouÃÂ´re right, the bone matrices in the md5anim are in the parentÃÂ´s space. So you have to

1. transform the boneÃÂ´s matrix into its parentÃÂ´s space:

Code: |

anim_matrix = bone_matrix * inverted parent_matrix |

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And thatÃÂ´s it.

If the Maya API doesnÃÂ´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

_________________

Staff

Modelviewer | 3DSMax<->MD5 | Blender<->MD5

Cat@Posted: Fri Apr 23, 2004 12:32 pm Post subject: : I'm currently writing a compiled plug-in, but once it's finished, I'll look into writing it in MEL.

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/knowledgebase/api/2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm Post subject: : "YouÃÂ´re right, the bone matrices in the md5anim are in the parentÃÂ´s space. So you have to

1. transform the boneÃÂ´s matrix into its parentÃÂ´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm Post subject: : anim_matrix = bone_world_matrix * inverted parentbone_world_matrix

is the right thing.

The root bone(s) donÃÂ´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didnÃÂ´t answer that yet:

Quote: |

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. MayaÃÂ´s bones grow along a different axis than MaxÃÂ´s bones, for example. So thereÃÂ´s lots of information lost.

My viewer displays the bonesÃÂ´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a boneÃÂ´s origin towards its childrenÃÂ´s origins, thatÃÂ´s the best that you can do. The md5mesh/anims just donÃÂ´t hold any more information, because thatÃÂ´s all thatÃÂ´s needed to do the skeletal animation.

_________________

Staff

Modelviewer | 3DSMax<->MD5 | Blender<->MD5

Cat@Posted: Fri Apr 23, 2004 6:59 pm Post subject: : Thanks for the quick response.

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm Post subject: : Cat, I understand C++, and readup and understand MEL. I have not really worked with it, but the understanding is there. (I use to do alot of basic programming) and MEL is not very hard and C++ is close.

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm Post subject: : I'm not sure what you mean, but if you need info about the md5 syntax, it's all been done:

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

_________________

Staff

Modelviewer | 3DSMax<->MD5 | Blender<->MD5

marsellus@Posted: Sat Aug 14, 2004 10:53 pm Post subject: : I was just asking you of the process you went through.

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm Post subject: : This thread is still alive?

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am Post subject: : hello Cat,

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm Post subject: Maya 5 md5mesh exporter complete, working on md5anim: I'm trying to export animation from Maya 5; thankfully the API makes this pretty easy. However, I'm a bit uncomfortable with the bone- and model- space information.

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skeletal_animation/md5mesh_skeleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skeletal_animation/maya_skeleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am Post subject: : Cool thing, your exporter! Do you do that in MEL or as a compiled plugin? I donÃÂ´t have much experience with Maya. Would that even be possible in MEL?

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But thatÃÂ´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didnÃÂ´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe thereÃÂ´s some info of interest.

Quote: |

weight.position = ( absolute_position - T ) * inverse(R) |

IÃÂ´d rather see it as

Code: |

position = abs_position * inverse(bone-matrix) |

so that the boneÃÂ´s transformation is included in the bone-matrix. ItÃÂ´s mathematically the same, but itÃÂ´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when youÃÂ´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

YouÃÂ´re right, the bone matrices in the md5anim are in the parentÃÂ´s space. So you have to

1. transform the boneÃÂ´s matrix into its parentÃÂ´s space:

Code: |

anim_matrix = bone_matrix * inverted parent_matrix |

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And thatÃÂ´s it.

If the Maya API doesnÃÂ´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

_________________

Staff

Modelviewer | 3DSMax<->MD5 | Blender<->MD5

Cat@Posted: Fri Apr 23, 2004 12:32 pm Post subject: : I'm currently writing a compiled plug-in, but once it's finished, I'll look into writing it in MEL.

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/knowledgebase/api/2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm Post subject: : "YouÃÂ´re right, the bone matrices in the md5anim are in the parentÃÂ´s space. So you have to

1. transform the boneÃÂ´s matrix into its parentÃÂ´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm Post subject: : anim_matrix = bone_world_matrix * inverted parentbone_world_matrix

is the right thing.

The root bone(s) donÃÂ´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didnÃÂ´t answer that yet:

Quote: |

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. MayaÃÂ´s bones grow along a different axis than MaxÃÂ´s bones, for example. So thereÃÂ´s lots of information lost.

My viewer displays the bonesÃÂ´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a boneÃÂ´s origin towards its childrenÃÂ´s origins, thatÃÂ´s the best that you can do. The md5mesh/anims just donÃÂ´t hold any more information, because thatÃÂ´s all thatÃÂ´s needed to do the skeletal animation.

_________________

Staff

Modelviewer | 3DSMax<->MD5 | Blender<->MD5

Cat@Posted: Fri Apr 23, 2004 6:59 pm Post subject: : Thanks for the quick response.

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm Post subject: : Cat, I understand C++, and readup and understand MEL. I have not really worked with it, but the understanding is there. (I use to do alot of basic programming) and MEL is not very hard and C++ is close.

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm Post subject: : I'm not sure what you mean, but if you need info about the md5 syntax, it's all been done:

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

_________________

Staff

Modelviewer | 3DSMax<->MD5 | Blender<->MD5

marsellus@Posted: Sat Aug 14, 2004 10:53 pm Post subject: : I was just asking you of the process you went through.

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm Post subject: : This thread is still alive?

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am Post subject: : hello Cat,

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!

Cat@Posted: Thu Apr 22, 2004 9:30 pm :

The md5mesh portion of the exporter _seems_ to work fine (it loads in der_ton's wonderful viewer.) It supports an arbitrary number of weights per vertex, and submeshes.

I'm not sure if I'm writing out the bindpos and bindmat correctly, however. Please correct me where I'm wrong.

My understanding of the bindpos is the model-space (absolute, for now) coordinates of the bone origin. The bindmat is the absolute orientation of the bone. I then compute extract the weights, and perform

weight.position = ( absolute_position - T ) * inverse(R),

where T is the bindpos and R is the bindmat.

This, as I said, looks right in the viewer. The skeleton still bothers me, however. The bones don't look oriented completely right, but maybe it's because I'm operating in Maya's Y-up system, and not Doom 3's Z-up.

Here's a screenshot in the viewer:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

Here's the skeleton in Maya:

http://www.cs.virginia.edu/~csz9v/skele ... eleton.jpg

It looks like the orientation is wrong, and I'm positive I'm pulling the world-space values from the bones.

Now comes my seemingly bigger problem. All I want to do for now is export a totally idle animation. (the bind/rest pose.)

I assumed that for each bone I would just export the local, or bone-space position and rotation of the bone in its bind/rest position, but I'm not quite sure I understand this.

I'd appreciate a thorough description of exactly what I'm supposed to do here. I'm somewhat comfortable with extracting the absolute transformation information, but not the local. I'm not sure if I'm supposed to be exporting the transformation relative to the parent, or something similar.

Thanks!

EDIT: What is the proper way to display the skeleton, given only the md5mesh? ( I don't want to draw lines from bindpos to bindpos, I'd like to display the bones' local axes.)

der_ton@Posted: Fri Apr 23, 2004 7:20 am :

Yes, from the screenshots it seems that the coordinate systems of the md5 bones are not the original ones from the Maya model. But that´s ok as long as the animations work, too. Note that for Doom3 you have to have righthanded bone spaces because the animation is given in euler angles, not given in explicit matrices. I ran into that problem with the 3dsmax-exporter when someone made a model by mirroring some bones, so they had left-handed coordinate systems in 3dsmax. Maybe Maya prevents that from happening.

If you didn´t already, you might want to take a look at the forum threads or sourcecode for the blender exporter and the 3dsmax exporter, maybe there´s some info of interest.

weight.position = ( absolute_position - T ) * inverse(R)

I´d rather see it as

position = abs_position * inverse(bone-matrix)

so that the bone´s transformation is included in the bone-matrix. It´s mathematically the same, but it´s a better way to organize your matrices. You only split them up into bindpos and bindmat at the very end, when you´re outputting to the md5mesh.

About the md5anim thing, this might help:

http://www.doom3world.org/phpbb2/viewtopic.php?t=1969

I wrote some information related to md5anims, with readers in mind that want to make a md5-viewer.

You´re right, the bone matrices in the md5anim are in the parent´s space. So you have to

1. transform the bone´s matrix into its parent´s space:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles

And that´s it.

If the Maya API doesn´t offer support for the math stuff (like the euler conversion), you can look at the blender2md5 script, it has that stuff included.

Cat@Posted: Fri Apr 23, 2004 12:32 pm :

Maya's C++ API provides a plethora of Matrix, Quaternion, Euler angle classes and conversions between each other.

I think I'll use the more elegant transformation + rotation stored as a single transform matrix as you suggested.

It's not perfectly clear to me what transformation matrix I need, as Maya's joints, which inherit from Maya's Transform class, have additional transformation information:

http://www.alias.com/eng/support/maya/k ... 2384.jhtml

I'll gladly release this to the public, especially since I'm being helped by this forum.

Cat@Posted: Fri Apr 23, 2004 5:24 pm :

1. transform the bone´s matrix into its parent´s space:

Code:

anim_matrix = bone_matrix * inverted parent_matrix

(a matrix holds rotation AND transformation)

2. convert the rotation part to euler angles "

Just a small question here

this is

anim_matrix = bone_local_matrix * inverted_parent_world_matrix?

and

recursively multiplying bone_local_matrices will give you bone_world_matrices, right?

der_ton@Posted: Fri Apr 23, 2004 5:49 pm :

is the right thing.

The root bone(s) don´t have a parent, no need to transform them. To get the world matrices of the bones during animation (in a viewer for example), you go through the bone-tree top-down (assuming the standard computer science metaphor of a tree that grows downwards ofcourse ).

Oh, I didn´t answer that yet:

Well, all there is in a md5 is the matrices of the bones. No length of a bone, and actually not a real direction either. Maya´s bones grow along a different axis than Max´s bones, for example. So there´s lots of information lost.

My viewer displays the bones´ local axes. The RGB vector triples, see? R,G,B = X,Y,Z vector of the matrix.

It displays blue lines towards from a bone´s origin towards its children´s origins, that´s the best that you can do. The md5mesh/anims just don´t hold any more information, because that´s all that´s needed to do the skeletal animation.

Cat@Posted: Fri Apr 23, 2004 6:59 pm :

I succesfully exported an md5mesh and the corresponding bind pose md5anim.

Time to iterate keyframes and export some interesting md5anims.

marsellus@Posted: Sat Aug 14, 2004 10:20 pm :

No I am not asking you to teach me, but let me try to guess how to export a static mesh (non-animated) to a MD5.

This is my guess:

Step 1. Open a MD5 file of a static mesh, and learn how its syntax is formated.

Step 2. Create a MEL script that will take a selected poly mesh, loop through it, and organize it the way the MD5 is. (or plugin for more controll)

Example:

----------------------------------

(left arm gib .md5mesh

MD5Version 10

commandline "mesh models/gibs/cycles/initial.mb -dest models/md5/gibs/leftarmgib.md5mesh -game Doom -prefix GIB2_"

numJoints 5

numMeshes 1

joints {

"origin" -1 ( 0 0 0 ) ( 0 0 -0.7071067691 ) //

"luparm" 0 ( -19.5236797333 7.9370079041 59.3041687012 ) ( -0.6382610798 0.6561502814 -0.3043398261 ) // origin

}(edited for space)

mesh {

// meshes: polySurface7

shader "models/gibs/gibmaster"

numverts 84

vert 0 ( 0.1495526433 0.7503765821 ) 0 2

vert 1 ( 0.1121515036 0.686191082 ) 10 1

vert 2 ( 0.0983231068 0.7449886799 ) 15 2

(EDIT for space)

numtris 122

tri 0 2 1 0

tri 1 0 1 3

tri 2 6 5 4

(edited for space)

numweights 101

weight 0 1 0.8477444053 ( -7.2114658356 -0.4997648597 -1.7153018713 )

weight 1 2 0.1522555798 ( 1.7257144451 -1.227357626 -1.7315846682 )

weight 2 2 1 ( -3.1451933384 -0.9853061438 1.2875579596 )

(edited for space)

---

Now I edited that rather well, but if you where to go through this and figure out how thats organized, what the numbers mean, than is this how you do it?

Would you be willing to share your source code? (with comments) I think this would be a teriffic way for me to pull the things i like (Moding, Modeling, C++/MEL) into a cool plug in.

thanks, themulf@gmail.com

der_ton@Posted: Sat Aug 14, 2004 10:41 pm :

http://www.doom3world.org/phpbb2/viewtopic.php?t=2884

marsellus@Posted: Sat Aug 14, 2004 10:53 pm :

If you created a MEL script, would it be a loop that goes through the geometry data, and prints it out in the Md5 format?

Cat@Posted: Sun Aug 29, 2004 4:22 pm :

I can share my source code, that's not a problem. It's C++, not MEL, and is meant for the alpha. I may update it for the retail version, but I have a feeling id already has a Maya 6 compatible exporter. There'd really be no point.

ehmdjii@Posted: Tue Sep 12, 2006 9:26 am :

i am looking for an up to date md5 exporter from maya and i would be very happy if you could help me out by providing me with what you have done already.

thanks a lot!