model model1;

procedure SimpleWall(const x1, z1, x2, z2, h1, h2: float; const u, v: float);
begin
  glbegin(GL_QUADS);
    glTexCoord2f(u, v); 
    glVertex3f(x1, h1, z1);
    glTexCoord2f(u + 0.1, v); 
    glVertex3f(x1, h2, z1);
    glTexCoord2f(u + 0.1, v + 0.1); 
    glVertex3f(x2, h2, z2);
    glTexCoord2f(u, v + 0.1); 
    glVertex3f(x2, h1, z2);
  glEnd;
end;

procedure SimpleFlat(const x1, z1, x2, z2, h: float; const u, v: float);
begin
  glTexCoord2f(u, v); 
  glbegin(GL_QUADS);
    glVertex3f(x1, h, z1);
    glVertex3f(x1, h, z2);
    glVertex3f(x2, h, z2);
    glVertex3f(x2, h, z1);
  glEnd;
end;

procedure Basket(const x1, y1, z1, x2, y2, z2: float; const u, v: float);
begin
  SimpleFlat(x1, z1, x2, z2, y1, u, v);  
  SimpleWall(x1, z1, x1, z2, y1, y2, u, v);
  SimpleWall(x1, z2, x2, z2, y1, y2, u, v);
  SimpleWall(x2, z2, x2, z1, y1, y2, u, v);
  SimpleWall(x2, z1, x1, z1, y1, y2, u, v);
end;

procedure myvert(const x, y, z, u: float);
begin
  glTexCoord2f(u, y);
  glVertex3f(x, y, z);
end;
  
procedure Cylinder(r1, r2, h1, h2: float);
var
  radius, halfLength: float;
  i, slices: integer;
  theta, nextTheta: float;
begin
  slices := 8;
  for i := 0 to slices - 1 do
  begin
    theta := i * 2.0 * PI / slices;
    nextTheta := (i + 1) * 2.0 * PI / slices;
    glBegin(GL_TRIANGLE_STRIP);
      myvert(r1 * cos(theta), h1, r1 * sin(theta), i / slices);
      myvert(r2 * cos(theta), h2, r2 * sin(theta), i / slices);
      myvert(r1 * cos(nextTheta), h1, r1 * sin(nextTheta), (i + 1) / slices);
      myvert(r2 * cos(nextTheta), h2, r2 * sin(nextTheta), (i + 1) / slices);
    glEnd;
  end;
end;

begin
  SetFrame(0);
  Cylinder(0.05, 0.08, 0.12, 0.16);
  Cylinder(0.08, 0.10, 0.16, 0.19);
  Cylinder(0.10, 0.14, 0.19, 0.26);
  Cylinder(0.14, 0.16, 0.26, 0.31);
  Cylinder(0.16, 0.17, 0.31, 0.35);
  Cylinder(0.17, 0.17, 0.35, 0.38);
  Cylinder(0.17, 0.16, 0.38, 0.41);
  Cylinder(0.16, 0.13, 0.41, 0.45);
  Cylinder(0.13, 0.10, 0.45, 0.47);
  Cylinder(0.10, 0.07, 0.47, 0.48);
  Cylinder(0.07, 0.00, 0.48, 0.49);
  Basket(-0.04,  0.00, -0.04, 0.04, 0.06, 0.04, 0.0, 0.5); 
  Basket(-0.04,  0.06, -0.04, -0.035, 0.13, -0.035, 0.75, 0.75); 
  Basket(-0.04,  0.06,  0.035, -0.035, 0.13,  0.04, 0.75, 0.75); 
  Basket(0.035,  0.06, -0.04, 0.04, 0.13, -0.035, 0.75, 0.75); 
  Basket(0.035,  0.06,  0.035, 0.04, 0.13, 0.04, 0.75, 0.75); 
end.
