float side = 100; float rad60=60*PI/180; float rotx = PI/4; float roty = PI/4; Pt p1 = new Pt(-side/2,0,0); Pt p2 = new Pt(0,sin(rad60)*(-side),0); Pt p3 = new Pt(side/2,0,0); Pt p4 = new Pt(0,sin(rad60)*(-side)*.5,sin(rad60)*(side)); Pt p5 = new Pt(side,0,0); Pt p6 = new Pt(side*1.5,sin(rad60)*side,0); Pt p7 = new Pt(2*side,0,0); Pt p8 = new Pt(side*1.5,sin(rad60)*side*.5,sin(rad60)*side); void setup() { size(800,600,P3D); } void draw() { background(0); translate(width/2.0, height/2.0, -100); rotateX(rotx); rotateY(roty); drawtetrahedron(230,0,0,p1,p2,p3,p4); drawtetrahedron(100,0,100,p5,p6,p7,p8); } void drawtetrahedron(int colR, int colG, int colB,Pt t1,Pt t2, Pt t3, Pt t4) { fill(colR,colG,colB); beginShape(TRIANGLES); vertex(t1.x,t1.y,t1.z); vertex(t2.x,t2.y,t2.z); vertex(t3.x,t3.y,t3.z); endShape(); beginShape(TRIANGLES); vertex(t1.x,t1.y,t1.z); vertex(t4.x,t4.y,t4.z); vertex(t3.x,t3.y,t3.z); endShape(); beginShape(TRIANGLES); vertex(t1.x,t1.y,t1.z); vertex(t4.x,t4.y,t4.z); vertex(t2.x,t2.y,t2.z); endShape(); beginShape(TRIANGLES); vertex(t2.x,t2.y,t2.z); vertex(t4.x,t4.y,t4.z); vertex(t3.x,t3.y,t3.z); endShape(); } void mouseDragged() { float rate = 0.01; rotx += (pmouseY-mouseY) * rate; roty += (mouseX-pmouseX) * rate; } class Pt { float x,y,z; Pt (float xx,float yy,float zz) { x = xx; y = yy; z = zz; } }