Exporting MD5 from Blender 2.5?

Anyone know of a script to export to md5 from Blender 2.5? I tried the old der_ton one for 2.49b from here but it just gives errors… :frowning:

hey! I need one too! now that I have moved to 2.5 for everything … im having tough luck getting my animations out.

MD5 export would be good, also MD2, MD3 and MS3D would be very useful. I think the Open Asset Import Library has most of these but i don’t think there was a export version for that addon though.

I’ve shifted to using IQM (Inter Quake Model format) which carries across animations. Still MD5 and it’s older counterparts seem needed by many applications, so I’m hoping someone will pick this up soon… :slight_smile:

I was not able to find an md5export script for blender2.5 with python 3.1. So I am working on ceonverting hte script from xreal

http://redmine.xreal-project.net/projects/xreal/wiki/Creating_Player_Models

I have figured out the syntax issues from python 2.6 to 3.1 but now I am up against the conversion to utilise the bpy library.

I have uploaded a copy of the current code. If someone has time to look at it and give me an idea of what I am up against to finish it I am happy to do the work to convert it.

http://djcj.org/code/md5_export.py

Thanks Kotaku!

I wish I knew enough to be of any help here, but please do post any developments on this thread so anyone searching finds it.

Fingers crossed! :slight_smile:

Does anyone have a link to info on how to migrate a script to bpy and python 3.1?

for reference sake.

http://wiki.blender.org/index.php/Extensions:Py/Scripts

info
http://wiki.blender.org/index.php/Doc:2.5/Manual/Extensions/Python

API:
http://www.blender.org/documentation/250PythonDoc/

Hey guys… there aren’t any ‘custom’ scripts like that available for 2.5 yet and many of the original authors are pretty much MIA or occupied with their own things now, so this is going to have to be something sorted out by the latest generation of Blender users.

If you get something sorted out let me know and I’ll add it to the tools page on KatsBits

I’m looking at the export_md5.py script again. I have figured out a bit more from the following thread.

http://blenderartists.org/forum/showthread.php?t=164765

I would appreciate if someone could advise the best way to convert the following code. It looks like the method of displaying the settings and export window might need to be completely revised for 2.5.



def show_gui():
  global EVENT_NOEVENT, EVENT_EXPORT, EVENT_QUIT, EVENT_MESHFILENAME, EVENT_ANIMFILENAME, EVENT_MESHFILENAME_STRINGBUTTON, EVENT_ANIMFILENAME_STRINGBUTTON
  global draw_busy_screen, md5mesh_filename, scale_slider
  global EVENT_SETTINGSFILENAME, EVENT_LOADSETTINGS, EVENT_SAVESETTINGS, settings_filename
  #global EVENT_CAM_MESHFILENAME, EVENT_CAM_ANIMFILENAME, EVENT_CAMEXPORT
  #global md5camanim_filename
  if draw_busy_screen == 1:
    bpy.BGL.glClearColor(0.3,0.3,0.3,1.0)
    bpy.BGL.glClear(bpy.BGL.GL_COLOR_BUFFER_BIT)
    bpy.BGL.glColor3f(1,1,1)
    bpy.BGL.glRasterPos2i(20,25)
    bpy.Draw.Text("Please wait while exporting...")
    return
  bpy.BGL.glClearColor(0.6,0.6,0.6,1.0)
  bpy.BGL.glClear(bpy.BGL.GL_COLOR_BUFFER_BIT)

  draw_reset()
  draw_newline()
  draw_addhorzspace()
  draw_setbase()

  draw_button("Cancel", EVENT_QUIT, "Quit this script")

  draw_button("Export", EVENT_EXPORT, "Start the MD5-export")

  draw_addhorzspace()

  # Andreas Kirsch 2007 - add batch gui stuff
  draw_button("Save Settings", EVENT_SAVESETTINGS, "Save the current settings", 2)
  draw_button("Load Settings", EVENT_LOADSETTINGS, "Load the settings from a file", 2)

  draw_newline()
  draw_addvertspace()

  md5mesh_filename = draw_string("MD5Mesh file:", EVENT_NOEVENT, md5mesh_filename.val, 255, "md5mesh file to generate", 3)
  draw_button("...", EVENT_MESHFILENAME, "Browse for an md5mesh file", 0.3 )

  draw_addhorzspace( 2 )

  scale_slider = draw_slider("Scale:", EVENT_NOEVENT, scale_slider.val, 0.01, 10.0, 0, "Adjust the size factor of the exported object and camera anim", 4)

  draw_newline()
  draw_addvertspace()

  draw_button( "Insert Animation", EVENT_INSERT, "Insert an action/animation to export", 2 )
  draw_addhorzspace()
  draw_button( "Insert All Animations", EVENT_INSERT_ALL, "Insert all actions/animations", 2.5 )
  draw_button( "Remove All Animations", EVENT_REMOVE_ALL, "Remove all actions/animations", 2.5 )

  """bpy.Draw.Button("Export Camera!", EVENT_CAMEXPORT, 2 * space + 2 * button_width, 3 * button_height, 2 * button_width, button_height, "Start the Camera-export")
  md5camanim_filename = bpy.Draw.String("MD5Camera file:", EVENT_NOEVENT, 2 * space +  4 * button_width,3 * button_height, 3 * button_width, button_height, md5camanim_filename.val, 255, "MD5Camera-File to generate")
  bpy.Draw.Button("Browse...", EVENT_CAM_ANIMFILENAME, 2 * space + 7 * button_width, 3 * button_height, button_width, button_height, "Specify md5camera file")
  """

  draw_newline()

  index = 0
  for info in animation_infos:
    draw_newline()

    draw_button("X", index | EVENT_DELETE_FLAG, "Delete an animtion", 0.3 )
    info.action_index_menu = draw_menu( "Actions:%t|" + get_actions_menutext(), index | EVENT_ACTION_FLAG, info.action_index_menu.val, "Name of the Action that should be exported (IPO name prefix)", 2 )
    info.startframe_slider = draw_number( "Start:", EVENT_NOEVENT, info.startframe_slider.val, 1, info.get_action_endframe(), "Start frame to export from", 1.2 )
    info.endframe_slider = draw_number( "End:", EVENT_NOEVENT, info.endframe_slider.val, info.startframe_slider.val, info.get_action_endframe(), "End frame to export from", 1.2 )
    info.target_filename = draw_string("", EVENT_NOEVENT, info.target_filename.val, 255, "md5anim file to export the action to", 3 )
    draw_button("...", index | EVENT_ANIMFILENAME_FLAG, "Browse for an md5anim file", 0.3 )

    index += 1

# try to load settings from the scene
load_settings_from_scene()

bpy.Draw.Register (show_gui, handle_event, handle_button_event)


why convert md5 exporter from XReal if Kat’s exporter is awesome? And we have Kat’s exporter with advanced GUI, so maybe it would be possible to adopt that script for Blender 2.5 ?

Just to clarify, I only host the script, I wish I was clever enough to have written it :wink:

iirc the MD5 scripts had more than a few modifications done to it to cater for some specific features of xReal which have sort of taken it away from it’s original format and feature set.

I’d certainly agree that in modifying that version could inadvertently ‘pollute’ - for want a better word - the exporting of a core, clean and standardised MD5 data-set; we need to be careful to maintain that at all costs - look what happened to CAL3D it became a complete mess later on because so many variations of it were published and no-one knew what the heck was what.

gotcha… we use MD5 script from your site and Black just added more GUI to it.

Oh I’m not saying it shouldn’t be done… just wanted draw attention to making sure we’re careful not to modify something in such a way as it takes a tangent to a solid standardised format. This is one of Blenders ‘problems’ in some ways… being open source makes it tricky to keep tabs on these third party tools and scripts.

so the exporter that is on your website is the one that writes clean md5s’?
on the other note there is a functional (or at least it was a month ago) IQM (Inter-Quake Model format) that works with Blender 2.5. The GUI is not as great as blender2md5, but it works.
http://lee.fov120.com/iqm/

Yes, it’s clean in the sense that it’s the original script der_ton wrote up (and maintained) for exporting models to MD5 in it’s original context, that of idtech4 games (Doom 3 et-al).

Thanks for the info. I’m happy to work on the exporter from Kats site. I didn’t realise it is more advanced than the xreal version.

BTW, thanks for the link. It looks like exactly what I am looking for. Maybe the job is already done?

I had to modify the blender2.5 script to change “Mathutils” to “mathutils” to get it to install via “File->User Preferences->AddOns”.

Using the latest blender svn I get this message when I enable the script by checking the checkbox in the “User Preferences->Addons” window:

Traceback (most recent call last):
  File "/usr/local/src/blender/blender-svn/blender/release/scripts/ui/space_userpref.py", line 1001, in execute
    if info.get("blender", (0, 0, 0)) > bpy.app.version:
TypeError: unorderable types: str() > tuple()

When I open “File->export” menu I see this message and the “iqm/iqe export” menu item doesn’t show up.

Traceback (most recent call last):
  File "/usr/local/src/blender/blender-svn/blender/release/scripts/modules/bpy_types.py", line 580, in draw_ls
    func(self, context)
  File "/usr/local/src/blender/blender-svn/blender/release/scripts/addons/iqm_export.py", line 905, in menu_func
    default_path = bpy.data.filename.replace(".blend", ".iqm")
AttributeError: 'Main' object has no attribute 'filename'

The last message comes from this function:


def menu_func(self, context):
    default_path = bpy.data.filename.replace(".blend", ".iqm")
    self.layout.operator(ExportIQM.bl_idname, text="Inter-Quake Model (.iqm, .iqe)").path = default_path

I had to change this line:

default_path = bpy.data.filename.replace(".blend", “.iqm”)

to

default_path = bpy.data.filepath.replace(".blend", “.iqm”)

Now I see the export option in the export menu.

Updated iqm_exporter for latest blender svn is here:

http://djcj.org/code/iqm_export.py

Can anyone tell me what this error means?

I have the default makehuman mesh with the Default Meta-rig armature which I have manually resized to fit the mesh. Am I missing a step or two before exporting?


Traceback (most recent call last):
  File "/usr/local/src/blender/blender-svn/blender/release/scripts/addons/iqm_export.py", line 895, in execute
    exportIQM(context, path, self.properties.usemesh, self.properties.usebbox, self.properties.usescale, self.properties.animspec)    
  File "/usr/local/src/blender/blender-svn/blender/release/scripts/addons/iqm_export.py", line 843, in exportIQM
    bones = collectBones(context, armature, scale)
  File "/usr/local/src/blender/blender-svn/blender/release/scripts/addons/iqm_export.py", line 601, in collectBones
    worldmatrix = armature.matrix
AttributeError: 'Object' object has no attribute 'matrix'