import processing.opengl.*; float pts[][] = new float[100][3]; float tpts[][] = new float[100][3]; int np = 0; int i=0; float d=1000; float tx= 300.0; float ty=300.0; float tz=0.0; float cx=1.0, sx=0.0; float cy=1.0, sy=0.0; float lx=0, ly=0; void setup() { size(600, 600, OPENGL); i=-1; pts[++i][0]=-200.0; pts[i][1]=-200.0; pts[i][2]=0.0; pts[++i][0]=-200.0; pts[i][1]=-200.0; pts[i][2]=100.0; pts[++i][0]=200.0; pts[i][1]=-200.0; pts[i][2]=0.0; pts[++i][0]=200.0; pts[i][1]=-200.0; pts[i][2]=100.0; pts[++i][0]=200.0; pts[i][1]=200.0; pts[i][2]=0.0; pts[++i][0]=200.0; pts[i][1]=200.0; pts[i][2]=100.0; pts[++i][0]=-200.0; pts[i][1]=200.0; pts[i][2]=0.0; pts[++i][0]=-200.0; pts[i][1]=200.0; pts[i][2]=100.0; np=i; println(PI*(mouseX-width)/width); } void draw() { background(0); stroke(255); if (mousePressed) {d=d+mouseY-ly; ly=mouseY; if (d<200.0) {d=200.0;};} else { float ax = PI; ax=-ax*(mouseX-width)/width; cx=cos(ax); sx=sin(ax); float ay = PI; ay=ay*(mouseY-width)/width; cy=cos(ay); sy=sin(ay); }; transform(); stroke(15); strokeWeight(10); show(); // advance(); stroke(255); strokeWeight(2); show(); }; void mousePressed () {lx=mouseX; ly=mouseY;}; void transform() { for (int i=0; i<=np; i++) { float x=pts[i][0]; float y=pts[i][1]; float z=pts[i][2]; float t; t=x; x=t*cx-y*sx; y=t*sx+y*cx; t=z; z=t*cy-y*sy; y=t*sy+y*cy; x=d*x/(d+z); y=d*y/(d+z); z=d*z/(d+z); x=x+tx; y=y+ty; z=z+tz; tpts[i][0]=x; tpts[i][1]=y; tpts[i][2]=z; }; }; void show() { line(tpts[0][0],tpts[0][1],tpts[0][2],tpts[1][0],tpts[1][1],tpts[1][2]); line(tpts[2][0],tpts[2][1],tpts[2][2],tpts[3][0],tpts[3][1],tpts[3][2]); line(tpts[4][0],tpts[4][1],tpts[4][2],tpts[5][0],tpts[5][1],tpts[5][2]); line(tpts[6][0],tpts[6][1],tpts[6][2],tpts[7][0],tpts[7][1],tpts[7][2]); line(tpts[7][0],tpts[7][1],tpts[7][2],tpts[1][0],tpts[1][1],tpts[1][2]); line(tpts[1][0],tpts[1][1],tpts[1][2],tpts[3][0],tpts[3][1],tpts[3][2]); line(tpts[3][0],tpts[3][1],tpts[3][2],tpts[5][0],tpts[5][1],tpts[5][2]); line(tpts[5][0],tpts[5][1],tpts[5][2],tpts[7][0],tpts[7][1],tpts[7][2]); line(tpts[0][0],tpts[0][1],tpts[0][2],tpts[2][0],tpts[2][1],tpts[2][2]); line(tpts[2][0],tpts[2][1],tpts[2][2],tpts[4][0],tpts[4][1],tpts[4][2]); line(tpts[4][0],tpts[4][1],tpts[4][2],tpts[6][0],tpts[6][1],tpts[6][2]); line(tpts[6][0],tpts[6][1],tpts[6][2],tpts[0][0],tpts[0][1],tpts[0][2]); };