ggazzo / opennero

Automatically exported from code.google.com/p/opennero
Other
0 stars 0 forks source link

setObjectColor does not work #72

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call setObjectColor from Python
2. No effect

What is the expected output? What do you see instead?

We would like to have a way to dynamically set the color of objects in 
OpenNERO. This currently doesn't seem to work.

(Patrick, please provide additional detail).

Original issue reported on code.google.com by ikarpov on 22 Feb 2011 at 8:34

GoogleCodeExporter commented 9 years ago
In mods/Maze/module.py I can change mark_maze_blue() to the following:

id = self.mark_maze(r,c,"data/shapes/cube/BlueCube.xml")
getSimContext().setObjectScale(id, Vector3f(2, 2, 2))
getSimContext().setObjectColor(id, Color(100, 100, 100, 100))

While setObjectScale() does change the size of the cube setObjectColor() has no 
effect on the cube's color.

Original comment by pat...@gmail.com on 2 Mar 2011 at 1:19

GoogleCodeExporter commented 9 years ago

Original comment by ikarpov on 7 Mar 2011 at 5:25

GoogleCodeExporter commented 9 years ago

Original comment by ikarpov on 10 Mar 2011 at 1:03

GoogleCodeExporter commented 9 years ago
Looking further into the bug, the OpenNERO code has the following ( in 
source/render/SceneObject.cpp:797 ):

            if ( mSharedData->IsDirty(SimEntityData::kDB_Color) )
            {
                if (mAniSceneNode) {
                    // The above workaround is not necessary anymore in Irrlicht 1.5
                    mAniSceneNode->getMaterial(0).DiffuseColor = mSharedData->GetColor();
                }
            }

In actuality, objects rendered by Irrlicht have materials with  several 
different color properties (see 
http://irrlicht.sourceforge.net/docu/classirr_1_1video_1_1_s_material.html). 
These are:

AmbientColor
    How much ambient light (a global light) is reflected by this material.

DiffuseColor
    How much diffuse light coming from a light source is reflected by this material.

EmissiveColor
    Light emitted by this material. Default is to emit no light. 

SpecularColor
    How much specular light (highlights from a light) is reflected.

The complete fix to this would require programmatic control over all material 
aspects including these colors. Currently these are assigned at object creation 
file from the material files.

The mid-term fix would require using the right combination of initial material 
and the right color setting code.

Original comment by ikarpov on 24 Mar 2011 at 4:44

GoogleCodeExporter commented 9 years ago

Original comment by ikarpov on 2 Jun 2011 at 11:14

GoogleCodeExporter commented 9 years ago

Original comment by ikarpov on 31 Aug 2011 at 2:24

GoogleCodeExporter commented 9 years ago

Original comment by ikarpov on 1 Sep 2013 at 7:00