// "Nicht gefraest"
// Alternative Modellierung des Objekts von Stefan Lagotzki
// Simple Animation durch clock-Variable
// 2/2002 Christian Perle

#include "colors.inc"
#include "textures.inc"

camera {
  location <1-2*clock, 1-clock, -5>
  direction 3*z
  look_at 0
}

light_source { <100, 80, -70> color White }
light_source { <-50, 40, -40> color rgb<.8, .8, .6> }

// Alles umschliessende Kugel (Himmel)
sphere {
  0, 1 hollow
  pigment {
    bozo scale <1, .2, 1>*0.1 turbulence .7
    color_map {
      [0 color rgb<.2, .6, 1>]
      [.7 color rgb<.6, .8, 1>]
      [1 color rgb<.9, .9, 1>]
    }
  }
  finish { ambient 1 diffuse 0 }
  scale 1000
}

// Einheitswuerfel als Grundobjekt
#declare UnitBox = box { -.5, .5 }

// Radius der herausgefraesten Zylinder
#declare CarveRad = .49

#declare CarvedBox = difference {
  object { UnitBox }
  cylinder { -.51*x, .51*x, CarveRad }
  cylinder { -.51*x, .51*x, CarveRad rotate 90*y }
  cylinder { -.51*x, .51*x, CarveRad rotate 90*y rotate 90*x }
}

// Skalierungsfaktor fuer die Schachtelung
#declare NScale = .8

#declare Nest = union {
  object { UnitBox scale NScale }
  object { CarvedBox }
}

// Rotation auf allen drei Achsen abhaengig von 0 <= clock < 1
#declare RotStep = <10, 15, 20>*clock

// Schachtelungstiefe 8
#declare NDepth = 8
#declare I = 0
#while (I<NDepth)
#declare NestN = union {
  object { CarvedBox }
  object { Nest scale NScale rotate RotStep }
}
#declare Nest = object { NestN }
#declare I = I+1
#end

object {
  Nest
  texture { Chrome_Metal }
  rotate <15, 10, 20>
}

// etwas unebene Ebene :-)
plane {
  y, -1 hollow
  pigment { White }
  normal { crackle .2 scale .6 }
}