This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [TOOL] OBJ to M2 converter + Sources  (Read 39370 times)

Garthog

  • Contributors
  • Polygonshifter
  • *****
  • Posts: 56
    • View Profile
[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.

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 !
« Last Edit: January 21, 2014, 01:37:58 pm by Admin »

Cromon

  • Contributors
  • Polygonshifter
  • *****
  • Posts: 56
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #1 on: August 13, 2013, 10:05:59 pm »
Like i told you already in skype, nice one! :)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

LIMEEE

  • Contributors
  • GM Isle Explorer
  • *****
  • Posts: 24
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #2 on: August 13, 2013, 10:08:25 pm »
Glad you released it, And if people have any questions about what to do in max, you could always try to ask me, as i was the one helping Garth to bug test this fantastic tool.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Soldan

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 159
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #3 on: August 13, 2013, 10:17:29 pm »
Epicness! Thanks a million!
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Will

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 140
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #4 on: August 13, 2013, 10:50:02 pm »
good share!
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
- JutsuONLINE - http://www.jutsuonline.co/
Always recruiting. Contact me

LIMEEE

  • Contributors
  • GM Isle Explorer
  • *****
  • Posts: 24
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #5 on: August 13, 2013, 11:16:35 pm »
To people that have problems with textures being messed up ingame. First of all make sure everything is in a 0.1 range. 2nd nothing can be welded together, Select all Verts and use Break, then export to obj, That should fix the texture problems 90% of the time.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Soldan

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 159
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #6 on: August 14, 2013, 02:27:56 am »
Converter works brilliantly, and it's really easy to use.

Well explained instructions by Garthog brought me to my goal in no time.

After a little bit of tweaking with renderflags (on my part, for textures - nothing to do with the converter whatsoever) I now have my weed plant ready to be used in two new professions that I am working on.

From blender to game, using this converter it took minutes, literally.

So much more ideal and userfriendly than the typical mdx, mdl, etc..

Thanks again Garthog!

Result:

« Last Edit: January 01, 1970, 01:00:00 am by Admin »

PhilipTNG

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 709
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #7 on: August 14, 2013, 10:57:21 am »
Quote from: "Soldan"

Dude, that is epic!!  Goodjob, did you hand model that?  =D
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

relaxok

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 74
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #8 on: August 14, 2013, 11:34:23 am »
Outstanding, man.  8-)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
----------------------------------------------------------------------------------------------------------------------------

My project blog: http://relaxok.tumblr.com/

Ascathos

  • Moderators
  • Creator of Worlds
  • *****
  • Posts: 1129
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #9 on: August 14, 2013, 01:54:35 pm »
Thanks for this!
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Arid

  • Contributors
  • Loreweaver
  • *****
  • Posts: 100
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #10 on: August 15, 2013, 09:21:13 am »
Anyone mind uploading how my Blender's export should look like? ><
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

TheBuG

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 469
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #11 on: August 15, 2013, 01:55:58 pm »
Good job!
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Soldan

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 159
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #12 on: August 15, 2013, 02:06:56 pm »
Here you go Arid,

This works for me!



Just remember to edit the usemtl to the name of your blp :)!

Soldan
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Soldan

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 159
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #13 on: August 15, 2013, 06:02:31 pm »
Another result;

I really like the SalamanderHunter (from cataclysm) shoulder, and I've always wanted to have it as a usable shoulderplate - thanks again Garthog!





Just need to particle clone and readjust the coords now :D

Soldan
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Dornussod

  • Registred Member
  • MWCS Enthusiast
  • *****
  • Posts: 1
    • View Profile
Re: [TOOL] OBJ to M2 converter
« Reply #14 on: August 17, 2013, 01:59:50 am »
Waow ! Nice, it works, thanks
« Last Edit: January 01, 1970, 01:00:00 am by Admin »