Change material color

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
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Change material color

Post by WToma »

Hi!
It's me again :) I try to change the color of some loaded meshes.
I use

Code: Select all

node->getMaterial(i).AmbientColor.set(0,0,255,0);
, but nothing happens. When I try to changle all colors (excepted emissive) of all materials, I still cannot notice any changes. (If I change emissive color it works, but looks ugly.)
Any ideas?
Toma
edit: the entered values are stored, I check it out by printing the color values.
"This is not a bug, this is a feature!"
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

Up!
Nobody got the faintest idea :?:
Toma
"This is not a bug, this is a feature!"
bearSoft
Posts: 165
Joined: Fri Apr 01, 2005 9:55 pm
Location: Denmark

Post by bearSoft »

hmm have u tried the same on a different pc?
some graphic card may act weird with some modes / some methods
-perhaps u can make an example file demonstrating this?
u can use http://www.uploadr.com/ as a 'fileserver' if u do nat have ur own
Regards.
Tech: win98se| 320mb ram| abitbe6| 433mhzceleron| atiRadeon7000.64mb| soundblaster125| dx9.0b | devCPP | IRR 0.12.0 |
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

I've made up a little test to demonstrate what happens. Zip includes c++ source, Dev-C++ project file and an example model.
Maybe the error is in my environment because I had build the lib myself and also changed some little modifications (see the "yet another lighting question" topic).
You can download the example from here: http://file.uploadr.com/19a5 (thx for mentioning uploadr, really great service!)
Toma
"This is not a bug, this is a feature!"
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

OK, I have found it. In this case, the problem was that I should have set up the new color before creating the IAnimatedMeshSceneNode from IAnimatedMesh. Working with EmissiveColor results an acceptable lighting/shading. In other cases, however, the usage of EmissiveColor is not a good solution because it results flat shaded surfaces that I don't want at all. And I can still notice strange/undocumented/unseen (by me ;)) things with other models. (Not all other, though.)
Looking forward for your brighter ideas :)
Toma
"This is not a bug, this is a feature!"
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

Here you can see the problem: http://file.uploadr.com/1ae5
The original color is that you can see on the left. I try to paint this car blue. On the left picture, I use this code:

Code: Select all

model->getMaterial(1).SpecularColor.set(0,255,255,255);
model->getMaterial(1).AmbientColor.set(0,0,0,255);
model->getMaterial(1).DiffuseColor.set(0,0,0,255);
model->getMaterial(1).Shininess=20.0f;
(model is an IAnimatedMeshSceneNode*)
On the right:

Code: Select all

model->getMaterial(1).EmissiveColor.set(0,0,0,255);
As you can see, the first doesn't work, the car is still red. The right works, but looks ugly, because it doesn't fade into the darkness.
Hope somebody has some ideas, because it drives me mad ;)
Toma
"This is not a bug, this is a feature!"
Post Reply