HELP! how do i load a .obj file with .mtl file

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
chancing

HELP! how do i load a .obj file with .mtl file

Post by chancing »

Hi,

As I still cannot work out the orientation problem with xExport, I know the orientation is kept well with obj export from Maya. But the material info is stored in another .mtl file if I use obj export. So in Irr, if I wanna load a obj file, how do I link its .mtl file to have the textures?

Thanks!
Dogs
Posts: 195
Joined: Wed Sep 15, 2004 1:04 am
Location: michigan

Post by Dogs »

Hmm Im not sure if you can just set the code up like a normal texture but put texture.mtl insted...
I dont think ive tried this...

So I wouldnt mind knowing this myself..
Im not even sure if you can use .mtl if its a valid texture or not...

Im going to check back on this post myself and see if this can be done as I may wish to load .obj files and use there material file exported as well.. if not Im wondering maybe there is a way to export the texture as a diff format from maya insted of .mtl .. Im not sure as I cant afford Maya and if I could i surely wouldnt buy it anyway lol..
Id get me a nice second car to drive insted...
3ds max was enouph money.... :D
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

unfortuantely irrlicht does not load .mtl files with hte .obj, and ignores the usemtl lines in the .obj files. .obj is probably just about hte easiest format in the world, os writting a loader for the .mtl files would probably not be very hard (I've never actualy done it though). Some changes would have ot be made in irrlicht so that it created a new meshbuffer whenever the obj file started using a different material.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
Dogs
Posts: 195
Joined: Wed Sep 15, 2004 1:04 am
Location: michigan

Post by Dogs »

I didnt think irrlicht would load the mtl texture...
Maybe something that can be added in future release who knows..

So im guesing its best to try and export your textures from maya some how as a diff suported texture format... :?
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

the problem is the model format, not the texture format. Irrlicht ignores all materials in .obj file, just loads geometry
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
Guest

Post by Guest »

I'm very interested in this problem as well, because I have a whole bunch of models with textures that my artist has created, and they look awful without the .mtl getting loaded.

Has anyone written a material loader so that Irrlicht can get that MTL stuff? Or perhaps it's in the 0.7.1 release?
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

Why not just convert everthing to .x or something? Easier than writing a loader, though someone should do it at sometime
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

yup, converting to x is an option.

Some notes:

- *.mtl is not a texture format. Is -like OBJ- an ascii format. It is the text file where some settings of the material are autmatically written by the 3d software that the artist uses. That is, he export as OBJ, and every good package will export an mtl file together with the OBJ. The texture is a thing apart. (can be a tga or whatever.) The mtl is not only important for as it tells WHERE the tetxure is, and order to actually use it (best practice is to allways tell the artist to export all to same folder(OBJ+mtl, and have the texture also there previously to asign in the 3d package), so no absolute/relative paths problems)
Mtl file also tell values like shininess, emissive, ambient, etc, etc. These could be used by a good irrlicht loader to translate quite accurately the material look that the artist wanted.

- While Alias Maya is the creator of the format, is not by any means the only package that export OBJ. The main advantage of OBJ is specially it's used by every app out there to export! :)
The other big advantage is...Unlike x, it supports more than 65,000 triangles (polygons) in a model. Soon this will be important. Indeed, we loaded 100k levels in pentiums with ati9100, in latest company I was... And 65 or more where usual. Yet though, in most free engines, this is a too high polys count, and for most pcs yet, quite an overkill.

-It has great advantages for editing between packages: lots of compatibility and is one the most lossless formats: it keeps quads (good for the artist, while to the engine the final export is in tris: is what the 3d card eats) , keeps smoothing groups (x and 3ds kills them, at least x does not kill smoothing info, x is a more complete format for games)


-For an static mesh, is usually less problems with an OBJ than X. Panda Max exporter is thought for animation and is really complex -and good- plugin.

Anyway, to be sincere, at the end of the day, is the same. You rarely are gonna need more than 65k tris. And if u do, if u separate in 3 meshes (just thinking on huge terrains or an airport huge interior with loads of detail) , 195k tris...heh, that's quite huge number...

- Wings3d does not export x , but obj and 3ds (3ds kills smoothing, kills material long names, and creates duplicated vertices wherever it finds an uv border (way often). OBJ is way better. )

- Max has a great import/export plugin for max4, and 5 habware.at/duck4.htm and max6 (surely 7 , too) habware.at/duck6.htm

- Blender exports/imports md2, OBJ, 3ds, perfectly. Exports also x, md5, md2, md3, milkshape static. (all this u need to setup an external plugin, previously find it. I collected the info in tools sticky page (in my sig))

I don't know if Irrlicht loads well the smooth groups info in OBJ, that'd be good, and probably the greatest advantage of using an OBJ instead of an x file, for static objects (obj does not support animation. )

BTW, actually I think the static mesh is more or less covered. I suppose people just asigne theuv texture in engine, as I supppose too, that OBJ is loading well in irrlicht the uvs and smoothing info. Indeed, good load of smooth groups is more important than themtl, imho, as the texture can be asigned by the coder, but not the carefully artist asigned smooth groups.Wings has hard edges (~smooth groups, but better) , but sadly, I am afraid it does not export that info in OBJ. Not sure, though.
Finally making games again!
http://www.konekogames.com
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

oops


sorry, ...I was wrong.

Wings3d DOES exports perfectly smooth groups Just Ultimate Unwrap does not understand s groups... But I tested now in Milkshape (another one that will allow you to make smooth groups, but ms3d is not free...hey..ms does do a great work in exporting...smooth groups in obj are also kept when export from there as OBJ. The mesh native format of Milkshape, *.ms3d, also imports/exports well the smoothgroups info.)

I neither know if ms3d has smooth groups support in irrlicht, neither if Milkshape format has a weird vertex count limit....OBJ hasn't got any, so I'd use that one...as you can also exchange really easily with other artists, no matter which package they use...OBJ is...universal. Like in animation, the most universal/complete format is x.
Finally making games again!
http://www.konekogames.com
Guest

Post by Guest »

[quote=Electron]Why not just convert everthing to .x or something? Easier than writing a loader, though someone should do it at sometime[/quote]

Well, for whatever reason, both the built in .x exporter and the one I downloaded after reading about it on these forums exported the models incorrectly. We had a fairly simple model of a castle with a keep, and it was utterly wrong.

That's why we started using the OBJ exporter, because it exports everything perfectly without modification.

Thanks for your excellent explanation of MTL, etc, Vermeer. I love it when people can bring a somewhat foreign topic to closure in a concise manner. I appreciate it.

Well, I guess I'll try .x again, or just keep working with these mtl-less models. It doesn't really matter at this point, because we're just testing things like controls and the world.
Post Reply