Deformed mesh using Blender doom md5 exporter

So my model in blender looks normal, but when I export the animation into jme it looks like…well, a zombie. I have no clue what causes this, but I've been messing around and it seems to happen when I make two separate object and then join them together for some reason. The mesh is deformed where I've joined the meshes.



How do I fix this?!?!

First of all read this thread http://www.jmonkeyengine.com/jmeforum/index.php?topic=6914.0.



Secondly post the .md5mesh and .md5anim files, if possible. And also the *.blend file.



You must remember that:


  1. Skeleton (Armature in Blender) should not have more then 1 bone at the root of the hierarchy.


  2. A model should not have more then 1 Armature object.


  3. Joining meshes in Blender could affect vertices weights.


  4. The sum of all bones factors influencing a vertex have to be equal to 1.

Here are the .mesh and .anim files:



http://whijollama.fortunecity.com/mesh.txt

http://whijollama.fortunecity.com/anim.txt



I only have one bone that is the origin…only one bone PERIOD…and the animation is just of him standing still.  In blender he looks like this…



http://whijollama.fortunecity.com/model.jpg



But in JME he looks like this…



http://whijollama.fortunecity.com/zombie.JPG



Nevermind the weird texture and him being on his side…but what’s with the other weirdness?

I cannot see the images or files.  :expressionless:

Doh…stupid thing. It works on my computer when I type it in, but not when I just click on it. You might have to refresh a few times.

It uses referrers to prevent direct linking. You need to get on the webpage (http://whijollama.fortunecity.com/) and then enter the image URL.

strange i can see them just fine

Some of your weights add up to something greater than 1… I think that should not be the case.

How do I make sure the weights don't add up to more than one?

Normalize/Scale Weight… script could be te right one. It appear in weight paint mode. But I still not tested it.

In your particular case, it seems that you are using exactly one weight per vertex… (i.e. each vert has a 1 in the last column), this means that each weight bias should be 1.0 (i.e. weight indx 0 1.0 ( x y z ) ).



If you are using Linux, I can give you a script that will change them automatically, another way would be to use find/replace of 0.500000 for 1.0 in the region where you define the weights.



Hope it helps.

I tested Normalize/Scale Weight… but it seems to not achieve what expected. Maybe looking around Blender related sites you will find a script to do weight normalization automatically.



This is a known problem, though. I hoped that der_ton's exporter did the job, but unfortunately it seems that it does not. As promised, I will develop a MD5 exporter for Blender, as soon as I have completed my knowledge about the format.



MD5 Reader 2 should not be expected to do it for us even if it could be simpler to do it from the MD5 format than inside Blender.

As promised, I will develop a MD5 exporter for Blender, as soon as I have completed my knowledge about the format.

I think that once jME 2.0 is released with hardware skinning and XML model format, it would be much easier to export to XML from blender.

I simply chosen MD5 format once and now I just continue development. I don't think that relying on only one format is good choice. The final developers who build their games can have the chance to adopt the best format they want.



If I will be able to do it also MD5 Reader 2 will support hardware skinning in the future, though (it needs some kind of conversion, during loading time but maybe it is feasible). But I am not in competition with the XML Collada format. Simply MD5 is currently the source where I am spending all my efforts.

Yay! Wrote a program to change all weights to 1, and my mesh looks normal. Haven't checked any animation besides him standing still, so I don't know if/how this will effect model movement, but I'll keep you updated.



Thanks for all the help :>

That's a good news for me. Finally a evidence that confirmed my guess.



Do you think it could be possible that you share that code, whijo?

I would say that what he did was only change the weights in the special case of one weight per vertex, but we will have to ask  :wink:



Personally, I think the MD5 Reader should do that automatically, as well as checking the bone hierarchy (only one root) since that seems to be causing a lot of trouble for many people. Is that feasible to do? Would you need some help writing it? I could perhaps have a look at it.

duenez said:

I would say that what he did was only change the weights in the special case of one weight per vertex, but we will have to ask  :wink:

Personally, I think the MD5 Reader should do that automatically, as well as checking the bone hierarchy (only one root) since that seems to be causing a lot of trouble for many people. Is that feasible to do? Would you need some help writing it? I could perhaps have a look at it.


Thanks a lot for the help offer duenez.

The reason for I asked for whijo code sharing is that, even if I could achieve that thing by myself using his (already done) code could permit me to save time. ;)

If you want to give a look at the code of MD5 Reader 2 and help us, you are wellcome.

Before you start anyway you should be aware of some basic things about the new MD5 Reader 2.
  • The original code is still maintained, but I plan to move to a more elegant, human readble and jME compliant refactor. In fact, if you look at the org.md5reader2 package you will see that there is already a skeleton of the new reader.

  • There are 2 branches of the MD5 Reader 2 based on original code. One is maintained by Duodecimo. He reconstructed there the parser/reader architecture, based on JFlex and CUP. I hope to merge soon the 2 branches or to include Duodecimo's parser in the MD5 Reader 2 new code.

  • Basically we don't aim to have any kind of conversion inside MD5 Reader 2, new code, but to provide a compliant exporter for Blender (that does all conversions) or a plugin architecture. That means that if you code such a converter/checker you should do it in a way that it would be really easy to port it (for example in Python) or to implement it in the new MD5 Reader 2 java code, in the case that we decide to include it.

  • Comment a lot your code.



I know these requirements are really tied up, but considering that I have not much time to spent in this project, and this approach helps me to easily restart when I have to be absent for long periods.

Thanks a lot

The code I used was written in perl and just changed all the weight numbers to 1. I still have to export the original blender file, then convert the file using this code. It doesn't work so well when a vertex is assigned to more than one bone…then I think the vertex weight gets assigned more than once and the total weight ends up being more than 1…and then the zombie mesh returns.



For now I'm just being very careful to assign each vertex to only one bone.  :expressionless:

Here's the code:







#!/usr/bin/perl



$file = shift;

$output = shift;



open(INPUT, $file);

open(OUTPUT, ">$output");



while(<INPUT>){

#      $_ =~ s/(^w+weightw+d+w+d+)w+d+w+(.)/$1 1.000000 $2/g;

        $_ =~ s/(^s
weightsdsd)s*[d|.]s(.*)/$1 1.000000 $2/g;

        print "$1 LDLJLDSFJ $2n";

        print OUTPUT $_;

}



close INPUT;

close OUTPUT;







I have yet to actually integrate it into the python script, but that's the plan.