Doom3world

The world is yours! Doom 3 - Quake 4 - ET:QW - Prey - Rage
It is currently Mon May 20, 2013 2:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 65 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: MD5 Importer for Blender
PostPosted: Thu Oct 21, 2004 9:57 pm 
Offline
Plasma Spammer
User avatar

Joined: Fri Jun 27, 2003 11:24 pm
Posts: 2712
Location: Munich, Germany
http://home.mnet-online.de/der/blender-md5importer.rar

Outdated info:
With a bit of a delay, finally here it is:
http://home.mnet-online.de/der/blender-md5importer.rar
Based on an importer by Bob Holcomb, that had the mesh import working. I modified it to handle MD5 version 10, and added the skeleton import (which turned out to be quite non-trivial) and vertex group generation.

It doesn't import md5anims currently.

How to:
Start the script, select the md5mesh file and press "Import".
After the import, the meshes will not be parented to the armature yet.
You have to do that manually since there is currently no way to
do that with a python script.
Parent it like this:
- select a mesh
- shift-select the armature (both the mesh and the armature should be
highlighted, but the armature has a slightly brighter color)
- press CTRL-P. Select "Armature" from the upcoming dialog, in the next
dialog press "Don't create vertex groups".
- repeat this for each mesh that the model consists of

If vertices don't move with the armature, you probably have forgotten to parent
the mesh to the armature.


Image
Hey, this isn't hell! What am I doing here? *scratches head*
Aw, look what they've done to my pants! :x

_________________
Image Staff
Modelviewer | 3DSMax<->MD5 | Blender<->MD5


Last edited by der_ton on Tue Jan 10, 2006 12:21 am, edited 1 time in total.

Top
 Profile E-mail  
 
 Post subject:
PostPosted: Fri Oct 22, 2004 5:58 am 
Offline
"...mostly harmless?!"
User avatar

Joined: Fri Nov 09, 2001 12:00 am
Posts: 5139
Location: UK
Cool to see this one final out of beta and appologies for not being around for final testing..!

_________________
Modeling and modding tutorials and tips


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 8:40 pm 
Offline
is connecting to Doom3world.org

Joined: Wed Nov 03, 2004 7:08 pm
Posts: 2
It works fine, thanks :D

A md5anim´s import would be very interesting.

Byes.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 20, 2004 6:45 am 
Offline
has joined the game

Joined: Fri Nov 19, 2004 5:04 am
Posts: 31
Location: Arlington, Texas, USA
I'm new to blender; how do you open the .tga file with the character's skin?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 20, 2004 6:54 pm 
Offline
"...mostly harmless?!"
User avatar

Joined: Fri Nov 09, 2001 12:00 am
Posts: 5139
Location: UK
geppy wrote:
I'm new to blender; how do you open the .tga file with the character's skin?
Have a read thru this thread as it outlines 'step by step' what you need to do to get a model into D3. There is a section in there though that runs you through how to assign a texture to a material and a material to a mesh.
http://www.doom3world.org/phpbb2/viewtopic.php?t=7430

_________________
Modeling and modding tutorials and tips


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Sat Nov 20, 2004 7:11 pm 
Offline
has joined the game

Joined: Fri Nov 19, 2004 5:04 am
Posts: 31
Location: Arlington, Texas, USA
Thanks. :D


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 12:14 am 
Offline
is connecting to Doom3world.org

Joined: Fri Sep 17, 2004 10:42 pm
Posts: 5
Location: Glasgow, UK
Hi,

Are there any plans to add importing of MD5Anims?

If not, is there any intermediary format I can export MD5Anims to and then import into Blender?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 1:00 am 
Offline
Plasma Spammer
User avatar

Joined: Fri Jun 27, 2003 11:24 pm
Posts: 2712
Location: Munich, Germany
Sorry, I'm not sure if or when I'll do that.

There's a BVH importer script by Bob Holcomb, that's a format used in motioncapturing mostly. If you can export your animation to BVH then you should be able to import it into Blender, if everything goes well.

Bob Holcomb's website is http://bane.servebeer.com/index.html

_________________
Image Staff
Modelviewer | 3DSMax<->MD5 | Blender<->MD5


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 1:02 am 
Offline
is connecting to Doom3world.org

Joined: Fri Sep 17, 2004 10:42 pm
Posts: 5
Location: Glasgow, UK
Thanks, I'll take a look.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 1:51 am 
Offline
picked up 100 armour

Joined: Sat Sep 25, 2004 8:39 pm
Posts: 149
Location: Central Texas
I downloaded the modelviewer, the import script, and the export script. The modelviewer works great btw. I unzipped the files and placed the scripts in blenders scripts directory. I created the PYTHONPATH variable and set targets accordingly. The export script shows up in the scripts window, but the import script doesn't. Has anyone else had this problem?

I'm running Blender 2.36 on a Windows XP Pro machine, with Python 2.34 installed to C:\Python23. I'd really like for this to work, that way I wouldn't have to try and learn maya :lol:

Any help is appreciated.

Thanks


Johnny


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 10:29 am 
Offline
Plasma Spammer
User avatar

Joined: Fri Jun 27, 2003 11:24 pm
Posts: 2712
Location: Munich, Germany
The import script doesn't have the header info that is needed for Blender to recognize it and make it available through the menu.
You can either start it conventionally (open a text edit window in one of Blender's windows, load in the script and start it with Alt-P), or you can copy&paste this header in the beginning of the importer .py file. That should enable Blender to recognize it (I just whipped this up and didn't check):

Code:
#!BPY
"""
Name: 'Doom3 MD5 Import'
Blender: 235
Group: 'Import'
Tip: 'Import md5mesh files'
"""

_________________
Image Staff
Modelviewer | 3DSMax<->MD5 | Blender<->MD5


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 9:42 pm 
Offline
picked up 100 armour

Joined: Sat Sep 25, 2004 8:39 pm
Posts: 149
Location: Central Texas
I tried the header but that didn't work, however, opening it up via the text window did work. Thanks for your help der_ton, and thanks for the scripts. Back to work, maybe someday I'll have something to show :lol:


Thanks,

Johnny


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 6:10 am 
Offline
picked up a pistol

Joined: Thu Mar 17, 2005 3:21 am
Posts: 61
I just spent about an hour making this 2.4-compatible. Replace the section starting on line 508 (the armObj definition) until just before the
"#dump the meshes into blender" bit with:

Code:
        armObj = Object.New('Armature', tempstring)
        armData = Blender.Armature.Armature("MD5_ARM")
        armData.drawAxes = True
        armObj.link(armData)
        scene = Blender.Scene.getCurrent()
        scene.link(armObj)
        armData.makeEditable()
       
        for bone in md5_bones:
            print scale
            bone.blenderbone = Blender.Armature.Editbone()
            headData = Blender.Mathutils.Vector(bone.bindpos[0]*scale, bone.bindpos[1]*scale, bone.bindpos[2]*scale)
            bone.blenderbone.head = headData
            tailData = Blender.Mathutils.Vector(bone.bindpos[0]*scale+bonesize*scale*bone.bindmat[1][0], bone.bindpos[1]*scale+bonesize*scale*bone.bindmat[1][1], bone.bindpos[2]*scale+bonesize*scale*bone.bindmat[1][2])
            bone.blenderbone.tail = tailData
            if bone.parent != "":
                bone.blenderbone.parent = md5_bones[bone.parent_index].blenderbone

            #rotate the bones correctly through this HACK (yeah it's ridiculous ;)
            #could probably be optimized a bit...
            boneisaligned=False
            for i in range(1, 359):
                boneisaligned=False
                m = Blender.Mathutils.Matrix(bone.blenderbone.matrix)
                mb = bone.bindmat
                cos = vector_dotproduct(vector_normalize(m[0]), vector_normalize(mb[0]))
                if cos > 0.9999:
                    boneisaligned=True
                    #print m[0], mb[0]
                    break
                bone.blenderbone.roll = i
            if not boneisaligned:
                print "Eeek!! ", bone.name, boneisaligned
            armData.bones[bone.name]=bone.blenderbone
        armData.update()
        armObj.makeDisplayList()
        scene.update();
        Blender.Window.RedrawAll()


NOTE: the headData and tailData definitions need to be on one line, make sure they end up that way when you c&p from the post.

as best I can tell, everything works properly. I moved a few bones, and the mesh deforms properly (as best I can tell). If anyone sees any issues, I'll try to get them sorted out. I did just try to learn python, old blender armatures, and new blender armatures at the same time, after all.

_________________
I'm not cynical, I'm optimistically challenged.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 07, 2006 11:16 pm 
Offline
Plasma Spammer
User avatar

Joined: Fri Jun 27, 2003 11:24 pm
Posts: 2712
Location: Munich, Germany
Nice work, thanks!
I'll take a look at the new API and update the scripts soon. If your modification is kept you'll be credited ofcourse.
In the meantime feel free to offer the script with your modification as a download and post the link here.

_________________
Image Staff
Modelviewer | 3DSMax<->MD5 | Blender<->MD5


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue Jan 10, 2006 12:20 am 
Offline
Plasma Spammer
User avatar

Joined: Fri Jun 27, 2003 11:24 pm
Posts: 2712
Location: Munich, Germany
http://home.tiscali.de/der_ton/blender-md5importer.rar

- works with 2.40, thanks to PaladinOfKaos
- parenting of meshes to armature is now done by the script, thanks to api improvement

The old version is in there too because Blender2.37 is still of use until the exporter is updated for 2.40 too.

_________________
Image Staff
Modelviewer | 3DSMax<->MD5 | Blender<->MD5


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue Jan 10, 2006 7:08 pm 
Offline
picked up a pistol

Joined: Thu Mar 17, 2005 3:21 am
Posts: 61
I've been trying to get the exporter going, too, but I've been having issues with the bones... The whole skeletal system probably needs to be re-written, preferably to take advantage of blenders built-in matrix and quaternion functions, since its already been written (blender and D3 use the same coordinate system, right?)

_________________
I'm not cynical, I'm optimistically challenged.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 10, 2006 8:18 pm 
Offline
Plasma Spammer
User avatar

Joined: Fri Jun 27, 2003 11:24 pm
Posts: 2712
Location: Munich, Germany
I'm going to look into that too. If you have any results can you send me what you have?

_________________
Image Staff
Modelviewer | 3DSMax<->MD5 | Blender<->MD5


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 12:12 am 
Offline
picked up a pistol

Joined: Thu Mar 17, 2005 3:21 am
Posts: 61
I'll send you a copy as soon as I get home.

quick summary:
Bones export fine if roll is zero, any roll garbles the quaternion. It seems to be outputting the mesh fine, since a test with a non-rolled skelleton gave a fine mesh, but I haven't really looked at the mesh code, other than to change a couple of syntax differences, so I don't know for sure.

_________________
I'm not cynical, I'm optimistically challenged.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 2:22 am 
Offline
picked up a pistol

Joined: Thu Mar 17, 2005 3:21 am
Posts: 61
grr...

After two days of searching, I can't seem to find any of my modified versions of that script... I must have deleted them at some point...

Sorry

_________________
I'm not cynical, I'm optimistically challenged.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 8:34 am 
Offline
Plasma Spammer
User avatar

Joined: Fri Jun 27, 2003 11:24 pm
Posts: 2712
Location: Munich, Germany
I didn't work on it that much yet, just got the skeleton export going but there's a problem with the orientation, maybe the same problem you mention.

I didn't update the mesh export section yet, it doesn't give an error but the exported meshes are empty, 0 vertices. If you can remember what you updated there, that would be cool.

_________________
Image Staff
Modelviewer | 3DSMax<->MD5 | Blender<->MD5


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 65 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group