Changing a textures color

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

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

				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);
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?

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
			ambient 0.588235 0.588235 0.588235 1
			diffuse 0.588235 0.588235 0.588235 1
			specular 0 0 0 10 0
				texture r2skin.jpg
Ofc, I changed the material to this:

Code: Select all


I hope it helps.

Post Reply