What is the easiest way to change a color of a 3d object. (primitive cone say)

Started by davec64, November 26, 2013, 06:37:20 AM

Previous topic - Next topic

davec64

I had this

tm.addTexture("platform", new Texture(0, 0, 0));
TextureInfo coneTex = new TextureInfo(tm.getTextureID("platform"));
    coneTex.add(tm.getTextureID("normals"), TextureInfo.MODE_MODULATE);
    tm.unloadTexture(fb, tm.getTexture("platform"));
    tm.replaceTexture("platform", new Texture(128, 128, red));


or

    tm.unloadTexture(fb, tm.getTexture("platform"));
    tm.replaceTexture("platform", new Texture(128, 128, green));

I just want to do this if possible.

depthColor = green;
        coneobj.setAdditionalColor(depthColor);

Dave

EgonOlsen

You can use setAdditionalColor if you can live with its restrictions. It's behaviour is based on how the OpenGL pipeline works and that will lead to results in a way that setAdditionalColor is actually setMultiplicativeColor (ignoring the ambient and light source color for now...). If you set green as an additional color, this should work well enough as long as the models texture has some amount of green in it. Example (only valid if no other kind of lighting is being used): If the fragment's color is (128,128,128) and you set (0,0,255) as an additional color, the result will be (0,0,128), which is somehow green. If the fragment's color is (255,255,0), the result would be (0,0,0), which is black. However, you usually don't have that kind of colors, so for the normal case, it actually works well enough.

davec64

Hi I resolved this by adding 3 textures of 0,0, size with different colors really simple and quick for a single texture object.

   tm.addTexture("conered", new Texture(0, 0, red));
      tm.addTexture("conegreen", new Texture(0, 0, green));
      tm.addTexture("coneorange", new Texture(0, 0, orange));

  if (channelDepth - reallocation.y < 1) {
      coneobj.setTexture("conered");

    }
    else if (channelDepth - reallocation.y < 2) {
      coneobj.setTexture("coneorange");

    }
    else {
      if (overlayBitmap != null) {
        coneobj.setTexture("conegreen");

      }
    }