//sketch_3D_Z_H_shapejHŒ`| void setup() { size(400, 400, P3D); } void draw() { background(255, 255, 255); lights(); ortho(-width/2, width/2, -height/2, height/2); // Same as ortho() translate(width / 2, height / 2); rotateY(map(mouseX, 0, width, -PI/1, PI/1)); rotateX(map(mouseY, 0, height, PI/1, -PI/1)); //noStroke(); strokeWeight(0.5); fill(255, 255, 255); scale(1, 1,1); Z_H_shape(100,100,6,8,100);//H_shape HŒ`| } void Z_H_shape(float H,float B,float T1,float T2,float L)//H_shape HŒ`| { int Pn=13;//ƒ|ƒCƒ“ƒg” float x1=B/2; float x2=T1/2; float y1=H/2; float y2=H/2-T2; float X[]={-x1,x1,x1,x2,x2,x1,x1,-x1,-x1,-x2,-x2,-x1,-x1}; float Y[]={-y1,-y1,-y2,-y2,y2,y2,y1,y1,y2,y2,-y2,-y2,-y1}; pushMatrix(); Z_Side(Pn,X,Y,L);//‘¤–Ê translate(0,0,-L/2); Z_Polyon(Pn,X,Y);//‘½ŠpŒ` translate(0,0,L); Z_Polyon(Pn,X,Y);//‘½ŠpŒ` popMatrix(); } void Z_Side(int Pn,float X[],float Y[],float L)//‘¤–Ê { int i; beginShape(QUAD_STRIP); for (i = 0; i < Pn; ++i) { vertex(X[i],Y[i], -L/2); vertex(X[i],Y[i], L/2); } endShape(CLOSE); } void Z_Polyon(int Pn,float X[],float Y[])//‘½ŠpŒ` { int i; beginShape(); for (i = 0; i < Pn; ++i) { vertex(X[i],Y[i]); } endShape(CLOSE); }