Page 1 of 2

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

Posted: Fri Sep 15, 2006 4:08 pm
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??

Posted: Fri Sep 15, 2006 5:14 pm
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!

Posted: Fri Sep 15, 2006 5:26 pm
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

Posted: Fri Sep 15, 2006 6:16 pm
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)

Posted: Fri Sep 15, 2006 10:57 pm
by afecelis
use .3ds instead and place your textures in the same folder as your 3ds.

Posted: Sat Sep 16, 2006 3:31 am
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 ~

Posted: Sat Sep 16, 2006 3:47 am
by Thomaskkc
I have try to load .3ds directly
but why the group object is display like a ungroup object in different place?

Posted: Sat Sep 16, 2006 4:00 am
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:

Posted: Sat Sep 16, 2006 4:39 am
by Thomaskkc
I have use Multi/Sub-object to map the mesh, but I have set the layer is 1
is that still ok?

Posted: Sat Sep 16, 2006 11:11 am
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.

Posted: Sat Sep 16, 2006 12:47 pm
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.

Posted: Sat Sep 16, 2006 10:37 pm
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.

Posted: Sun Sep 17, 2006 12:36 am
by afecelis
and you just place the line after loading the mesh?

Posted: Sun Sep 17, 2006 8:49 am
by hybrid
No, you put it into the .obj files such that materials are automatically loaded just as for the other mesh file formats.

Posted: Sun Sep 17, 2006 9:58 am
by Thomaskkc
the code can put it in the .obj file ??
where is it put ?
and the systax is just mtllib filename.mtl??