Tried to make a simple little “webapp” that converts Md2 models(the old quake 2 model format) into the json format(version 3) that is used by three.js.
You simply open the page, and then drag and drop a *.md2 file and it will be converted and a preview of the mesh should appear. You can then drag and drop jpg/png images for the texture to be previewed as well.
Left click and drag to rotate, right click and drag to move. Scrollwheel to zoom.
If it looks ok, enter a filename and hit “Save”.
It should now be downloaded(in Chrome at least, Firefox opens it in a new window).
You can then load in the json files into your three.js projects and use them as morphTargets.
MD2 to JSON Converter (a model to test with, if you don’t have one)
Example of converted model as morphTarget
I have only tested this in Chrome and Firefox, so not sure if it works anywhere else. Mostly done as an exercise for myself to understand the format, drag and drop and filehandling etc. But might be useful to someone else out there.
Edit (Mar 08, 2012): Looks like I had the exporter output a horizontally flipped model, should be fixed now. Thanks to @alteredq for letting me know.
Edit (May 11 2013): Updated it to export to the latest format(3.1).
Edit (Feb 10 2014): Fixed it, was broken due to some webgl changes in recent browsers.
Awesome!
I tested it with some models from
http://telias.free.fr/Models_menu.html
They came in just fine…
Thanks a lot for this amazing tool!
Could you please let me know where you get the MD2 models? looking for a place I can get few for free or buy.
Glad you find it useful! :)
It´s a really old format so it´s not used much nowadays.
But there are some models still around.
The most obvious is Planet Quake: http://planetquake.gamespy.com/View.php?view=Quake2.List&game=5&category_select_id=3
This one got a few: http://www.md2.sitters-electronics.nl/models.html
Some fangame that got a few: http://mb.srb2.org/forumdisplay.php?s=6b3f4a9fd6558d6393ef62f56adfc92a&f=72
I guess you could also use something like Milkshape 3d( http://chumbalum.swissquake.ch/ ) to convert between other formats. I think Md2 models had like a 4k polycount limit or something though.
When i download it with Firefox, it’s saved like “name.part” file. Why i can’t save it like .js? It’s only a .part file
Not sure why that is, I guess it´s just the way Firefox handles these “blobs” differently. But all the data is there and you can just rename the *.part-file to “whatever.js”.
I’ve got an issue with a two-materials model (a single texture seems to be used for the whole model), is it possible to convert it from md2 to json using your tool ?
You mean two textures are used on a single model? Do you have an example of such a model somewhere? Might be better to go with the three.js blender pipeline for such a model though.
This is really awesome work.
Do you think it’s possible to convert the normal indexes to the json format ?
I guess what you are after is something like this that is already in three.js by now:
https://github.com/mrdoob/three.js/blob/master/src/core/Geometry.js#L305
So you could just load the model and then do geometry.computeMorphNormals();
This example might be helpful: http://mrdoob.github.com/three.js/examples/webgl_morphnormals.html
Or did you mean something else?
Yes, you’re right there’s no need to used the pre-computed values.
Thanks
I’ve tried to use the converter under different versions of Three.js and since r50 the texture mapping fails as the mapping vertices seem to be wrong.
Do you have any idea of what has changed in Three.js since r50 that might have caused the problem ?
Yes, I think something with the texture-flipping changed in Three.js. Between 3.0 and 3.1 of the json-format: https://github.com/mrdoob/three.js/wiki/JSON-Model-format-3.1
I´ll see if I have time to change the converter to output v 3.1 instead, should be an easy fix.
In the meantime you could probably set texture.flipY = false;
You’re right the flipY trick worked just fine.