// Last edited on DATE TIME by USER
// Processed by remove-cam-lights

background{ color rgb < 0.75, 0.80, 0.85 > }

#declare tx_plastico =
  texture{
    pigment{ color rgb < 0.10, 0.80, 1.00 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_cantor =
  texture{
    pigment{ color rgb < 0.50, 0.90, 0.80 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_cantor2 =
  texture{
    pigment{ color rgb < 0.60, 0.50, 0.80 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_cantor3 =
  texture{
    pigment{ color rgb < 0.90, 0.70, 0.80 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_cantor4 =
  texture{
    pigment{ color rgb < 0.0, 0.99, 0.4 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_cantor5 =
  texture{
    pigment{ color rgb < 0.99, 0.99, 0.0 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_xadrez =
  texture{
    pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 2.0
  }

#macro degrau(nivel)
        box{
                < 0, 0, 0 >,
                < 6, nivel, 0.5+(6-nivel)/2 >
                texture{ tx_plastico }
        }
#end

#macro cantor(degrau,cantorPos)
        cone{   < cantorPos-0.5, degrau-0.5, 0.5+(6-degrau)/2 >,
                  0.3,
                < cantorPos-0.5, degrau-0.5, 1+(6-degrau)/2 >,
                  0.2
                #if (degrau=1)
                   texture{ tx_cantor2 }
                #end
                #if (degrau>1)
                   texture{ tx_cantor }
                #end
                #if (degrau=3 & cantorPos >= 3)
                   texture{ tx_cantor3 }
                #end
                #if (degrau=5 & cantorPos <= 3)
                   texture{ tx_cantor4 }
                #end
                #if (degrau=6 & cantorPos >= 3)
                   texture{ tx_cantor5 }
                #end
        }

        sphere { < cantorPos-0.5, degrau-0.5, 1.3+(6-degrau)/2 >, 0.2
                #if (degrau=1)
                   texture{ tx_cantor2 }
                #end
                #if (degrau>1)
                   texture{ tx_cantor }
                #end
                #if (degrau=3 & cantorPos >= 3)
                   texture{ tx_cantor3 }
                #end
                #if (degrau=5 & cantorPos <= 3)
                   texture{ tx_cantor4 }
                #end
                #if (degrau=6 & cantorPos >= 3)
                   texture{ tx_cantor5 }
                #end

        }

#end

#declare chao =
  box{ <-20,-20,-1>, <+20,+20,0> }

#include "eixos.inc"

union{
  object{ eixos(8) }
  object{ chao  translate < 0,0,-5 > texture{ tx_xadrez } }

        #declare i = 6;
        #while ( i > 0 )
          degrau(i)

                #declare c=6;
                #while ( c > 0 )
                  cantor(i,c)
                  #declare c = c - 1;
                #end

          #declare i = i - 1;
        #end

}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 1.00 >;
#declare raio_cena = 10.0;
#declare dir_camera = < 8.00, 10.00, 5.00 >;
#declare dist_camera = 18.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)