3Dサンプル(sketch_3D_Z_Channel)みぞ形鋼スケッチ
3Dサンプル(sketch_3D_Z_Channel)みぞ形鋼スケッチは以下となります。
//sketch_3D_Z_Channel みぞ形鋼
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_Channel(100,50,5,7.5,100);//Channel みぞ形鋼
}
void Z_Channel(float H,float B,float T1,float T2,float L)//Channel みぞ形鋼
{
int Pn=9;//ポイント数
float x1=B/2;
float x2=B/2-T1;
float y1=H/2;
float y2=H/2-T2;
float X[]={-x1,-x1,x1,x1,-x2,-x2,x1,x1,-x1};
float Y[]={-y1,y1,y1,y2,y2,-y2,-y2,-y1,-y1};
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);
}