// ======================================================================
// CORES E TEXTURAS

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

#declare tx_liquid = 
  texture {
    pigment { color rgb <1.00, 0.80, 0.10> filter 0.7 }
    finish { diffuse 0.2 reflection 0.8 }
  }

#declare tx_vidro = 
  texture{
    pigment { color rgb < 0.85, 0.95, 1.00 > filter 0.70 }
    finish { diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 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
  }

#declare tx_fosca = 
  texture{
    pigment{ color rgb < 0.2, 0.2, 0.2 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

// ======================================================================
// DESCRIÇÃO DA CENA 

#declare raio = 2.000;
#declare feet_distance = 2.5;
#declare foot_height = 2;

// Partes da cena:
#declare chao = 
  box{ <-40,-40,-1>, <+40,+40,0> }

#declare platform =
  intersection {
    sphere {
      <0, 0, 0>, feet_distance
    }

    box {
      <-feet_distance, -feet_distance, -0.1>,
      <+feet_distance, +feet_distance, +0.1>
    }

    translate <-feet_distance/2, -feet_distance/2, foot_height>
    texture { tx_vidro }
  }

#declare erlenmeyer =
  union {
    difference {
      cylinder {
        <0, 0, 1>, <0, 0, foot_height>, 0.2
      }

      cylinder {
        <0, 0, 1>, <0, 0, foot_height>, 0.1
      }
    }

    difference {
      cone {
        <0, 0, 0>, 1
        <0, 0, 1>, 0.2
      }

      cone {
        <0, 0, 0.05>, 0.9
        <0, 0, 1>, 0.1
      }
    }

    texture { tx_vidro }
  }

#declare liquid =
  cone {
    <0, 0, 0.05>, 0.9
    <0, 0, 0.55>, (0.8 * 0.5) / 0.95
    texture { tx_liquid }
  }

#declare chair_feet = 
  union {
    union {
      object { liquid pigment { color rgbf <1.00, 0.80, 0.10, 1> } }
      object { erlenmeyer }
    }

    union {
      object { liquid pigment { color rgb <1.00, 0, 0, 1> } }
      object { erlenmeyer }

      translate <-feet_distance, 0, 0>
    }

    union {
      object { liquid pigment { color rgb <0, 0.80, 0.50, 1> } }
      object { erlenmeyer }

      translate <0, -feet_distance, 0>
    }

    union {
      object { liquid pigment { color rgb <0.50, 0, 0.90, 0.9> } }
      object { erlenmeyer }

      translate <-feet_distance, -feet_distance, 0>
    }

    texture { tx_vidro }
  }

#include "eixos.inc"

union {
  object { chao texture { tx_xadrez } }
  
  object { chair_feet scale 1 }
  object { platform }

  object {
    platform
    rotate <0, 90, 0>
    translate <-feet_distance * 2 - 1, -0.4, foot_height * 2 + 1>
    scale 0.75
  }

  box {
    <-feet_distance - 0.5, -feet_distance * 3 / 5, foot_height + 0.1>,
    <-feet_distance - 0.6, -feet_distance * 2 / 5, foot_height + 0.9>
    texture { tx_fosca }
  }

  translate <0, 0, -2>
}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 1.00 >;
#declare raio_cena = 8.0;
#declare dir_camera = < 14.00, 7.00, 6.00 >;
#declare dist_camera = 5*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)