www.jpct.net
jPCT-AE - a 3d engine for Android => Support => Topic started by: kiffa on March 22, 2013, 12:40:29 pm
-
I'm writing a SceneLoader which has a feature: auto setting Object3D's transparency by it's texture. Codes may like that:
Texture texture = TextureManager.getInstance().getTexture(name);
object3d.setTexture(name);
if(texture.containsAlpha()){
object3d.setTransparency(0xff);
}
But there isn't a method like texture.containsAlpha().
-
I'm writing a SceneLoader which has a feature: auto setting Object3D's transparency by it's texture. Codes may like that:
Texture texture = TextureManager.getInstance().getTexture(name);
object3d.setTexture(name);
if(texture.containsAlpha()){
object3d.setTransparency(0xff);
}
But there isn't a method like texture.containsAlpha().
Mabe load/convert as a bitmap, get the pixels as array, check all first byte value's of 4 (ARGB) ?
-
You can get a Texture's pixels from an ITextureEffect as well.
-
Both of the above are not easy to use(for my case). Could you add the method Texture.containsAlpha() ?
-
Both of the above are not easy to use(for my case). Could you add the method Texture.containsAlpha() ?
A Bitmap object in Java/Android has a 'hasAlpha()' flag. So you could load your texture as bitmap and then add it as texture.
Something like the following would do the trick:
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.YOURBITMAP);
if (bmp.hasAlpha()==true)
{
//This bitmap has alpha ..
}
//Now you can pass your bitmap as texture
Texture YOURTEXTURE = new Texture(bmp);