1
Support / Need some help with texture tranparency
« on: January 15, 2011, 11:26:50 pm »
Hi,
I would like to show some text above some 3d Objects.
Searching and trying different sollutions the whole day I capitulate now and ask here.
I cannot find a solution how to make the black background of the texture transparent.
Sample code:
With this code the background is not visible but my text is too bright and it is transparent too
Please help me. Sorry I am sure it is very simple but I just dont get on it.
I would like to show some text above some 3d Objects.
Searching and trying different sollutions the whole day I capitulate now and ask here.
I cannot find a solution how to make the black background of the texture transparent.
Sample code:
Code: [Select]
Paint paint = new Paint();
paint.setColor(Color.rgb(0, 50, 0));
Bitmap.Config config = Bitmap.Config.ARGB_8888;
FontMetricsInt fontMetrics = paint.getFontMetricsInt();
int baseline = -fontMetrics.top;
Bitmap charImage = Bitmap.createBitmap(128, 128, config);
Canvas canvas = new Canvas(charImage);
canvas.drawRGB(0,0,0);
canvas.drawText("here will be some text", 1, baseline, paint);
Texture texture = new Texture(charImage,false);
TextureManager.getInstance().addTexture("texture", texture);
plane = Primitives.getPlane(10, 6);
plane.setLighting(Object3D.LIGHTING_NO_LIGHTS);
RGBColor c=new RGBColor(255,255,255);
plane.setAdditionalColor(c);
plane.setTexture("texture");
plane.setTransparency(200);
plane.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
plane.strip();
plane.build();
world.addObject(plane);
With this code the background is not visible but my text is too bright and it is transparent too
Please help me. Sorry I am sure it is very simple but I just dont get on it.