KatsBits Community

Game Editing => Scripts & Support => Topic started by: nemyax on May 15, 2012, 10:03:40 PM

Title: [MD5] export add-on for Blender 2.63+
Post by: nemyax on May 15, 2012, 10:03:40 PM
UPDATE: Updated version (for Blender 2.66+) of Arx MD5 export available here (https://www.katsbits.com/smforum/index.php?topic=520.0)



I've written an MD5 exporter for Blender 2.63+. It takes advantage of the Bmesh data structure, so it won't work with prior versions. This exporter was done from scratch and does not use any code from older ones.

It was made for use in the Arx: End of Sun project (http://arxendofsun.solarsplace.com/), and built around the workflow used by the project team, not around the workflow associated with previous exporters. For usage details, see the accompanying readme file.

The exporter is up at http://arxendofsun.solarsplace.com/downloads/io_scene_md5.zip
The .zip file contains the add-on directory and a readme file (mandatory reading).

Disclaimer: I don't really know how to code, so do not expect this to work well for you. In addition, some of the transform code is based on trial and error rather than an understanding of the maths involved. However, if you've been bitten by the lack of MD5 export for 2.63 (as I have) and you abhor the prospect of sticking with pre-2.63 (as I do), you might want to give this a spin.

[EDIT]added link to updated script. kat
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on May 18, 2012, 07:17:12 PM
Thanks for posting. Not had a chance to test this yet though.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on May 25, 2012, 12:40:08 PM
The script has been updated:
1. Fixed a frame range bug.
2. Made it record parameter values (Reorient and Scale) used during export.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: velociostrich on May 28, 2012, 03:31:42 AM
I'm a developer on the Unvanquished project (http://unvanquished.net/ (http://unvanquished.net/)). We've been having a number of issues with the previous MD5 exporter and haven't really gotten around to addressing them (opting instead to use older versions of Blender). At present, there's a lot of different versions of the old exporter just floating around on the internet, so just yesterday we set up a new github repository (https://github.com/Unvanquished/Blender-Scripts (https://github.com/Unvanquished/Blender-Scripts)) for that purpose. Haven't had any time to upload any scripts to that, however.

tl;dr we ought to work together if we can, and get that script under revision control ASAP, whether its yours or ours. (Git is really great for this sort of thing, imo).
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on May 28, 2012, 03:59:33 AM
As of now, pretty much any MD5/MD3/ASE et-al material finds a focus on KatsBits as a central hub of information on those formats so I'm not entirely sure (convinced) adding yet another download/repository location is an effective way of dealing with the problem you're addressing with your comment.

What I'd suggest is you version up what you need using Git and your hosting channel, then post here to let everyone know it's availability, this allows everyone to do what they need, minus, the problems associated with projects going offline and/or disappearing, taking all their content with them - over the years that's happened more times that it should and we loose a lot of material as a result (it's also one of the reasons KatsBits was set up some 12 years ago [under a different name]).

In other words, I'd encourage you and other authors (including nemyax) to work independently or collectively as required and circumstances dictate. Good luck with your project by the way.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on May 28, 2012, 09:05:09 AM
We've been having a number of issues with the previous MD5 exporter and haven't really gotten around to addressing them
Have you tried this exporter with your assets?
get that script under revision control ASAP
It's version-controlled in the Arx End of Sun repo.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on June 15, 2012, 07:21:33 PM
I gave this exporter a try. It didn't work for me.

I unzipped .py file into scripts/addon/ , started Blender, went to Preferences to activate the addon and it was not there :/ Nor it was in Export menu.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on June 15, 2012, 07:28:40 PM
Put the io_scene_md5 directory in addons, not the individual .py files.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on June 15, 2012, 07:35:07 PM
Thanks, that worked. However, may I ask why not to get very nice GUI from existing MD5 exporter and not re-invent the wheel?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on June 15, 2012, 07:39:05 PM
I did what worked best for me.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on June 18, 2012, 05:20:31 PM
A quick note on why mesh and anim export are separated (so that there's no more Drama):
In the course of working with a scene, a completed mesh normally needs to be exported only once. However, you may need to export multiple animations for that mesh. For that reason, anim export is a separate command, and the GUI (one particular dropdown, really) from der_ton and keless' script was not adopted.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on June 18, 2012, 06:08:05 PM
Mesh file can be overwritten every time you export, it's just an automated thing. But exporting one Action at a time is a total pain.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on June 18, 2012, 06:23:35 PM
exporting one Action at a time is a total pain.
Does the previous script write multiple anims per save?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on June 18, 2012, 06:46:55 PM
Ofc, why else would I be asking for improvements :)
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on June 18, 2012, 06:50:24 PM
I see. I should certainly add that at some point.
I'm not sure when I'll be able to though.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on June 18, 2012, 07:02:31 PM
There are some folks who are interested in doing this, and therefore I created a mock up of the GUI and technical description, in case you are still interested: http://blenderartists.org/forum/showthread.php?258069-PAID-job-MD5-exporter-for-Doom-3
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on June 18, 2012, 07:15:53 PM
> types in Action names
A resounding NO. If batch export is to happen in this one, it will be  based on timeline markers, not actions in the Blender sense. I don't want to go near that can of worms.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on June 18, 2012, 07:54:22 PM
You need to have each animation in a separate Action. There is IQM exporter that does just that - it takes Action and exports only amount of frames occupied with keys. Nothing more nothing less. Sometimes animation needs to be shorter than Action timeline is, so markers would help a lot.

That's just sane workflow. You exporter provides workflow from 90s, when command line tools were common.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on June 21, 2012, 09:07:42 AM
The script has been updated:
1. Added batch export.
2. Added popups blocking the file selector if export is not possible (not implementing this from the start was very lame on my part, sorry about that).

Get it at the usual place: http://arxendofsun.solarsplace.com/downloads/io_scene_md5.zip
Don't forget to read the readme.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: Spielkarsten on July 04, 2012, 09:29:58 PM
I have noticed that the export fails if you have any object transformation on the armature. If you clear that, it works fine. Maybe you could add that to the readme or fix it.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: 222464 on July 10, 2012, 07:40:29 PM
Hello,

When looking for a solution for an animated model format for my game engine, I found MD5, and from there I found this. First of all, thanks for sharing this! MD5 exporters seem to be pretty rare. Unfortunately though, when trying to export a MD5 mesh, I got:

(https://www.katsbits.com/smforum/proxy.php?request=http%3A%2F%2Fi1218.photobucket.com%2Falbums%2Fdd401%2F222464%2Ferror.png&hash=d6499d284cac05f0330da509b3c14e7b)

I was able to export an animation just fine, but meshes don't seem work for me. Any ideas as to what I might be doing wrong?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on July 10, 2012, 08:04:46 PM
When you export are you select both mesh and armature (armature last), or just the mesh on it's own?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: 222464 on July 10, 2012, 08:28:51 PM
I tried both, no success  :(

EDIT: The error also causes Blender to crash when exiting.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on July 10, 2012, 08:39:19 PM
Do you want to send me the file and I'll take a look? info@katsbits.com if you can/are able to.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 11, 2012, 08:57:49 AM
I have noticed that the export fails if you have any object transformation on the armature. If you clear that, it works fine. Maybe you could add that to the readme or fix it.
I'll look into it, thanks for reporting.
When you export are you select both mesh and armature (armature last), or just the mesh on it's own?
It doesn't matter. Only the mesh selection is used. The readme states this explicitly.
Unfortunately though, when trying to export a MD5 mesh, I got:
This error means the script can't find vertex weight data in the mesh object. It's supposed to catch this condition early, but apparently it doesn't. I'll try to fix this soon; meanwhile, please make sure your mesh is weighted properly. It would help if you uploaded your blend file somewhere.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: 222464 on July 11, 2012, 12:14:18 PM
I uploaded the model here: https://sites.google.com/site/cireneikualsgameprogramming/misc (https://sites.google.com/site/cireneikualsgameprogramming/misc)

Warning, it is a horrific example of programmer art!  :P
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on July 11, 2012, 02:37:27 PM
Did you check the email I sent you in return 222464? There are a few more problems with the model you need to address in addition to the vertex weighting issue nemyax mentioned.

[EDIT]ignore the above, I just read your reply, message was in my junk folder again.. damn filters!
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: 222464 on July 19, 2012, 02:53:43 PM
After setting it aside for a while, I again tried to use this exporter, but unfortunately I have still not been able to successfully export a MD5 mesh.

Animations work just fine, so I don't see how it can be a vertex weighting issue.

Thanks for the help so far!

Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 22, 2012, 11:08:26 PM
I don't see how it can be a vertex weighting issue.
It is. Check your weights. And unparent the mesh from the armature while you're at it—this is wrong on so many levels (and you tricked yourself by parenting it).
MD5 animations don't use any weight information (only bounding boxes and joints), so animation export is not prevented.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 27, 2012, 11:08:06 AM
A small clarification: although the "swarmer" character has some weighting issues, the real cause of the error seems to be the presence of vertex groups unrelated to bones. I'll need to make the script ignore those. I'll also forbid zero weights, because they are ambiguous.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: 222464 on July 27, 2012, 08:08:55 PM
Ah, thank you! I re-weighted it over and over, but just couldn't get it to work. I finally got it to work by removing the vertex groups. You are my hero!  ;D

I am looking forward to the next version!
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 27, 2012, 08:23:27 PM
I finally got it to work
Glad it's worked out for you.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on July 27, 2012, 08:27:13 PM
@nemyax: Is there any particular reason, besides perhaps limited knowledge of Blender's API, to not listen to designers and artists to create sane GUI and sane workflow for MD5 exporter ?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 27, 2012, 08:41:16 PM
motorsep
Apparently the reason is a different opinion of what a "sane" workflow is. I am prepared to explain what few design decisions there are in this script. What is it you're not comfortable with?
Incidentally, who are the aggrieved designers and artists whom this exporter has inconvenienced? And why don't they look elsewhere?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on July 27, 2012, 09:22:09 PM
Workflow should be simple - select meshes (models can have several surfaces), select armature, export. No need to mess with layers, or have only single mesh, etc. Just look at the old exporter from 2.49b

Yeah, as usual, programmers see sane workflow one way and artists see it another way :)

I personally not comfortable with constraints you impose in the exporter on how scene should be made, how animation should be done and how it should be exported. The workflow is fundamentally flawed.

"They" have been looking somewhere else and got all new GUI done. Just waiting on part that converts Blender matrices into MD5 format matrices. It's just taking way more time than expected.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 27, 2012, 09:47:00 PM
Workflow should be simple - select meshes (models can have several surfaces), select armature, export. No need to mess with layers
Why the layers
You generally don't need all of your bones in the MD5. Much of the armature in a moderately complex setup is helper bones, which need to be filtered out. What you suggest results in all of that fluff ending up in the export result. This is not what I would want, but if you're OK with that, just put them all in layer 5. That's one keypress and one click.
The messing bit
There's a script included in the readme to help stuff the MD5 layer.

or have only single mesh
This exporter does not have the one-mesh limitation.

I personally not comfortable with constraints you impose in the exporter on how scene should be made, how animation should be done and how it should be exported.
Tough. But then, how are those constraints more severe than in other exporters?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on July 27, 2012, 09:57:13 PM
Why the layers
You generally don't need all of your bones in the MD5. Much of the armature in a moderately complex setup is helper bones, which need to be filtered out. What you suggest results in all of that fluff ending up in the export result. This is not what I would want, but if you're OK with that, just put them all in layer 5. That's one keypress and one click.

Are you aware that active bones layer can be exported? Leave it up to artist to have a layer active with bones he wants to export. It can be any layer, as long as it's active. If you load MD5's from Doom 3, you will see that there are bones in them that ideally should not have been exported.

The idea that artist has to put bones into layer 5 is ridiculous, because everyone has their own habits and workflow. I might want my export bones to be in layer 1 and someone else likes to have them in layer #last.

The messing bit
There's a script included in the readme to help stuff the MD5 layer.

That's besides the point. Making awkward workflow and saying "go read docs" is not a user-friendly approach.

Tough. But then, how are those constraints more severe than in other exporters?

There are no other exporters besides one for 2.49, where you can pick out what you need to export, where you need to export, etc. etc. It's more productive, it's more intuitive, more artist friendly.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 27, 2012, 10:12:34 PM
Leave it up to artist to have a layer active with bones he wants to export. It can be any layer, as long as it's active.
I, the artist, prefer to have only my control bones showing up at all times. What I don't want to do is switch layers for export.

The idea that artist has to put bones into layer 5 is ridiculous
No. It's mischievous and quaint.

I might want my export bones to be in layer 1 and someone else likes to have them in layer #last.
Put them in 1, 5 and #last. What's the problem?

one for 2.49, where you can pick out what you need to export, where you need to export
And here you can't?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on July 27, 2012, 10:29:05 PM
nemyax, as the script was originally geared toward Arx it's inadvertently imposing that particular workflow in places where it may be at the expense of what has been years of evolutionary incremental development which is firmly based on idtech4. If the purpose here is to produce a general MD5 script then these are valid concerns. If not, and you just want to release "Arx MD5", then you can happily ignore what's being said/requested. But, it's important to make sure potential users clearly understand this otherwise topics like this can quickly descend into flame-fests.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 28, 2012, 05:48:13 AM
If the purpose here is to produce a general MD5 script then these are valid concerns. If not, and you just want to release "Arx MD5", then you can happily ignore what's being said/requested. But, it's important to make sure potential users clearly understand this otherwise topics like this can quickly descend into flame-fests.
This topic has generated a few perfectly valid requests (batch export, better vertex group handling) and useful bug reports. I am willing to work on those, and more feedback is always welcome, of course.
However, where I don't agree with a proposed implementation, I try to give my grounds for refusal; I will not be shamed into making such changes.
The exporter is essentially "Arx MD5", but can be (and apparently has been) used generically.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on July 28, 2012, 08:11:20 AM
For the sake of clarity it might be worth updating the initial post to let users know the script is indeed an "Arx MD5" exporter; the workflow arrangements that cater to that seem to be the main bone of contention here so it's best to make that known to save problems with users wondering why things aren't working the way they're expecting relative to previous scripts.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on July 28, 2012, 08:30:19 AM
Good point. Original post updated.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on July 28, 2012, 05:25:49 PM
Cheers. Tidied the post a bit (formatting was a bit wonky) and added a link to your main project site for you.
Title: Update 0.6.20120728
Post by: nemyax on July 29, 2012, 03:54:17 PM
Fixed vertex group bug
The exporter now ignores vertex groups that have nothing to do with exportable bones.

Forbade vertex weights set to zero
This may be temporary, as I'm in two minds about it. On the one hand, zero weights are garbage data probably left behind due to oversight. On the other hand, they are harmless unless a vertex has nothing but zero weights. Such vertices could be automatically declared unweighted if necessary, but MD5 doesn't support those. Which would you prefer?
Readme: added note about unapplied transforms
I haven't been able to reproduce the failure that Spielkarsten reported (http://www.katsbits.com/smforum/index.php?topic=404.msg2386#msg2386), but keeping the armature's object transforms applied is generally the Right Thing (at least in the MD5 export context, where you can't creatively abuse armature transforms for effect). So this is advised in the readme.

Download: http://arxendofsun.solarsplace.com/downloads/io_scene_md5.zip
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: 222464 on August 07, 2012, 08:09:27 PM
Hmm, I think I have the same problem as Spielkarsten. When I first tried to load the animation, the frame data was all messed up and the animation was deformed. I first thought it may be a problem with my model loader, so I loaded it with AssimpView and got the same results. I then cleared all armature transformations, and was able to correctly run the animation.

It only happens with an animation, the bind positions of the bones are fine.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: motorsep on August 07, 2012, 08:15:28 PM
Try using another script, which I fixed recently http://www.katsbits.com/smforum/index.php?topic=167.0
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on August 07, 2012, 08:44:15 PM
Agreed, at least that way you'll be able to work out exactly what's causing the issue. If your output is OK then you know something in relation to the script is causing issues (even if that means the mesh isn't prepped correctly for it).
Title: Update 0.6.20121130
Post by: nemyax on November 30, 2012, 12:04:56 PM
Changes:
Inline rather than start-of-line comments for export parameters
This caused issues with the 3ds max importer.
Higher precision for coordinates
Coordinate floats now have 10 decimal places for more compatibility with other tools.

Download: http://arxendofsun.solarsplace.com/downloads/io_scene_md5.zip
Works with Blender 2.64a.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on November 30, 2012, 12:22:54 PM
Thanks for the update nemyax.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: tea monster on October 14, 2013, 04:04:14 PM
I'm getting the dreaded "Mesh contains XX vertices with zero weights assigned". I've tried cleaning the weights and normalizing them and still getting the error message.  How do you search through and find the ones with no weights assigned?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on October 14, 2013, 05:44:25 PM
tea monster
Blender has a Show Zero Weights option in the toolbox (T). At least the more or less current versions do.
You should also make sure the mesh has no vertex groups other than those used by the bones. There was a related bug in the script at some point, and I don't remember if this old version has it. Have you considered updating? http://www.katsbits.com/smforum/index.php?topic=520.0
Blender is pushing 2.69, and pre-2.66 is quite old now.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: tea monster on October 14, 2013, 06:30:32 PM
Cheers, I found that weight cleaning tool.

What does it work up to? I've been using it with 2.63 as that is what it said on the thread title.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on October 14, 2013, 06:35:20 PM
What does it work up to?
It stopped working in 2.66. The fix would be trivial (likely just an extra argument in the from_object() function), but I decided to drop the older versions in the 0.7 update.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: tea monster on October 14, 2013, 06:43:56 PM
So, is there an update that works with the latest version of Blender? I was in tears thinking I'd have to reinstall 2.49.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on October 14, 2013, 06:51:14 PM
Just checked 0.7 with Blender 2.69RC, and it works fine (on a valid scene, hehe). Get the latest version from the link I posted above.
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: kat on October 14, 2013, 07:30:53 PM
Be careful testing on RC's.. scripts have broken innumerable times on public releases when they previously worked on RC's. And vice versa it should be noted. RC's results should be "advisory" or "subject to final confirmation" ;)
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: tea monster on October 14, 2013, 11:04:06 PM
Thanks very much!

Is there any way to specify the shader path in this script?
Title: Re: MD5 export add-on for Blender 2.63+ released
Post by: nemyax on October 15, 2013, 06:18:08 AM
tea monster
No, at this time you need to edit it manually. What do you think would be the best place to specify the path in Blender?