1
Resources and Tools / [TOOL] OBJ to M2 converter + Sources
« on: August 13, 2013, 10:00:21 pm »
Hello Modcraft,
I'm happy to share my first "good" tool. A OBJ to M2 converter, which permit to create new M2s !
I have to thank several people for that, so :
Thanks schlumpf, gamh, relaxok, mjollna, LIMEEE, Zim4k, allifeur, and all people who contributed to wowdev wiki.
I don't want this tool to be shared anywhere else than on modcraft for now.
Vertex format : "v X Y Z"
Normals format : "vn X Y Z"
Vertex Textures format : "vt U V"
X Y Z are floats. There must be only one space between v, X, Y and Z, else it'll crash ( my bad ).
Same for U and V.
Face format : "f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3"
Same there, any extra space and it'll crash.
If it crashes with your OBJ file ( which shouldn't happen if those rules are followed ), just post and tell me if there's an error + send me the obj file so I can look at it.
Export settings for 3DS Max
[attachment=2:39gjq86j]objsettingsmax.png[/attachment:39gjq86j]
Export settings for Blender ( old )
About Materials
There must be 1 material per group( not more, didn't test about less ). Currently, there is a "ugly" hack as I didn't do the MTL Parsing. The texture name is extracted from the "usemtl" statement inside a .obj file.
Meaning, if you have in your OBJ file "usemtl wood", it won't look in the mtl file for the material wood etc.., it'll just use "wood.blp".
Depending on the software you use, material name could be different than the actual texture filename, so be careful with that, i'll implement that on the following days.
It's a command line tool, here's the usage :
OBJtoM2.exe MyFile.obj MyModel pathtomytexturesinthempq
MyModel argument shouldn't have any extension ( else it'll lead to strange filenames )
pathtomytexturesinthempq must have a at the end.
That's all I think, enjoy, and don't forget to post screens of the things you do with that, and report all bugs you might encounter !
[attachment=3:39gjq86j]OBJtoM2.rar[/attachment:39gjq86j]
UPDATE : Working for WinXP 32 bits version
[attachment=1:39gjq86j]OBJtoM2.rar[/attachment:39gjq86j]
This new version doesn't add texture automatically, there is a built-in console that permit you to add textures / textureunit / renderflag.
It also permits to add reflect on models quite easily.
Garthog
UPDATE : Sources
I do not really have time to work on that anymore. It has more potential than only a bad command line tool. So here are the sources. You're free to change it, though if you do so, you're strongly encouraged to share the modifications.
Such a tool wouldn't exist without the help I got from the community, and previously shared things, so let's continue that mind.
[attachment=0:39gjq86j]OBJtoM2_SOURCE.rar[/attachment:39gjq86j]
-> Proposed todo list :
--> The CMD sucks
--> Make a more generic format to which M2 will be loaded.
--> FBX ?
--> 3D View + QT ?
Have fun & good luck !
I'm happy to share my first "good" tool. A OBJ to M2 converter, which permit to create new M2s !
I have to thank several people for that, so :
Thanks schlumpf, gamh, relaxok, mjollna, LIMEEE, Zim4k, allifeur, and all people who contributed to wowdev wiki.
I don't want this tool to be shared anywhere else than on modcraft for now.
What is currently supported by this tool ?
- Geometry / Normals / Texture coordinates import from OBJ
- Each "group" is imported as a new geoset. For each geoset, a render flag is created.
- Each material is imported as a texture
- Collisions / Bounding boxes are calculated at M2 creation ( thanks to Mjollna )
What is unsupported by this tool ?
- Animations & Rigging
- Particles & Ribbons
- Geosets calculations ( centermass etc.. )
- MTL Parsing ( it doesn't parse MTL files )
- Different LOD ( ModelName00.skin is the only skin generated )
- Cameras
How to use ?
OBJ Format
- No extra space is allowed in the file. Having the vertex defined like that "v 1.0 1.1 1.3" will make the converter crash. ( It's mainly for 3DS Max )
- UV Map should stay in the [0,1] space
- UV Mapping should be done "per vertex". WoW doesn't support multiple texture coordinates per vertice
- Smoothing must be done through "Normals welding" ( and not vertices welding ). This is 3DS Max option, idk about blender.
- Normals should be calculated by the 3D software
- Objects should be exported as "group" ( g in obj file )
- Probably other things, i just don't remember atm. Anyway, formats below must be respected
Vertex format : "v X Y Z"
Normals format : "vn X Y Z"
Vertex Textures format : "vt U V"
X Y Z are floats. There must be only one space between v, X, Y and Z, else it'll crash ( my bad ).
Same for U and V.
Face format : "f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3"
Same there, any extra space and it'll crash.
If it crashes with your OBJ file ( which shouldn't happen if those rules are followed ), just post and tell me if there's an error + send me the obj file so I can look at it.
Export settings for 3DS Max
[attachment=2:39gjq86j]objsettingsmax.png[/attachment:39gjq86j]
Export settings for Blender ( old )
About Materials
There must be 1 material per group( not more, didn't test about less ). Currently, there is a "ugly" hack as I didn't do the MTL Parsing. The texture name is extracted from the "usemtl" statement inside a .obj file.
Meaning, if you have in your OBJ file "usemtl wood", it won't look in the mtl file for the material wood etc.., it'll just use "wood.blp".
Depending on the software you use, material name could be different than the actual texture filename, so be careful with that, i'll implement that on the following days.
Command Line
It's a command line tool, here's the usage :
OBJtoM2.exe MyFile.obj MyModel pathtomytexturesinthempq
MyModel argument shouldn't have any extension ( else it'll lead to strange filenames )
pathtomytexturesinthempq must have a at the end.
That's all I think, enjoy, and don't forget to post screens of the things you do with that, and report all bugs you might encounter !
[attachment=3:39gjq86j]OBJtoM2.rar[/attachment:39gjq86j]
UPDATE : Working for WinXP 32 bits version
[attachment=1:39gjq86j]OBJtoM2.rar[/attachment:39gjq86j]
This new version doesn't add texture automatically, there is a built-in console that permit you to add textures / textureunit / renderflag.
It also permits to add reflect on models quite easily.
Garthog
UPDATE : Sources
I do not really have time to work on that anymore. It has more potential than only a bad command line tool. So here are the sources. You're free to change it, though if you do so, you're strongly encouraged to share the modifications.
Such a tool wouldn't exist without the help I got from the community, and previously shared things, so let's continue that mind.
[attachment=0:39gjq86j]OBJtoM2_SOURCE.rar[/attachment:39gjq86j]
-> Proposed todo list :
--> The CMD sucks
--> Make a more generic format to which M2 will be loaded.
--> FBX ?
--> 3D View + QT ?
Have fun & good luck !