How to load OBJ + MTL textures?

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
zathras
Posts: 4
Joined: Sat Sep 23, 2006 5:34 pm
Contact:

How to load OBJ + MTL textures?

Post by zathras »

Woot! I went through the first few tutorials, and am now proud owner of an amateurishly crafted spaceship that I can walk through with simple collision detection! :D

Now I have lots of questions:
  • - My model is an OBJ file + MTL file (+ some JPGs) -- is that okay or would you recommend a better format?

    - How do I make Irrlicht load the MTL and textures? At the moment, everything is rendered in neutral grayscales. I copied all the texture files into the project and don't get any errors, I just didn't find any command to load MTL. The tutorials didn't cover textures, but the screenshots implied it would "just work" with obj files too.

    - Related question: I know how to load a texture (e.g. PNG, JPG) and apply it to the node. But I don't want the whole node (spaceship) to have the same texture... In the mesh editor, walls, floor and furniture had different textures, glass panes were transparent, etc. What's the recommended way to keep the materials/textures the same as they were exported?

    - And last but not least: Why are left and right mirrored!? :shock:
"Keep up the good work!" to the irrlicht team,

zathras
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Please search for a recent thread which covered exactly this topic. It's basically as follows: The obj file has to reference the mtl file with a proper statement. then the complete file is loaded and material statements in the obj file can use all materials defined in the loaded mtl files. So it's really automatically done for you if your files are ok.
Materials are kept as defined in those files, so transparency and different textures should show up ok.
And left and right inversion might be due to left-handed or right-handed coordinate systems (or a bug :wink: )
zathras
Posts: 4
Joined: Sat Sep 23, 2006 5:34 pm
Contact:

Post by zathras »

:oops: I should learn to use the search function properly. Seems to be a frequently asked question. Here is the answer, how to download and patch an MTL loader into Irrlicht:
http://gdlib.net/index.php?name=Downloa ... ails&id=72

Who is the webmaster, can he please add the appropriate threads
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=11083
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=15610
either to the FAQ or, as "further reading", to the beginners tutorial?

PS:

Interesting. Being able to load the MTL file also fixes the mirroring problem -- so this info obviously was also stored in the MTL file.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

there is no need to add the mtl loader as a patch now, as it has been part of irrlicht for some time
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
zathras
Posts: 4
Joined: Sat Sep 23, 2006 5:34 pm
Contact:

Post by zathras »

bitplane wrote:there is no need to add the mtl loader as a patch now, as it has been part of irrlicht for some time
But appearently not in version 1.0, which is easier to install and use on MacOS. Although I have to admit that I don't know how difficult it is to apply the same changes to 1.1 that were applied to 1.0 to make 1.1 compile on MacOS?
Post Reply