Author Topic: setAdditionalColor  (Read 1690 times)

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
setAdditionalColor
« 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]));
}



Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: setAdditionalColor
« Reply #1 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?

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
Re: setAdditionalColor
« Reply #2 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: setAdditionalColor
« Reply #3 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.

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
Re: setAdditionalColor
« Reply #4 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

Offline HammerNL

  • byte
  • *
  • Posts: 15
    • View Profile
Re: setAdditionalColor
« Reply #5 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
« Last Edit: December 02, 2013, 10:55:56 am by HammerNL »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: setAdditionalColor
« Reply #6 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.