loading a model with a glass texture

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
Moulded

loading a model with a glass texture

Post by Moulded »

how can i load a model with a part of it textured with glass material.
Can giles do this job . I mean can i make the model with it and export it in .X format and load it in irrlicht . Will it show up.
I tried in 3ds max and got negative results. How to get the model in irrlicht which contain a glassy part in it
hybrid

Post by hybrid »

I think the 3ds loader just lacks the recognition of transparency. It should be possible to add mesh buffers with transparent material. I don't know the x mesh loader that well, but it could be possible to use it for partially transparent parts.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

If you created your materials properly in 3dsmax, then all you got to do is export to 3ds. When Importing the 3ds to Giles, it will automatically detect your material settings. Just make sure to use texture maps (jpegs) for each material you create. Don't just change its difuse color. i.e. if you want a wall to be white, then don't just create a material with white in the difuse color but create a white texture and drop it on the material's difuse channel. Same with glass; create the color tone you want for the glass in a jpeg and then add it in the difuse channel and set its opacity to say 60% or 50%. Apply your materials and export to 3ds. Giles will recognize your material settings. You can finally add lights and lightmaps within Giles and then export to My3d.

ps. Final word: don't use multilayer materials. Each object must have its own idependent texture.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

an example is worth a 1000 words!
here, I created this small app and room for you. 3dsmax5, 3ds, giles and my3d file included with the template project. Nothing fancy, just a room with some windows to show you how Giles takes the materials from max.

so the process goes:
1. Model in max, texture in max, use jpegs. For glass set its opacity to 50%. Place some lights.
2. Export to .3ds
3. Import in Giles. Giles will open the file with its materials and even the lights you placed.
4. Lightmap in Giles (render).
5. Export to My3d. remember to use the _lm for the lightmap file and copy it to the "Lightmaps" folder. (i.e. lightmap01_lm.jpg)
6. use the templae app to see it in action.

Take a look from outside the room to the inside. You'll notice the glass effect. WASD to move, alt+f4 to quit. Hope it helps!
Grab it here:
http://www.danielpatton.com/afecelis/Irrlicht/glass.zip
screen from inside:
Image
looking from outside-in:
Image
hybrid

Post by hybrid »

Thanks afecelis, you gave me the confidence in my 3ds patches I was seeking for :D
I have made some changes to add several useful things to the 3ds loader. Those I recall right now are:
Transparency (Yes, it looks the same when loaded directly in 3ds :shock: )
Vertex colors (No need to use small textures to imitate flat coloring)
Shininess
Some Shading flags such as Wireframe and Gouraud shading are recognized

I will also include the bug with missing faces into my patch (which was correctly reported several times the last weeks. Note that the bug fix seems to be nonsense, because the indices count would have to be divided by three. But the actual number stored in the variable is the face num, so no need to divide).

I will post the bug fixes tomorrow when I have the source code online. But I've tested it and it really works. Lights still to come, though. And many other things, too. :cry:
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

great news Hybrid! gotta try those patches out. Please keep me updated! :wink:

glad the files helped.
hybrid

Post by hybrid »

Ok, patch is available. Also a screenshot: Image
I will try the multi-material thing right now.
jameskayin
Posts: 5
Joined: Thu Mar 01, 2007 2:13 am

Post by jameskayin »

Hi,afecelis:
I got a problem like this:
I made a 3DS scene,and also made a glass with 50% opacity,then I loaded it to irrEdit,it looks fine before calculate the scene with "ambient light" option checked.But after I calculated the light,the opacity missing,and the glass looks like just a wall -_-|||
Why does it take place? Can you give me a hand?Many thanks.
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post by belfegor »

Here is how i set up two materials on one model in 3dsMAX:

make a model
convert to editable poly
press 'm' to bring up material editor
select first set of polygons in model
assign first material slot (wall texture for example)
select invert(other set of polygons ,window for example)
assign second material slot(glass texture witch i will later set up transparent)
export to '.X' (text format)
and then in irrlicht:

irr::scene::IAnimatedMesh* m = smgr->getMesh("mesh.X");
irr::scene::IAnimatedMeshSceneNode* am = smgr->addAMSN(m);

am->getMaterial(0).Texture1 = driver->getTexture("wall.tga");
am->getMaterial(0).Texture2 = driver->getTexture("wall_n.tga");
am->getMaterial(0).MaterialType =(irr::video::E_MATERIAL_TYPE)bumpMapMateriall;

am->getMaterial(1).Texture1 = driver->getTexture("glass.tga");
am->getMaterial(1).MaterialType = irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL;

Maybe before that you could open "mesh.X" with text editor.And find in
what material number texture are assigned by X-exporter, if
result is not correct.I have sometimes two materials assigned in
6 and 7 materials in X file and sometimes in 0 and 1.
Dont know about '.3ds' file format but i think its binary so i cant know
where are materials(in witch material number).
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
Post Reply