setAdditionalColor

Started by Alexey, October 29, 2011, 02:18:41 PM

Previous topic - Next topic

Alexey

Hello, i try to set additional color for the object, but it not do any color changes. May do something wrong?

Object3dEx marker = new Object3dEx(Primitives.getPlane(1, 10));
initTextureByName(UITextureName.marker.name(), true);
marker.setBillboarding(true);
marker.setTransparency(5);
marker.setTexture(UITextureName.marker.name());
marker.compile();
marker.setLighting(Object3D.LIGHTING_NO_LIGHTS);
marker.build();
world.addObject(marker);
//function for pc/android realization depend to in color class
        addAdditionalColor(marker, new int[]{0,255 ,0});
marker.translate(marker.getTranslation().calcSub(placeObj.getTransformedCenter()));
marker.addParent(placeObj);

        public void addAdditionalColor(Object3D o, int[] color){
o.setAdditionalColor(new RGBColor(color[0], color[1], color[2]));
}



EgonOlsen

Keep in mind that an additional color will multiplied with existing color (i.e. texture color), not added. This means that a red texture will stay red (at best) even if you assign blue as an additional color. Maybe that's the problem here?

Alexey

I try on 2 objects (base color of texture - green) - to one of them add color 0,0,255 and cant see at least some difference

EgonOlsen

How green is that green? It doesn't get greener than green, i.e. 255*255 is cut off to 255. Try with some grey or white texture instead and see what happens then.

Alexey

Tried in empty new project - setAdditionalColor work fine, so something wrong in my project, if i find  the cause - i will write here

HammerNL

#5
Hi Egon,

I read in this thread that additional color is multiplied with the existing color. That would explain why my black object seems to ignore the additional color. However, setting an additional color of BLACK on a colored object, does not result in a BLACK object. So it's not a simple multiplication.

Also, your documentation states the color is added:

public void setAdditionalColor(RGBColor col)
Sets the additional color for this object. This color will be added to the regular color of each vertex (given by ambient, diffuse and specular lighting).

So I'm a bit confused here: Now how does additionalColor work exactly?

Tnx

EgonOlsen

It's added to the vertex' color and the result will be multiplied with the texture's color at that fragment.