#include "colors.inc"

// Trabalho 2 de MC930

// ======================================================================
// CÂMERA 

camera {
  location  <  6.00, 2.00, 6.00 >  // Posição do observador.
  right      0.75*x                // Largura RELATIVA da imagem.
  up        -1.00*y                // Altura RELATIVA da imagem.      
  sky       y                      // Qual direção é "para cima"?
  look_at   <  0.00, 0.00, 0.00 >  // Para onde a câmera está apontando.
} 
// Nota: os parâmetros "right" e "up" devem ter a mesma proporção
// que os parâmetros ${WIDTH} e ${HEIGHT} no Makefile.

// ======================================================================
// FONTES DE LUZ

light_source {
  10 * < +50.0, +30.0, +50.0 >              // Posição da lâmpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10 * < +50.0, -10.0, +10.0 >             // Posição da lâmpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

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

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

////////////Declaração das cores

#declare dourado_metalico =
  texture {
    pigment { Gold }
    finish {
        ambient 0.05
        diffuse 0.5
        reflection {
                0.5
                metallic
        }
        specular 0.1
        roughness 0.05
        }
  }

#declare prata_metalico =
  texture {
    pigment { Silver }
    finish {
      ambient 0.05
      diffuse 0.5
      reflection {
        0.5
        metallic
      }
      specular 0.1
      roughness 0.05
    }
  }

#declare ciano_espelhado =
  texture {
    pigment { Cyan filter 0.5}
    finish {
      ambient 0.1
      diffuse 0.35
      reflection 0.25
      specular 1
      roughness 0.001
    }
  }

#declare vermelho_espelhado =
  texture {
    pigment { Red filter 0.5}
    finish {
      ambient 0.1
      diffuse 0.35
      reflection 0.25
      specular 1
      roughness 0.001
    }
  }

#declare azul_espelhado =
  texture {
    pigment { Blue filter 0.5}
    finish {
      ambient 0.1
      diffuse 0.35
      reflection 0.25
      specular 1
      roughness 0.001
    }
  }

/////////// A cena segue abaixo:

// A base da coroa
difference {
  lathe {
    linear_spline
    4,
    <1,0>, <2,0>, <3,3>, <2,2>
    texture { dourado_metalico }
    finish {
      ambient .3
      phong .75
    }
  }

//Cilindros para fazer os detalhes superiores da coroa
  union {
    cylinder {
      <3, 3.2, 0>,     // Center of one end
      <-3, 3.2, 0>,     // Center of other end
      1.6            // Radius
      texture { prata_metalico }
    }

    cylinder {
      <3, 3.2, 0>,     // Center of one end
      <-3, 3.2, 0>,     // Center of other end
      1.6            // Radius
      texture { prata_metalico}
      rotate 60*y
    }
  
    cylinder {
      <3, 3.2, 0>,     // Center of one end
      <-3, 3.2, 0>,     // Center of other end
      1.6            // Radius
      texture { prata_metalico}
      rotate 120*y
    }
  }
}

//Detalhe prateado da coroa
torus {
  2.35, 0.2              // major and minor radius
  translate 1.3*y
  texture { prata_metalico }
}

//Pedras preciosas da coroa
  sphere {
    < 2.00, 0.70, 0.00 >, 0.35
    texture { ciano_espelhado }
  }
  sphere {
    < 2.00, 0.70, 0.00 >, 0.35
    texture { vermelho_espelhado }
    rotate 60*y
  }
  sphere {
    < 2.00, 0.70, 0.00 >, 0.35
    texture { azul_espelhado }
    rotate 120*y
  }

  sphere {
    < 2.00, 0.70, 0.00 >, 0.35
    texture { ciano_espelhado }
    rotate 180*y
  }
  sphere {
    < 2.00, 0.70, 0.00 >, 0.35
    texture { vermelho_espelhado }
    rotate 240*y
  }
  sphere {
    < 2.00, 0.70, 0.00 >, 0.35
    texture { azul_espelhado }
    rotate 300*y
  }


//Plano onde a coroa descansa
plane { <0, 1, 0>, 0
  pigment {
    checker color White, color Black
  }
}