Game Editing > Scripts & Support
[MD5] EXPORT script for Blender 2.6x (OPEN)
der_ton:
Hi, I'm the guy who wrote the script for the 2.4x Blender version. I think you could save some time by reusing some of it and just updating the parts that interface with Blender to get the data out of Blender and into the python script's structures, and from there the already existing md5 output will work, independently of the changes in Blender2.5.
I can fully understand that you don't want to use the existing script though. Programming is fun, and programming your own stuff and going all the way on your own legs (or brains, hehe) is much more fun than reusing someone else's stuff (even though I like to think my old script is not too bad code, you're right, python makes it a bit more difficult if the script documentation isn't that good).
on topic: The file format apparently was laid out so there's a minimum of preprocessing that the game engine has to do on load-time. The data in the weights is indeed xyz positions, in bone-space of their respective bone. A vertex (in the md5 naming scheme) doesn't have a position because there is no fixed position in an animated mesh. A md5mesh vertex' position is determined by its position relative to its (possibly multiple) influencing bones, and these relative positions are those 'weights' positions. There are pages on doom3world.org and I also think on http://www.modwiki.net/ that describe the semantics of the md5 file contents. Sorry if that sounds rude, but how did you write md5 rendering code for your engine if a detail like that raises questions?
keless:
Hey der_ton-- yes, thats actually what I'm doing right now (using the module registration code from the md3 loader, but converting your 2.4 code into 2.5)
On that note, does anyone know what the Blender 2.5x translation of the 2.4x call to
--- Code: ---data.getVertexInfluences(face.v[i].index)
--- End code ---
would be?
EDIT:
I'm reading some of the other 2.5x exporters (like export_obj.py) and I'm thinking the 'bone' names associated with the vertex are found as the vertex group names? So a vertex with 4 groups named 'g1, g2, g3, g4' would be associated with bones 'g1', 'g2', 'g3', and 'g4' and somewhere there will be a per-vertex list of weights.
So to get a list of bones associated with a vertex, it looks like syntax might be:
--- Code: ---mesh = someMeshObj
for vert in mesh.verts:
boneWeights = [0] * len( vert.groups )
for vgIdx in range(len(vert.groups)):
boneWeights[vgIdx].objVgIdx = vert.groups[vgIdx].group
boneWeights[vgIdx].weight = vert.groups[vgIdx].weight
for weight in boneWeights:
weight.name = mesh.vertex_groups[ weight.objVgIdx ].name
--- End code ---
keless:
Anyone know how to remove objects from a bpy_prop_collection in 2.5x?
specifically:
--- Code: ---nobj = obj.create_mesh(bpy.context.scene,True,'PREVIEW')
faces = nopj.faces
for face in faces[:]:
#some code here
faces.remove(face.index) #ERROR HERE
--- End code ---
in the 2.4x md5 script, he iterates over the list of faces in a mesh, and removes each face as it's processed. However, with the 2.5x code the list of faces is such that the array of faces held by the "preview" object (or by bpy.data.meshes['meshname'].faces ) is 'protected' and remove() function exists but fails:
"TypeError: bpy_prop_collection.remove() not supported for this collection"
kat:
Take a look on the ModWiki page for bone info because there are significant organisational differences between older and newer MD5's and their data structure. I just had a look at the file I posted above vs the files contained in the source zip on the same page, one's a v6 file, the other a v10 (something I need to correct as I missed that one) :-\
keless:
Yeah, the MD5s I've been working with are all v10, and der_ton's export script is v10 as well.
I don't know of any versions greater than v10, but I'm only planning on getting 10 to work (ignoring older versions) at the moment.
I'm skipping animation for right now, but I've got a valid md5mesh output going. However, the texture coordinates seem wrong and some of my test files fail to export due to index OOB error.
The file is getting kind of long, is there a way to add attachments to forum posts, or should I set up a public host for sharing?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version