Page 1 of 1

Changing a textures color

Posted: Sun Jan 13, 2019 5:57 pm
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?

Re: Changing a textures color

Posted: Mon Jan 14, 2019 8:33 pm
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.