SceneNode color change when lighting it
SceneNode color change when lighting it
Hi everyone!
I'm really confused. I give up!
Don't know what to do, to change a SceneNode color. I have created a SceneNode, then set diffuse color of it's material, and set lighting on. Then I've created a LightSceneNode, and when change DiffuseColor of my SceneNode nothing changed. Is there any way to change color of SceneNode manipulating only material color? My node is based on SMeshBuffer which has a material.
Maybe I have to change vertices Color? This works, but maybe I can set Vertices color to white (for example) and then change only Material color to take effect? Which one should I change? Is this really needed to change SceneNode vertices color?
It would be nice if someone could paste a short example.
Thanks in advance!
I'm really confused. I give up!
Don't know what to do, to change a SceneNode color. I have created a SceneNode, then set diffuse color of it's material, and set lighting on. Then I've created a LightSceneNode, and when change DiffuseColor of my SceneNode nothing changed. Is there any way to change color of SceneNode manipulating only material color? My node is based on SMeshBuffer which has a material.
Maybe I have to change vertices Color? This works, but maybe I can set Vertices color to white (for example) and then change only Material color to take effect? Which one should I change? Is this really needed to change SceneNode vertices color?
It would be nice if someone could paste a short example.
Thanks in advance!
Re: SceneNode color change when lighting it
the solid material uses the vertex colors to iluminate the models, so, you need to set the vertex colors to full white if you want the objects to be lit only with the material color.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: SceneNode color change when lighting it
There is already an example in Irrlicht - checkout Example 22.MaterialViewer. It allows setting different material- and light-settings for 2 scenenodes so you can compare the changes and how they are affected by stuff like Textures.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: SceneNode color change when lighting it
I've already set vertex color to white, and still can't change color of Node. Moreover I've been using example 22 to see how material color works. And it looks like it don't work. Can you tell me how to use example 22 with vertex set to white to change color of object? It really not works fine for me.
Please write haw to set each option and what is need to be set to change to another color. Do I need special kind of light or any light can be used?
Please write haw to set each option and what is need to be set to change to another color. Do I need special kind of light or any light can be used?
Re: SceneNode color change when lighting it
Uhm, light-colors used to work when materials had no textures. No longer does work that way it seems :-( Sorry, I didn't notice when this got changed, I'm pretty sure it was different back when I wrote the example. I need time to figure out since when that is the case and what's going on now.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: SceneNode color change when lighting it
Now, I can only change each vertex color to see object in that color. Does it means it's a bug?
Re: SceneNode color change when lighting it
try this on your material if your using flat colour (with white vertex colours)
and if textured....
Code: Select all
setFlag(EMF_COLOR_MATERIAL,false);Code: Select all
setFlag(EMF_COLOR_MATERIAL,true);Re: SceneNode color change when lighting it
@ Klunk:
I LOVE YOU!
)
I've just changed back all vertices to white and manipulate DiffuseColor of material and it affects. It just works!
@ CuteAlien:
I think you should change example 22. When changing texture:
material.setFlag(EMF_COLOR_MATERIAL, <texture.available>);
Thanks again everyone for your help! You are great!
Probably I will have another question soon. How to enable shadows? Will try to find it out myself.
I LOVE YOU!
I've just changed back all vertices to white and manipulate DiffuseColor of material and it affects. It just works!
@ CuteAlien:
I think you should change example 22. When changing texture:
material.setFlag(EMF_COLOR_MATERIAL, <texture.available>);
Thanks again everyone for your help! You are great!
Probably I will have another question soon. How to enable shadows? Will try to find it out myself.
-
hybrid
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: SceneNode color change when lighting it
If you don't use setFlag() but access the member directly, you can even fine-tune the settings in more detail. This value defines, which part of the lighting material is defined by vertex colors.
Re: SceneNode color change when lighting it
Got another problem with white vertex, and color based on MaterialColor. When I set following:
SMaterial &meshMaterialWalls = meshObjectWalls->getMaterial();
meshMaterialWalls.ColorMaterial = false;
meshMaterialWalls.NormalizeNormals = true;
meshMaterialWalls.Lighting = true;
meshMaterialWalls.MaterialType = EMT_SOLID;
meshMaterialWalls.GouraudShading = true;
my mesh is not Gouraud shaded. Can you tell why is that?
SMaterial &meshMaterialWalls = meshObjectWalls->getMaterial();
meshMaterialWalls.ColorMaterial = false;
meshMaterialWalls.NormalizeNormals = true;
meshMaterialWalls.Lighting = true;
meshMaterialWalls.MaterialType = EMT_SOLID;
meshMaterialWalls.GouraudShading = true;
my mesh is not Gouraud shaded. Can you tell why is that?
Re: SceneNode color change when lighting it
I resolved it!
Indices in my mesh was combined exactly to one vertex and "vice versa". Same number vertices and indices. When I reduced vertices and finally get all vertices unique, my mesh is now rendered like I want it.
All works fine now. Thanks a lot for your help!
Indices in my mesh was combined exactly to one vertex and "vice versa". Same number vertices and indices. When I reduced vertices and finally get all vertices unique, my mesh is now rendered like I want it.
All works fine now. Thanks a lot for your help!