How to use ARGB color mode in mogre?


24-06-2008 08:21:20

I'am new for ogre , and I want to control entity's color with ARGB color mode like this:

ent.GetSubEntity(0).GetMaterial().GetBestTechnique(0).GetPass(0).Ambient.SetAsARGB(uint colorvalue);

But It can not do anything ! can anybody help?

(I'm very sorry about my poor English!)

Thank you !


25-06-2008 23:41:14

this a ogre Material system topic, try finding in OGRE forums. May be there is some way to use ARGB colors directly using the material script.


26-06-2008 03:37:52

Thank you ,Marioko!

And there is any way to convert System.Drawing.Color to fload value for R,G,B?then,I can use SetAmbient() function like this:

ent.GetSubEntity(0).GetMaterial().GetTechnique(0).GetPass(0).SetAmbient (float r,float g,float b);

It would work fine!

(I'm so sorry about my poor English!)


26-06-2008 14:26:32

Mmm sure, with System.Drawing.Color you can:

Color slateBlue = Color.FromName("SlateBlue");
byte g = slateBlue.G;
byte b = slateBlue.B;
byte r = slateBlue.R;

Bytes are a numbers from 0 to 255, in Mogre colors are from 0 to 1.0 then:

Bytes Float
Min 0 0
Max 255 1.0

Only you need to do i a little convertion like this:

byte green = slateBlue.G;
float mogreGreen = green/255; // this get a 0 to 1.0 value


27-06-2008 04:55:11

Thank you for your help,Marioko!

I fine the other way like this :

ColourValue color = new ColourValue();

And I have another problem : I want to create two same entities of different color ,how can I do ?use material clone?use material script ?or anyother way?

(I'am sorry about my poor English !)


27-06-2008 14:24:19

nice.. i know that should be a better way to convert colors (but i dont remember that) :D

Entity object has a method SetMaterial and a property Material, you can create a lot of entity of the same .mesh file and for each entity set a custom material.. :D


27-06-2008 15:46:09

heres my convertion code
public class MyColor
public MyColor()
public static Color ConvertColourValue(ColourValue colourValue)
return Color.FromArgb((int)(colourValue.a * 255), (int)(colourValue.r * 255), (int)(colourValue.g * 255), (int)(colourValue.b * 255));
public static ColourValue ConvertColor(Color color)
return new ColourValue((color.R / 255), (color.G / 255), (color.B / 255), (color.A / 255));

then you can call it like
light.SpecularColour = MyColor.ConvertColor(Color.SlateBlue);
Color mySspecularColor = MyColor.ConvertColourValue(light.SpecularColour);


28-06-2008 10:38:20

Thank you everybody!

The problem has solved perfectly,thanks again!

I have another problem about ManualObject now.There is any way to set the line width?


28-06-2008 17:44:51

nice.. mm you should open a new topic about ManualObject.. and remember find first in OGRE official forums and then MOGRE forums.


30-06-2008 07:24:33

Thank you ,Marioko!Thanks for your help in these days ! :D