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

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

light_source { <100, 80, -70> color rgb 1 }
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
	pigment { rgb <0.658824, 0.658824, 0.658824> }
	finish {
		ambient 0.3
		diffuse 0.7
		reflection 0.15
		brilliance 8
		specular 0.8
		roughness 0.1
	}
	rotate <15, 10, 20>
}

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