How to custom loading multiple textures on One model

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
lordcool
Posts: 15
Joined: Thu Jul 13, 2006 8:33 am

How to custom loading multiple textures on One model

Post by lordcool »

I want to customizing using the models(meshes) and the textures in memory.
Client get a number of models/textures from streaming(DB etc..)

The model using one texture is ok,
but using two Texture(or more) model(like "dwarf.x") is the problem.

I tried to this follow code.

Code: Select all

scene::IAnimatedMesh* mesh = m_pSmgr->getMesh("media/dwarf.x");
scene::IAnimatedMeshSceneNode* node=0;
video::ITexture* tex1 = m_pDriver->getTexture("media/d1.jpg");
video::ITexture* tex2 = m_pDriver->getTexture("media/a1.jpg");
node = m_pSmgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
node->setMaterialTexture(0, tex1);
node->setMaterialTexture(1, tex2);
d1.jpg - dwarf texture
a1.jpg - axe texture

see this, wrong Axe texture..
http://hompy.ollio.com/view.asp?fnm=hompy96253.jpg

please suggest to me. how can i slove it. thanks.
Licco
Posts: 2
Joined: Mon Nov 20, 2006 6:08 am

Post by Licco »

I have this problem, 2....
Hope someone can tell us how to solve...thx!
luckymutt
Posts: 453
Joined: Sun Mar 06, 2005 11:56 pm
Location: C-Ville

Post by luckymutt »

It sounds like you are trying to make a multi/sub-object texture(one bmp for part of the mesh and another for another part of the mesh in the same channel, ie:diffuse color), which I don't think you can do.

The multiple texture capabilities are for applying different maps and shaders in different channels on a mesh, not for applying it to different parts of a mesh.
Join us in the Irrlicht chatroom:
[url]irc://irc.freenode.net/irrlicht[/url]

I love deadlines. I like the whooshing sound they make as they fly by. -D.Adams
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You have to access the different mesh buffers which are part of the mesh. Each one has its own material and you have to assign the proper textures there.
Licco
Posts: 2
Joined: Mon Nov 20, 2006 6:08 am

Post by Licco »

hybrid wrote:You have to access the different mesh buffers which are part of the mesh. Each one has its own material and you have to assign the proper textures there.
Can you please give out some examples( showing some code is better...) to explain how to do the mapping?
Thank you very much!!!
n00b
Posts: 58
Joined: Tue Sep 05, 2006 3:00 pm
Location: Earth
Contact:

Post by n00b »

the easiest way is to use a 3d modelling program and apply textures there!
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

:x and what will the 3d program do he want to import it into irrlicht huh?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

What :shock: Using a 3d modeller is almost the only way to do proper UV texture mapping. If you have a more complex mesh thn a cube you'll like fail to add textures manually.
BTW: You simply have to guess which mesh buffer is the corret one for your texture. It heavily depends on the loader etc. how this will work. And if your mesh does not contain separate material definitions you cannot add separate textures at all.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

node->setMaterialTexture() does not do what you think it does.

use:
node->getMaterialCount()
node->getMaterial(matindex).Textures[texindex] = texture

read:
http://irrlicht.sourceforge.net/docu/cl ... de.html#a8
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
lordcool
Posts: 15
Joined: Thu Jul 13, 2006 8:33 am

Post by lordcool »

The best way is that use one model one texture.
bitplane's hint covers this problem mostly. thank you very much. :D
complex mesh has to using 3d modelling program maybe.
and need to learn more mesh buffers. :oops:

my program is that client receives meshes/textures from server. and don't want clients save meshes/textures in their HDD. it's just temporary data. All process must be executed in memory.

thaks all!!
BastetFurry
Posts: 5
Joined: Thu Dec 07, 2006 1:59 pm

Post by BastetFurry »

Why not a temp dir you clean after the programm ends?
And why clutter the internet with traffic when its better buffering the data on the users HD?
Just look how GuildWars does it. Some nice protected container format, reminds me a bit of the old BAM format cbm disks have. *g*
You would just need to edit Irrlicht itself so that it reads from said container format and not from normal filespace and you dont even need to release your "ultra high confidental" scrambling system. Irrlicht is zLib licenced ;)
Post Reply