[SOLVED]How To Load Texture from 3dsMax into Irr?

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.
Thomaskkc
Posts: 134
Joined: Fri Sep 15, 2006 4:04 pm

[SOLVED]How To Load Texture from 3dsMax into Irr?

Post by Thomaskkc »

I have draw a object in 3dsmax and i have assign some texture by 3dsmax, but when i load this obj which exported by 3dsmax into Irr, it disappear all the texture and need to write the code:
setMaterialTexture

so how can i load the texture which assign from 3dsmax into irr without using setMaterialTexture??
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

I am not sure if .obj files store the texture filename or not. Open the .obj file and the .mtl with a text editor and see if the texture name is present anywhere. If not it's either a limitation of the .obj format or your exporter. or irrlicht.

Google the .mtl format, it seems you can use textures

for example

map_Ka my_texure.bmp
map_Kd my_texure.bmp

Try editing the .mtl file!
Thomaskkc
Posts: 134
Joined: Fri Sep 15, 2006 4:04 pm

Post by Thomaskkc »

Thx, i try to follow ur step

I have open the .mtl file, but can't find any texture file
so is that i can only add the texture name in .mtl file is ok?
then let the irrlicht to load the .mtl file?
or anything to do
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

yes try adding the filename and see what happens!

In the mtl file there should be sections for each material,

Example with texture added:

newmtl Material_Name
Ns 96.078431
Ka 0.764102 0.764102 0.799580
Kd 0.581219 0.621303 0.609937
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Ka my_texure.bmp

You could also try replacing "map_Ka" with map_Kd, map_Ks, or even having all three.

(I think they are different texture maps for ambient, diffuse, shinyness but am not sure)
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

use .3ds instead and place your textures in the same folder as your 3ds.
Thomaskkc
Posts: 134
Joined: Fri Sep 15, 2006 4:04 pm

Post by Thomaskkc »

re xDan

I have try to add the texture, but how can i load the mtl file into Irr?

re afecelis

I have try but still not work
Is that any more description about it?

thanks for any suggestions, explaination and example ~
Thomaskkc
Posts: 134
Joined: Fri Sep 15, 2006 4:04 pm

Post by Thomaskkc »

I have try to load .3ds directly
but why the group object is display like a ungroup object in different place?
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

1. are you UV mapping your meshes?
2. are you using multi-layered materials?

exporting multi-layered materials will go nuts in Irrlicht. Try to create a separate material for each mesh in your scene. When exporting accept on the preserve coordinates message you get, then place all of the textures you used (jpgs, bmps, etc) in the same folder as the .3ds. If you're just exporting materials with colors in the difuse channel (no bitmaps) you'll also get errors. Finally, remember to set "EMF_LIGHTING, false" on your 3ds mesh node.

If you don't go over the 65k poly limit in 3ds you should be ok. :wink:
Thomaskkc
Posts: 134
Joined: Fri Sep 15, 2006 4:04 pm

Post by Thomaskkc »

I have use Multi/Sub-object to map the mesh, but I have set the layer is 1
is that still ok?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

.mtl files have to be "use'd" in .obj files. I think the syntax is 'use_mtl filename.mtl' Then .mtl files are loaded automatically.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

@hybrid: that's a new one for me! :shock: It's great to know Irrlicht can read the info in the .mtl file, thanks! :D

@Thomaskkc: sorry for not using the proper term, that's what I meant "Multi/sub-object" materials. Avoid using them as Irrlicht goes crazy with those and will end up showing you some weird scenes or untextured models. Try starting by keeping it simple; separate texture per mesh and try it out.

Also try hybrid's latest info with your .obj file (and please report back if you succeeeded).

One last thing you could do is unwrap your model and use a single texture with all of your textures in it. May I ask what your model is? I mean, is it a level map or a character?

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

Post by hybrid »

Correct code is

Code: Select all

mtllib filename.mtl
and then inside a group

Code: Select all

usemtl materialname
And this has been supported since the obj+mtl patch which is now part of Irrlicht core.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

and you just place the line after loading the mesh?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, you put it into the .obj files such that materials are automatically loaded just as for the other mesh file formats.
Thomaskkc
Posts: 134
Joined: Fri Sep 15, 2006 4:04 pm

Post by Thomaskkc »

the code can put it in the .obj file ??
where is it put ?
and the systax is just mtllib filename.mtl??
Post Reply