Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Miridian

Pages: [1]
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:
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 :D
Please help me. Sorry I am sure it is very simple but I just dont get on it.

2
Support / Need some help calculating angles of an onscreen joystick
« on: January 10, 2011, 09:18:37 pm »
Hi, I have started writing my first java project a few days ago.
It is a small game where I am using an onscreen joystick to turn the player.
I already have the joystick and the player but I cant find out how to turn the player by the angle of the joystick.

Code:

Code: [Select]
//get the angle
//initx,inity is the start point of the joystick
//touchingPoint is the point where the finger is touching the screen.
angle = Math.atan2(touchingPoint.y - inity,touchingPoint.x - initx);

//rotate the player
player_mesh.rotateY((float) (jpctaetest.controls.getAngle()/10)* ft);


I think it am using the wrong way for the angle because my player mesh is rotating slow when the joystick is on the right side and very fast when it is on the left  ???
please help  :)

Pages: [1]