Author Topic: How to set the transparency of texture?  (Read 2149 times)

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
How to set the transparency of texture?
« on: August 27, 2012, 09:35:16 am »
I used a PNG file with alpha channel as the texture of an Objcet3D, and some fragment of the Object3D were mapped to full-transparency pixel of the texture.

But when i run the app, the fragment which should be full-transparency were filled with black color.

How do i set the transparency of texture? My codes:

Code: [Select]
      in = res.openRawResource(R.raw.tex_world_trees);
      Texture t = new Texture(in, true);  // with alpha
      tm.addTexture("world_trees", t);
      in.close();
     
     obj.setTexture("world_trees");

    world.addObject(obj);
    //render、draw、display...
   

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How to set the transparency of texture?
« Reply #1 on: August 27, 2012, 10:20:17 am »
Just enable transparency for the object (Object3D.setTransparency(...)).

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Re: How to set the transparency of texture?
« Reply #2 on: August 27, 2012, 04:18:30 pm »
Now it's ok! Thanks!