I want create a 3d cube,wich you can rotate with w,a,s and d.
But when the cube rotate disappearing some cube faces.
See http://greenfootgallery.org/scenarios/3417
Thanks for your help.
Advenging
public class ZeichenBlatt extends Actor { int P2[][] = {{1,1,-1},{-1,1,-1},{-1,-1,-1},{1,-1,-1}}; int[] dx = new int[4]; int[] dy = new int[4]; int P3[][] = {{1,1,1},{-1,1,1},{-1,-1,1},{1,-1,1}}; int[] dx2 = new int[4]; int[] dy2 = new int[4]; int P4[][] = {{1,1,-1},{1,1,1},{-1,1,1},{-1,1,-1}}; int[] dx3 = new int[4]; int[] dy3 = new int[4]; int P5[][] = {{1,1,-1},{1,1,1},{1,-1,1},{1,-1,-1}}; int[] dx4 = new int[4]; int[] dy4 = new int[4]; int P6[][] = {{1,-1,-1},{1,-1,1},{-1,-1,1},{-1,-1,-1}}; int[] dx5 = new int[4]; int[] dy5 = new int[4]; int P7[][] = {{1,-1,-1},{1,1,-1},{1,1,1},{1,-1,1}}; int[] dx6 = new int[4]; int[] dy6 = new int[4]; double e = 100; int alpha = 0; int beta = 0; double a; double b; double Mx = 320; double My = 240; public ZeichenBlatt() { GreenfootImage img = new GreenfootImage(640,480); setImage(img); img.setColor(Color.BLACK); img.fill(); } public void act() { GreenfootImage img = getImage(); img.clear(); // Mx=Mx+0.2; img.setColor(Color.BLACK); img.fill(); if (Greenfoot.isKeyDown("q") ) { e=e+0.2; } if (Greenfoot.isKeyDown("e") ) { e=e-0.2; } if (Greenfoot.isKeyDown("a") ) { beta=beta+1; } if (Greenfoot.isKeyDown("d") ) { beta=beta-1; } if (Greenfoot.isKeyDown("w") ) { alpha=alpha+1; } if (Greenfoot.isKeyDown("s") ) { alpha=alpha-1; } if (Greenfoot.isKeyDown("left") ) { Mx=Mx-2; } if (Greenfoot.isKeyDown("right") ) { Mx=Mx+2; } if (Greenfoot.isKeyDown("up") ) { My=My-2; } if (Greenfoot.isKeyDown("down") ) { My=My+2; } for(int i2=0; i2<4; i2++) { dx[i2] = toPx(P2[i2], alpha, beta); dy[i2] = toPy(P2[i2], alpha, beta); } for(int i3=0; i3<4; i3++) { dx2[i3] = toPx(P3[i3], alpha, beta); dy2[i3] = toPy(P3[i3], alpha, beta); } for(int i4=0; i4<4; i4++) { dx3[i4] = toPx(P4[i4], alpha, beta); dy3[i4] = toPy(P4[i4], alpha, beta); } for(int i5=0; i5<4; i5++) { dx4[i5] = toPx(P5[i5], alpha, beta); dy4[i5] = toPy(P5[i5], alpha, beta); } for(int i6=0; i6<4; i6++) { dx5[i6] = toPx(P6[i6], alpha, beta); dy5[i6] = toPy(P6[i6], alpha, beta); } for(int i7=0; i7<4; i7++) { dx6[i7] = toPx(P7[i7], alpha, beta); dy6[i7] = toPy(P7[i7], alpha, beta); } img.setColor(Color.WHITE); img.fillPolygon(dx,dy,4); img.setColor(Color.YELLOW); img.fillPolygon(dx2,dy2,4); img.setColor(Color.RED); img.fillPolygon(dx3,dy3,4); img.setColor(Color.GREEN); img.fillPolygon(dx4,dy4,4); img.setColor(Color.ORANGE); img.fillPolygon(dx5,dy5,4); img.setColor(Color.BLUE); img.fillPolygon(dx6,dy6,4); } public int toPx(int A[], int alpha, int beta) { double a = Math.toRadians(alpha); double b = Math.toRadians(beta); double x = Mx+e*A[1]*Math.cos(b)-e*A[0]*Math.sin(b);// MX verschiebt würfel um x achse 1. Produkt gibt würfel seine form return (int)Math.round(x); } public int toPy(int A[], int alpha, int beta) { double a = Math.toRadians(alpha); double b = Math.toRadians(beta); double y = My-e*A[2]*Math.cos(a)+e*A[0]*Math.sin(a)*Math.cos(b)+e*A[1]*Math.sin(a)*Math.sin(b); return (int)Math.round(y); } }