Changing a textures color

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
saintnick
Halfling
Posts: 51
Joined: Tue Nov 27, 2018 1:41 am
x 5

Changing a textures color

Post by saintnick »

Ogre Version: 1.11.4 :?:
Operating System:Windows 10 :?:
Render System:Any :?:

In my project I want users to be able to choose a team color. Their models should then be colored with their team color. I did this with the robot mesh that comes with Ogre by manually creating a second texture and material where the grey is colored red or blue. However I want the user to be able to choose any color with a color picker and manually creating every color for every model these seems incorrect.

I tried:

Code: Select all

				mEntity->setMaterialName("Examples/Robot");
				MaterialPtr mMat = mEntity->getSubEntity(0)->getMaterial();
				mMat->getTechnique(0)->getPass(0)->setAmbient(255, 0, 0);
				mMat->getTechnique(0)->getPass(0)->setDiffuse(255, 0, 0, 0);
				mEntity->setMaterialName(mMat->getName());
I noticed no change to the robot's texture.

I was going to texture all my models grey where I want a team color. Then at run time pick a color and change all the grey color in my texture to the selected color. Can Ogre do this?
Tikoucas
Gnoblar
Posts: 7
Joined: Fri Dec 28, 2018 7:52 pm
x 1

Re: Changing a textures color

Post by Tikoucas »

I noticed it didn't work for me aswell when I tried to colour the robot, but it worked with other objects.
I believe it's because the robot material script got a program in it (which I don't understand at all).
However the next material script for the robot did actually work.

Code: Select all

material Robottest
{
	technique
	{
		pass
		{
			ambient 0.588235 0.588235 0.588235 1
			diffuse 0.588235 0.588235 0.588235 1
			specular 0 0 0 10 0
			texture_unit
			{
				texture r2skin.jpg
			}
		}
	}
}
Ofc, I changed the material to this:

Code: Select all

mEntity->setMaterialName("Robottest");
[code]

I hope it helps.
Post Reply