Coloring 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
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Coloring textures?

Post by Reiko »

Hello

I think the answer to this is very simple but I am not sure what I am doing.

I have a mesh with a monochrome texture. How can I apply something similar to a "Color balance" sort of thing, which exists in graphic programs such as Adobe Photoshop and GIMP, to the texture to change the color?

Basically, all my characters have a black-and-white hair texture and I want to be able to let the player choose an RGB color for their hair color. So rather than having 10 different textures that are coloured differently to choose from, I want to use the one black-and-white texture for everyone but be able to apply any different color to it.

What is the best way to go about this?

I'm not sure if it matters, but I dont have any lights, I just got the EMF_LIGHTING set to false on the node for the hair.

Thanks in advance.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

See the DiffuseColor method of SMaterial, just get the material and set the colour to something other than white.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Rei
Posts: 4
Joined: Mon Aug 17, 2009 1:51 pm

Post by Rei »

Hey again (forgot the pass to my other acc >.>)

I tried your suggestion, but I must be doing something wrong, cause the texture still shows as monochrome like before. (nothing changed)

This is what I've got.

Code: Select all

mesh = smgr->getMesh("data\\malehair.x");
node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialTexture( 0, driver->getTexture("data\\malehair.jpg") );
node->setMaterialFlag(EMF_ANISOTROPIC_FILTER, true);
node->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
node->getMaterial(0).DiffuseColor.set( 255, 255, 0, 255 );
Is there something else I've forgotten to do?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe you have more than one material?
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Post by Reiko »

I know this is pretty old now, at the time I couldnt solve it but I was trying just now, now that I know my way around irrlicht a little better, and I figured out a way to do it.

I just did

Code: Select all

smgr->getMeshManipulator()->setVertexColors(nodeHair->getMesh(), SColor(255, 0, 0, 255))
or whatever color. Pretty simple. This way was better cause I didn't have any lights, I think the diffuse color and such will only work with lights or something.
Post Reply