/*------------------------------------------------------------------------------
   Script   : Hallowe.PoV    Auteur : Krohorl    Date : 15-Apr-1995
------------------------------------------------------------------------------*/
// --- Quelques couleurs bien senties ---
// --- A few colors ---
#declare Blanc = color red 1 green 1 blue 1
#declare Gris = color red 0.5 green 0.5 blue 0.5
#declare OrangeCitrouille = color red 1 green 0.4 blue 0
#declare JauneOrange = color red 1 green 0.9 blue 0
#declare Ivoire = color red 1 green 0.85 blue 0.72

// --- La texture de la citrouille (intrieur et extrieur) ---
// --- The texture for the pumpkin (inside and outside) ---
#declare CitrouilleTex = texture {
  pigment { color OrangeCitrouille }
  normal { bumps 0.8 scale <0.09,0.3,0.13> }
  finish { ambient 0.4 diffuse 0.4 specular 0.4 roughness 0.01 } }

// --- La texture des dents ---
// --- The texture for the teeth ---
#declare DentsTex = texture {
  pigment { color Ivoire }
  normal { wrinkles 4 scale <0.05,0.05,0.05> }
  finish { ambient 0.4 diffuse 0.3 specular 0.4 roughness 0.002 } }

// --- Pour dcouper les yeux ---
// --- Tool for cutting the eyes ---
#declare TriaPrismeZ = difference {
    box { <-1,0,-1>,<1,1,1> }
    plane { <1,0,0>,0 rotate <0,0,-45> translate <-1,0,0> }
    plane { <1,0,0> 0 inverse rotate <0,0,45> translate <1,0,0> } }
// --- Pour dcouper le sourire ---
// --- Tools for cutting the smile ---
#declare LunePrismeZ = difference {
  cylinder { <0,0,-1>,<0,0,1>,1 }
  cylinder { <0,0,-2>,<0,0,2>,1.3 translate <0,0.8,0> } }
// --- Quartier de citrouille ---
// --- Part of the pumkin ---
#declare Quartier = sphere { <0,0,0>,1 scale <2.2,2.2,1> translate <-1,0,0> }
// --- Pour faire les dents ---
// --- Teeth ---
#declare Dents = cylinder { <0,-0.3,0>,<0,0.3,0>,0.1 }
// --- La citrouille ---
// --- The pumpkin ---
#declare Citrouille = union {
    object {
      difference {
        union {
          object { Quartier rotate <0,0,0> }
          object { Quartier rotate <0,20,0> }
          object { Quartier rotate <0,40,0> }
          object { Quartier rotate <0,60,0> }
          object { Quartier rotate <0,80,0> }
          object { Quartier rotate <0,100,0> }
          object { Quartier rotate <0,120,0> }
          object { Quartier rotate <0,140,0> }
          object { Quartier rotate <0,160,0> }
          object { Quartier rotate <0,180,0> }
          object { Quartier rotate <0,200,0> }
          object { Quartier rotate <0,220,0> }
          object { Quartier rotate <0,240,0> }
          object { Quartier rotate <0,260,0> }
          object { Quartier rotate <0,280,0> }
          object { Quartier rotate <0,300,0> }
          object { Quartier rotate <0,320,0> }
          object { Quartier rotate <0,340,0> } }
        object { sphere { <0,0,0>,1 scale <2.55,2,2.55> } }
        object { TriaPrismeZ scale <0.8,0.9,1> rotate <0,0,3> translate <-1.08,0.43,-2.8> }
        object { TriaPrismeZ scale <0.82,0.87,1> rotate <0,0,-8> translate <1,0.47,-2.8> }
        object { LunePrismeZ scale <2,1,1> translate <0,0,-2.8> } }
      texture { CitrouilleTex } }
    object {
      union {
        object { Dents rotate <0,0,10> translate <-1.1,-0.4,-2.4> }
        object { Dents translate <-0.2,-1.05,-2.4> }
        object { Dents rotate <0,0,-20> translate <0.5,-0.4,-2.6> } }
      texture { DentsTex } }
    scale <1,1.2,1>
    bounded_by { sphere { <0,0,0>,4 } } }

// --- Les textures du chapeau ---
// --- The textures for the hat ---
#declare ChapeauCol = color red 0.7 green 0.5 blue 0.7
#declare BordureCol = color red 0.5 green 0.3 blue 0.6
#declare ChapeauTex = texture {
  pigment { color ChapeauCol }
  normal { ripples 1 frequency 4 scale <0.2,0.2,0.2> }
  finish { ambient 0.4 diffuse 0.5 specular 0.25 roughness 0.15 } }
#declare BordureTex = texture {
  pigment { color BordureCol }
  normal { dents 2 scale <0.1,0.1,0.1> }
  finish { ambient 0.4 diffuse 0.6 specular 0.1 roughness 0.2 } }

// --- Le chapeau : une quadrique : x2y + yz2 + 0.04y + 0.04 = 0 ---
// --- The hat : it's a quadric shape with formula ^^^. ---
#declare Chapeau = union {
  // --- Le chapeau / The hat ---
  object {
    intersection {
      quartic {
        < 0,  0,  0,  0,  0,  0,  1,  0,  0,  0,
          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
          0,  0,  0,  0,  0,  0,  0,  1,  0,  0.04,
          0,  0,  0,  0,  0.04 > inverse }
      cylinder { <0,-100,0>,<0,-0.05,0>,1 } }
    texture { ChapeauTex } }
  // --- La bordure / Bottom of the hat ---
  object { sphere { <0,0,0>,1 scale <1.04,0.06,1.04> translate <0,0.008,0> } texture { BordureTex } }
  rotate <180 0 0> rotate <0,0,4> scale <4.5,5,4.5>
  bounded_by { box { <-5,-0.2,-5> <5,5,5> } } }

// --- la texture du corps ---
// --- The texture for the body ---
#declare CorpsCol1 = color red 0.52 green 0.90 blue 0.60
#declare CorpsCol2 = color red 0.92 green 1.00 blue 0.60
#declare CorpsTex = texture {
  pigment { 
    bozo turbulence 0.5 lambda 2 scale 0.5
    color_map {
      [0.20 color CorpsCol1]
      [0.90 color CorpsCol2] } }
  normal { bumps 0.6 scale <0.12,0.18,0.12> }
  finish { ambient 0.1 diffuse 0.4 specular 0.15 roughness 0.05 } }

// --- Le corps / The body ---
#declare Corps =
  object {
    intersection {
      // --- It's another quadric wich is the product of :
      //       1 - the beginning of a Taylor development of the sinusod y=Sin(x)*Sin(z)
      //       2 - the surface x2y2 + x2z2 + y2z2 + 10xy + 10yz + 10xz wich is a 3D cross with circular section
      //     The result is the formula : z4/24 + z2/2 + x2y2 + x2z2 + y2z2 +K = 0 where K can vary.
      quartic {
        < 0.0416, 0,  0,  0,  1,  0,  0,  1,  0, -0.5,
          0,      0,  0,  0,  0,  0,  0,  0,  0,  0,
          0,      0,  0,  1,  0,  0,  0,  0,  0, -1,
          0.0416, 0, -0.5,0,  0.3 > /* sturm */ }
      box { <-5,-5,-5> <5,5,5> } }
    texture { CorpsTex }
    bounded_by { box { <-5,-5,-5> <5,5,5> } }
    scale <2,2,2> rotate <180,35,0> }

// --- le fond toil ---
// --- Star sky is a very simple image mapped onto a sphere. The shadows are casted outside the viewed area, so
//     I can use high value for diffuse to increase simulated stars light ---
#declare Ciel = object {
  sphere { <0,0,0>,500 }
  texture {
    pigment { image_map { gif "HalloSta.Gif" map_type 0 interpolate 4 } scale <60,60,60> }
    finish { ambient 1 diffuse 0.8 } } }

// === Sc
camera { location <0,30,-300> direction <0,0,25> look_at <0,1,0> }

// --- Les bougies de l'intrieur ---
// --- Lights to simulate candles in the pumpkin ---
object { light_source { <-0.1,0,0> color JauneOrange } }
object { light_source { <0.1,0,0> color JauneOrange } }

// --- Eclairage extrieur ---
// --- Outside light ---
object { light_source { <-10,10,-40> color Gris } }

// --- Le ciel /The sky ---
object { Ciel }

object { Citrouille }
object  { Chapeau translate <0,1.7,0> }
object { Corps translate <0,-2,0>}
