www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Alexey on October 29, 2011, 02:18:41 pm

Title: setAdditionalColor
Post by: Alexey on October 29, 2011, 02:18:41 pm
Hello, i try to set additional color for the object, but it not do any color changes. May do something wrong?
Code: [Select]
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]));
}


Title: Re: setAdditionalColor
Post by: EgonOlsen on October 29, 2011, 05:23:35 pm
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?
Title: Re: setAdditionalColor
Post by: Alexey on October 30, 2011, 02:21:47 pm
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
Title: Re: setAdditionalColor
Post by: EgonOlsen on October 30, 2011, 08:13:27 pm
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.
Title: Re: setAdditionalColor
Post by: Alexey on November 01, 2011, 08:54:56 am
Tried in empty new project - setAdditionalColor work fine, so something wrong in my project, if i find  the cause - i will write here
Title: Re: setAdditionalColor
Post by: HammerNL on December 02, 2013, 10:48:30 am
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
Title: Re: setAdditionalColor
Post by: EgonOlsen on December 02, 2013, 03:52:50 pm
It's added to the vertex' color and the result will be multiplied with the texture's color at that fragment.