md3 exporter progressing

I have been working on an MD3 exporter to use in the Worldforge project (see http://www.worldforge.org). It is largely based on Bob Holcomb’s script (see http://bane.servebeer.com/programming/blender/)

You can find it here:
http://home.netspeed.com.au/mcginnes/md3-export-0.2.py

Some feedback would be useful.

Damien

Great to see someone working on this. Though I am unable to export anything, I get this from the console:
MD3 Frame
Min Bounds: [0.0, 0.0, 0.0]
Max Bounds: [0.0, 0.0, 0.0]
Local Origin: [0.0, 0.0, 0.0]
Radius: 0.0
Name: FRAME1

Traceback (most recent call last):
File “/J’s stuff/blender stuff/Python scripts/md3-export-0.2.py”, line 873, in my_callback
save_md3(filename)
File “/J’s stuff/blender stuff/Python scripts/md3-export-0.2.py”, line 838, in save_md3
process_surface(obj,md3)
File “/J’s stuff/blender stuff/Python scripts/md3-export-0.2.py”, line 798, in process_surface
vindices = index_dict[vertex.index]
KeyError: 68

yeah, its currently set up to only export selected items.

So just select your mesh before exporting.
Also tags are exported from empties that start with tag_

It needs a gui, and some decent error reporting, but that can wait.

Damien

actually I made a couple of changes that might have an effect on your problem. Try it now.

If not, can you generate a .blend that shows the problem and I’ll take a look.

Most likely you have vertices in your mesh that arent part of a face.
now I report that as an exception and continue, skipping that vertex

Damien

It’s working here.

I needed to set the number of frames to export in constants area of the scripts, but works quite well…

I had a jumping animation (terribly done, just for quick tests with x export files) to which I had applied ik solvers to empties, so to leave the feet glued to fllor and that. And moving all bones but leaving origing at 0,0,0 , to make the jump.

It all works perfectly.Curiously, it later on shows the mesh perfectly smooth if I set only the one frame that comes default…if I change it to 40, it unwelds every triangle…i was quite surprised, and then I remembered. Md3 breaks wherever there’s a sharing border of UVs, reason why many md3 artitst used to hide the UV seams in hiden part like bellow the chin in the neck and all.

I didn’t remember either that animation did not have UVs, just a per fece uv mapping, so, every face had a single one-face-group, that’s why appears a geometry seam in every triangle contour. I’d expect just the uv chunks borders in a well uv mapped model.

I suppose the key is like it was at times (but i am not totally sure about this) , that is, hidding theuv seams in parts of the mesh quite hidden to the gamer.

Correct me if I’m wrong…

I remembered when seing your code (I am not a coder) the comment about the routine duplicating verts as md3 does not support faceuv, which I suppose is the old thing I think I know bout not support of shared uvs for md3.

Also, my file is one md3 without shaders , nor tags, nothing. Just my interest in md3 is only using as a better md2, without the vertex trembling(I think for not using floats) seen in engines. And a higher polycount limit (8192 triangles, 4096 tris, even I think u set that as the limits in the script) That is, not only I don’t use special features, I even don’t use parts, chunks.All is a single piece model, as I prefer to bend the shoulder skin and stuff with my bones and weights, so what I really do is bake that into an interpolated single piece animation.

And to report that it works, happily. Only would need to know that being the output for the engines only reading md3, u have to uv map the human model carefully to leave the uv seams burried in hidden areas.

But that, like some other stuff, is limited due to the format. The script is working perfect here.

[There are a BUNCH of engines accepting md3 format(apart from q3 series) ]

Congrats! :slight_smile:

Good thing…now Blender exports, and I have tested that does correctly, weighted bone animation with *.x (and md5 and cal3d, which I have not tested, but it’s said work very well) , and md2, md3, for vertex animation.(which is also smooth)

[ To put an example of formats not allowing weights, you can think of Milkshape3d, and Halflife 1 formats. ]

Quite the whole set for exporting smooth (all that export or bake the weights) character animations. :slight_smile: :slight_smile:

thanks. I was the one who cleaned up the cal3d exporter too. :slight_smile:

It would be good to check tags because I guessed at how to put the values in the ‘axis’ field. It is represented by 3 triples, so I took them to be the three rows of the rotation matrix. Good a guess as any.

As for UVs you are right. Anywhere there is a uv seam, there will be duplicated vertices. What is the effect of this on screen - I didnt quite understand what you were trying to say.

It is also possible that threre is a problem with normals - I havent checked them that well

Damien

“Thanks. I was the one who cleaned up the cal3d exporter too.”

hey, cool 8)

“It would be good to check tags because I guessed at how to put the values”

I’m afraid I don’t know how to do tags, I know from a theory point of view, but never did an md3 that was other that one single piece model without all the q3 arena nitty gritty stuff…I used for other engines, as a “better than md3” format, interpolated full unbroken meshes, that’s it.

“As for UVs you are right. Anywhere there is a uv seam, there will be duplicated vertices. What is the effect of this on screen - I didnt quite understand what you were trying to say.”

I’ll explain it. Whenever you duplicate a vertice, you are breaking the mesh there. That is, visually is generated a crease. very similar to a shading seam. In Max, the stuff is known as smooth groups (In Maya, hard egdes, better way to deal it,edges) an smooth group border is a place where the shading has a crease, like a cut. Visually, you don’t distinguish a smooth group crease from a geometry broken edge (duplicated vertices along an edge) .Indeed, I only know from the artist point of view, and depending on the package, I think some even actually break the mesh to make the smooth groups.

One way or the other, is a bad artifact. As you end up seing probaly a clean cut all along the nose, mouth…for example when used the common thing of making right and left side of human face, be sharing vertices (mirroring one side and putting it on top of the other, matching relative uvs.Saves texture space.) but happens every where there’s a uv border. Ie, in the interior of legs.

The key with that problem is put the uv seams where they are seen as a natural thing.Ie, in the interior side of trousers, making in texture a painted sewed border. Or the border of a helmet, the borders of a shirt, etc.

As u see, md3 demands for an uv mappin careful planning. Is not blender or your exporter’s fault, is how is done md3.

So, doing it in a planned way (of course, it will make you loose some advantages) it can be dealed. Usually and already mapped generic 3d model wont do.

But imho, is simply great that now md2 and md3 do have these formats. For low end pcs , is simply the way to go, as no bones weights calculation needed, while still see smooth bending in shoulders and joints, as the can originally done with bones and weights, as they at last get baked as vertex animation, interpolated with linear or spline interpolation.

What I meant is thatnks to you and bobo, now it also have the two main vertex animation exports for games. Having those and the 3 main and more extended bones and weights ones : *.x , cal3d, md5, it practically can export to any engine. Which imho is great. :slight_smile:

the list of the game engines that -in theory- could be now(thanks to these exporters) used with blender would make me fill a whole thread with them with just the list, so I’ll avoid that :wink:

“It is also possible that threre is a problem with normals - I havent checked them that well”

I don’t know…the export was simple…well…when exported on frame only, I’d say normals where perfect in the external viewer… when exported the animation, it took then the duplicating vertices thing with UVs, so as I had made a per face automatic mapping (all triangles matching in one !) it showed no normals ,all flat, so I can’t tell you…
I can only say that from what I saw, seemed to works as expected.

There’s a freeware tool, called npherno MD3 Compiler (or nMD3c , nPherno MD3c ) that allows to compile an md3 from exported lwos, 3ds, asc or ase, or loading just an md3 and do some editing…one is “rebuild normals” :wink:

It was used with first md3 export in Gmax, a Id Software exporter for gmax called tempest. later on, was made another -available for use in comercial projects, opposite to Id’s Tempest- gmax md3 exporter which had not the normals problem ( mojo.gmaxsupport.com )

cool, i put this in .blender/scripts and used it very nicely to export a helicopter i made, and that works. Only problem though, is that the texture is not retained. Should it have been? If I export to .obj, it does retain the uv texture info, and I can import the .obj, and its perfect. So, should I be doing something that I’m missing? Or is the script not dealing with uv texturing?

thanks a bunch! (im so happy to have this script already)

-pandora

Hi,

Pandora pointed me to this script, and I’ve extended it to export blender materials as MD3 shaders. Specifically, TexFace type materials are exported as direct texture filename references in the MD3. Other material types are exported using the material name. The latter allows the model to reference Q3 shaders instead of plain textures.

I’ve also slapped on a little GUI that allows to configure the internal paths in the MD3 file and a couple of other options.

I haven’t heard from the original author yet, so this isn’t any sort of “official” update to the exporter; it’s just a branch/hack that hopefully can make life easier for modelers. Please send feedback to my email: arsenij [at] gmail [dot] com

The modified script can be downloaded from this page:
http://www.freewebs.com/estrato/misc.htm

Here is a direct link, if you’re not interested in reading the credits:
http://www.freewebs.com/estrato/scripting/md3-export-0.2-lgt.py

(sometimes the freewebs host is unreachable for some people for no apparent reason, but the links are valid)

no point forking the exporter. if the change works, then good.
I havent really used it much since getting it going.

Damien

Great!

Thanks everyone involved :slight_smile:

I’ve figured I’d better bring up this old post instead of making a new one since what I want to do is mostly around this script.

According to replies in here this script exports animation. I’ve figured it only exports 1 frame to me, according to its output. What transformation does animation or/and model has to be put into to make it export animation? (md3 uses vertex anim in case you’re not familiar with md3).

At this time I want to export a cloth anim of a flag using SoftBody effects on a plane. Can that be done, and what edits have to be done on the model to make it so.

If additional scripting is required for what I’m asking for, where should I look at? I’m not familiar with python but I have little experience in perl so I may manage learning some of it.

thank you.

This is a godsend! Just today I was getting frustrated because the only way I could muck about with quake was with the textures. What are the practicalities of going from an animated blender model to a usable quake 3 model?

what I currently wanted to do, turned out it could be done with no animation and only 3d party game engine shaders, however, I’d be nice to have any addition practical information regarding this script from ppl that have experience on it.

(unless I try diving into scripting myself, it doesn’t sound such a bad idea considering the horrible status of different model formats in game design)

PS. there’s mention in this thread about uv mapped textures being exported fine. I tried one by following the normal blender procedure and checking “texface” for rendering but the result wasn’t good. I’ll try again but any info on that too would be appreciated.

I remember well. That last modification done above, worked great for me. I had a test model, imported as OBJ into blender (modeled and uvmapped outside Blender, but that’s unimportant) , weighted it, and did a basic animation. Well, then I exported the way i prefer with md3 files: as a solid model, not built by parts (like Quake3 models were originally ) , and it did seem to do well the bendings and interpolation, like a “better md2”, which was my purpose.

Remember that both md2 and md3 formats do force an split were a vertex has 2 UV coords. But said by someone , it can be avoided by code, or something. But I’m no coder. So, when I do md3 files, I do hide very well seams in non seen 3d places, as will actually be a crease in smoothing normals.

Oh, so, yes, it does export animation quite well. Maybe you are getting confused with another md3 plugin out there, which does the opposite, import into Blender, and which for now only imports statics.

i did some modifications to read/write more parts of md3 format-files. The plugins can be found in the tool directory: http://otc6.svn.sourceforge.net/viewvc/otc6/trunk/tools/