Multiple 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
kendric
Posts: 71
Joined: Tue May 29, 2007 9:05 pm

Multiple textures

Post by kendric »

I have a model of a gun and hands and it has 4 texture files that go with it. I was trying to figure out how to put more then one texture on it, but using the layers, only the top one shows.

Is there any info on how you assign 4 textures, and how they correctly know where to go on the model?
If i put the textures on one at a time they land in the right spots somehow, so its partly there.

Thanks in advance.

***
In addition, I solved this problem for now(not how I would like to keep it) by seperating the parts into seperate models and attaching them all to a common anchor custom scene node. That works sorta, but depending on the angle of the camera, some of the scene nodes will vanish, and then reappear. Its very consistent, if say i turn to 30 degrees, the hands will remain and the gun will vanish. If i move the anchor node around a bit and then try it again, the sub nodes dissapear at different angles and sometimes more of them dissapear when it happens.

Is there something special about having children nodes on a scene node that you need to do to make sure they always draw correctly?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The four texture stages per Material are for special effects, blending of textures (on one place) etc. They are not intended to be used for different textures on spearate places. You have to use different materials for this purpose. So go back to your 3d modeller and put separate materials on each place you want a different texture. Or put all your four textures into one and make proper texture unwrap for creating correct texture coords (which can be but need not be more ressource saving).
souledgar
Posts: 5
Joined: Tue May 22, 2007 1:09 pm

Same problem, but more complicated.

Post by souledgar »

I'm facing the same problem here, but instead of a camera-guns, the thing i have to texture is a Level map. Its for a racing game and is obviously a racing level, a city to by precise, GTA style.

How do you assign textures to materials programmatically? What i have now is an obj and an mtl file, couple with its textures. It shows up fine in game, but i need to be able to change the textures on the assigned materials on the fly. e.g. Instead of a city texture set, a player can choose an option to instead race in a .. say.. forest, or underwater. A tarmac road would not appear appropriate for a forest, so i was wondering if it can actually be done.

If the answer is yes, could you point me in the right direction? Thanks!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can get access to the materials and change the textures in them. Just get the proper Material of your mesh (getMaterial(n)) and chaneg the textures.
kendric
Posts: 71
Joined: Tue May 29, 2007 9:05 pm

Post by kendric »

Wow thanks, that was something I had completly missed in all my time working on this ;)

It works perfectly now.

Here is a code snipper of a helper function i made if anyone wants it. I need to convert from std strings to irrlicht ones but other then that its fine.

void applyTextures(ISceneNode* sceneNode,int textures,const std::string* textureNames)
{
ITexture* texture;
for(int i=0;i<textures;i++)
{
texture=myGameDriver->getTexture(textureNames.c_str());
sceneNode->getMaterial(i).Textures[0] = texture;
}
}
Post Reply