3d cube using canvas. Need a little improvement

Posted by TimeManx on Stack Overflow See other posts from Stack Overflow or by TimeManx
Published on 2012-08-30T21:02:13Z Indexed on 2012/09/05 3:38 UTC
Read the original article Hit count: 144

I made this 3d cube using the following code

Matrix mMatrix = canvas.getMatrix();

canvas.save();
camera.save();
camera.rotateY(-angle);
camera.getMatrix(mMatrix);
mMatrix.preTranslate(-width, 0);
mMatrix.postTranslate(width, 0);
canvas.concat(mMatrix);
canvas.drawBitmap(bmp1, 0, 0, null);
camera.restore();
canvas.restore();

camera.rotateY(90 - angle);
camera.getMatrix(mMatrix);
mMatrix.preTranslate(-width, 0);
mMatrix.postTranslate(width2, 0);
canvas.concat(mMatrix);
canvas.drawBitmap(bmp2, width, 0, null);

This is what it gives

enter image description here

But what I need is

enter image description here

It's because when Camera rotates the images, some part of the image gets hidden. Like thisenter image description here

But I think this can be done.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-animation