KatsBits Community

[MD5] EXPORT script for Blender 2.6x (OPEN)

keless · 228 · 262541

0 Members and 2 Guests are viewing this topic.

cebugdev

  • Guest
hi admin,

i work with overdrivekaz for this project and he is the modeler and i did the model viewer and the engine, i decided to use MD5 because it is lightweight and easy to implement model with skinned animation. anyways, what he meant was when looking at the inside of the MD5 file, the filename of the texture does not appear in the "shader" part of the code each mesh, it only displays shader "Material.001" and also no texture files imported along with md5mesh and md5anim.

overdrivekaz will post more details soon, hope you guys can help us with this, thanks,


Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 2692
    • KatsBits
@cebugdev: thanks for clarifying. I've just added a new section to the MD5 prep & export information (cf. MESH PREP Material, Texture, UVW names/ID's) which explains in-depth what the problem is likely to be. Suffice to say here though, make sure your Material names are 'valid'; you'll need to remove the automatic numerical append, that's the ".001" bit from the Material name (and other data for that matter). Depending on what you're doing (how you've implemented the format in the engine), Material names ("ID") will be important in terms of their referencing a 'path' or just a (descriptive) 'word', "wood" vs "textures/floor/wood" for example.

Failing all that the resulting *.md5mesh, being text based, can be corrected manually in NotePad or similar if there are problems - you can test material/texture assignment in MD5View, just try loading in a random image to see if it gets applied, if it does you have a valid mesh, if it doesn't you'll know there's an issue (make sure to use *.tga formatted images initially).


Offline overdrivekaz

  • Defunct
  • Newbie
    • Posts: 5
Sir. can i send the file through pm?.. i will also include the md5 file for your reference. thanks

update: i renamed a unique shader/material name but still the same.


Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 2692
    • KatsBits
Yep, send it through and I'll take a look - info@katsbits.com

[EDIT] upon further investigation the issue overdrivekaz was having related to the texture assigned to the mesh not being 'power of two'; make sure texture assets are valid sizes related to that 'rule' else they won't appear in MD5View for testing (and likely any game engine using the format).


Offline Rajveer

  • Newbie
    • Posts: 6
I've tried using this script in both Blender 2.63 and 2.66, however with any mesh I use I always get what seems to be invalid bounds (i.e. for min the x, y and z values are all the same for each frame, and I'm not sure if max values are valid). I've included a sample below:

bounds {
   ( -1.463064 -1.463064 -1.463064 ) ( -1.463064 3.384057 2.877697 )
   ( -1.390775 -1.390775 -1.390775 ) ( -1.390775 3.384057 2.877697 )
   ( -1.274601 -1.274601 -1.274601 ) ( -1.274601 3.384057 2.877697 )
   ( -1.235497 -1.235497 -1.235497 ) ( -1.235497 3.384057 2.877697 )
   ( -1.234138 -1.234138 -1.234138 ) ( -1.234138 3.384057 2.877697 )
   ( -1.233475 -1.233475 -1.233475 ) ( -1.233475 3.384057 2.877697 )
   ( -1.234469 -1.234469 -1.234469 ) ( -1.234469 3.384057 2.877697 )
   ( -1.252545 -1.252545 -1.252545 ) ( -1.252545 3.384057 2.877697 )
   ( -1.349897 -1.349897 -1.349897 ) ( -1.349897 3.384057 2.877697 )
   ( -1.463064 -1.463064 -1.463064 ) ( -1.463064 3.384057 2.877697 )
   ( -1.349896 -1.349896 -1.349896 ) ( -1.349896 3.384057 2.877697 )
   ( -1.252545 -1.252545 -1.252545 ) ( -1.252545 3.384057 2.877697 )
   ( -1.234469 -1.234469 -1.234469 ) ( -1.234469 3.384057 2.877697 )
   ( -1.233475 -1.233475 -1.233475 ) ( -1.233475 3.384057 2.877697 )
   ( -1.234468 -1.234468 -1.234468 ) ( -1.234468 3.384057 2.877697 )
   ( -1.252475 -1.252475 -1.252475 ) ( -1.252475 3.384057 2.877697 )
   ( -1.349568 -1.349568 -1.349568 ) ( -1.349568 3.384057 2.877697 )
   ( -1.463064 -1.463064 -1.463064 ) ( -1.463064 3.384057 2.877697 )
}

I've taken a quick look at the script and can't see anything obviously wrong (I've never done Python scripting though), so is there anything I could be doing incorrectly? Note that other than that, the models get exported perfectly.


Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 2692
    • KatsBits
The coordinates shown in "bounds" represent the MD5's bounding box (volume of space occupied) per frame of a given animation sequence.

Assuming the mesh and Armature are properly centered on Blenders grid so the Objects 'Origin' point is placed at grid-centre (0,0,0) prior to export, both positive and negative values should be seen in the resulting output because they represent, in 'Object Space' (values based on the Objects Origin iirc), the 'min' and 'max' "X", "Y" and "Z" coordinates of each face of the six-sided volume as it changes shape and size due to articulation of the underlying mesh.

If you're not seeing any obvious errors, i.e. the mesh is all over the place, what you have there appears to be fine.


Offline Rajveer

  • Newbie
    • Posts: 6
Thanks for the quick reply. The models I've tried look fine - they are properly centered and have width in all axes. With all of them I get the same issue, the min x, y, z and max x values are all the same. When trying this with the "Bob" MD5 model provided in the MD5 downloads section on this site I get the min x, z and max x values being the same, so the bounds ends up being a 2d square along the y-z plane with no width, which definitely looks wrong (this was in Blender 2.63 and 2.66a)?


Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 2692
    • KatsBits
What are you using to test/view the mesh data? Using 'Bob' there shouldn't be any general issues using the files as-is, so there must be something else going on. To check try exporting from Blender 2.69 using the same script (which works fine) to see if that fixes the issue.. if it does then you know there's a problem exporting from the mentioned versions of Blender rather than the files you're actually exporting.


Offline Rajveer

  • Newbie
    • Posts: 6
I've downloaded Blender 2.69 and unfortunately get the same issue. I'm using my own engine to view the MD5 mesh/animation and it's per-frame AABB, however the AABB problem can be verified by just opening the file in Notepad++ and comparing the values. The actual exported model and animation work perfectly, it's just the bounding boxes that have an issue.

If you have the time, could you verify these results by trying to export the Bob MD5 model and checking what the exported bounds are? I only ask because I'm at a loss :(


Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 2692
    • KatsBits
OK looking in to this as the bob example files exported from Blender 2.69 are showing some odd distortion errors for me when opened into MD5View - something that doesn't happen with other recent files/projects so I suspect these issues are the result of the many internal changes Blender has undergone with 2.5/2.6 series. Will post an update shortly.


Offline Rajveer

  • Newbie
    • Posts: 6
Thanks very much for double checking. Please take your time there's no rush, also if there's any way I can help (providing test cases e.t.c) then let me know :)


Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 2692
    • KatsBits
Sample file has been updated for Blender 2.69 and above (subject to Blender Foundation subsequently breaking stuff internally again). Old version is still available but both can now be found on the MD5 sample file page.


Offline Rajveer

  • Newbie
    • Posts: 6
I think there's been a misunderstanding, the problem wasn't with the Bob MD5 sample model, the problem is with the MD5 export script. Taking a look at the updated model, the newly-created "bob_lamp_update.md5anim" and "bob_lamp_update_export.md5anim" animation files still have the same problem - the bounds are incorrect. Open up those files with Notepad++ and compare the values for each bounding box's min and max x, y and z values and you'll see that the bounds were calculated/exported incorrectly.


Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 2692
    • KatsBits
Just to check this further the below is the first line from the 'bounds' block exporting the same (original) Bob file from each script corresponding version of Blender - before export MESH objects were reset so their size and origin were relative to Blenders grid-centre (used "Apply" to set Origin points at 0,0,0) - the bounding box values are calculated relative to that position (outwards).

Bounds from 2.54
( -1.634066 -1.325154 -0.028520 ) ( 1.632142 7.007772 6.647473 )

Bounds from 2.57
( -1.634066 -1.325154 -0.028520 ) ( 1.632142 7.007772 6.647473 )

Bounds from 2.62
( -1.634067 -1.634067 -1.634067 ) ( -1.634067 6.444686 5.410537 )

Bounds from 2.63
( -1.634067 -1.634067 -1.634067 ) ( -1.634067 6.444686 5.410537 )

Bounds from 2.69
( -1.634067 -1.634067 -1.634067 ) ( -1.634067 6.444686 5.410537 )

It looks like either there's an error in the script or Blender itself (in terms of what it's doing relative to the script) after the significant change that happened Blender 2.60 onwards - looking at the numbers from 2.62 the bounds do indeed appear to be a flat box compared to prior that.

Unfortunately I can't do anything beyond confirming what you've found as I'm not a code-monkey.


Offline Rajveer

  • Newbie
    • Posts: 6
Thanks for double checking the different Blender versions for which work and don't. If I have time I'll take a look at the changes between 2.57 and 2.63 and hopefully be able to figure out what changes need to be made to the script. If I'm able to fix it I'll report back.