//sketch_3D_Z_Angle 山形鋼 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_Angle(50,5,100);//Angle 山形鋼 } void Z_Angle(float W,float T,float L)//Angle 山形鋼 { int Pn=7;//ポイント数 float x1=W/2; float x2=W/2-T; float X[]={-x2,-x1,-x1,x1,x1,-x2,-x2}; float Y[]={-x1,-x1,x1,x1,x2,x2,-x1}; pushMatrix(); Z_Side(Pn,X,Y,L);//側面 translate(0,0,-L/2); Z_Polyon(Pn,X,Y);//多角形 translate(0,0,L); Z_Polyon(Pn,X,Y);//多角形 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[])//多角形 { int i; beginShape(); for (i = 0; i < Pn; ++i) { vertex(X[i],Y[i]); } endShape(CLOSE); }