/*
 *		H E X A B E N Z
 */
// =======================================================

#macro Benz_Cone_Base ()		//  = object
// {
union	{
	#local RA = R_basecone;
	#local RB = 0.001;
	difference {
		cone { 0, RA, y*0.89, 0.0001 }
		cone { 0, RA, y*0.89, 0.0001 translate -0.014*y }
		}
	difference {
		sphere { 0, RA*1.098 scale <1, 0.58, 3.03> }
		sphere { 0, RA*1.096 scale <1, 0.58, 3.03> }
		translate -0.02*y
		}
	}
// }
#end

#macro Benz_Cones ()		// = object
// {
union	{
	#for (foo, 0, 360, 60)
	#local E = 0.31;
	#local Tx = E * sin(radians(foo));
	#local Ty = E * cos(radians(foo));
	object {
		Benz_Cone_Base ()
		#local R = rand(Rng1);
		#if ( R < 0.3333 )
		  texture { T_Silver_2C scale 11.50 }
		#elseif ( R < 0.6666 )
		  texture { T_Brass_2C   scale 13.50 }
		#else
		  texture { T_Brass_4A   scale 13.50 }
		#end
		rotate -z*foo
		translate <Tx, Ty, 0>
		}
	torus { E, E*0.05
		scale <1, 2.4, 1> rotate x*90 
		#if ( rand(Rng1) < 0.5 )
		  texture { T_Planete_A }
		#else
		  texture { T_Planete_B }
		#end
		}
	#end   // end for
	}
// }
#end

// ------------------------------------------------------

#declare R_Tube = 0.17;
#local L_Tube = 0.54;

#macro Benz_Tubules ()
merge	{
	#local E = R_Tube * 0.75;
	#local R = 0.009;
	#for (foo, 0, 360, 30)
	  #local Tx = E * sin(radians(foo));
	  #local Ty = E * cos(radians(foo));
	  #local Dza = z * 0.25;
	  #local Dzb = z * 0.95;
	  cylinder { -Dza, Dzb, R  translate <Tx, Ty, 0> }
	  sphere { -Dza, R*1.8     translate <Tx, Ty, 0> }
	  sphere {  Dzb, R*1.8     translate <Tx, Ty, 0> }
	#end
	#if ( rand(Rng1) < 0.520)
	  texture { Orange_Glass }
	#else
	  texture { Yellow_Glass }
	#end
	}
#end

#macro Benz_Fuseau ()
difference {
	sphere { 0, R_Tube*0.39  }
	sphere { 0, R_Tube*0.37  }
	cylinder { <-1, 0, -1>, < 1, 0, 1>, R_Tube*0.21 } 
	cylinder { < 1, 0, -1>, <-1, 0, 1>, R_Tube*0.21 } 
	}
scale <1, 1, 4.4>
#if ( rand(Rng1) < 0.360)
  texture { Shadow_Clouds scale 0.56 }
#else
  texture { Flashy }
#end

#end     // end macro

#declare Benz_Fuseau_Flash = object
{
union	{
	object { Benz_Fuseau () }
	light_source { 0,
		rgb <rand(Rng2), rand(Rng2), rand(Rng2)>
		fade_distance	0.96
		fade_power	1.95
		}
	}
rotate -z*clock*8
}

//	-------------------------------------------

#local Forme_Cockpit = object
{
difference {
	sphere { 0, R_Tube*0.72 }
	sphere { 0, R_Tube*0.72 scale 0.99 }
	#for (Foo, 0, 359, 36)
	  cylinder { x, 0, R_Tube*0.15
				translate y*(R_Tube*0.32)
				rotate y*Foo }
	#end
	}
scale <1, 0.87, 1>
translate z*L_Tube*1.18
}

#declare Benz_Cylindre = object
{
#local E_tube = 0.02;
#local R_int  = R_Tube - E_tube;
difference	{
	union {
		cylinder { z*L_Tube*1.6, -z*L_Tube,  R_Tube }
		/* les deux bouts du cylindre creux */
		#local R2 = (R_Tube + R_int) / 2;
		torus { R2, E_tube scale <1, 4, 1>
				rotate x*90 translate  z*L_Tube*1.6 }
		torus { R2, E_tube scale <1, 4, 1>
				rotate x*90 translate -z*L_Tube  }

		/* cette sphere devrait devenir
		     un vrai cockpit ? */
		object { Forme_Cockpit
			translate y*R_Tube*0.97}
		}
	cylinder { z*4,      -z*4,   R_int }
	}
texture { Soft_Silver scale 6.0 }
}

#macro Benz_Tube ()
// #declare Benz_Tube = object
// {
union	{
	object { Benz_Tubules () }
	object { Benz_Fuseau_Flash translate z*0.40 }
	object { Benz_Cylindre }
	}
// }
#end

// ------------------------------------------------------

#macro HexaBenz ()
// #declare HexaBenz = object
// {
union	{
	#local Rk = (rand(Rng1)-0.5) * 1312;
	object { Benz_Cones () rotate z*NormClock*Rk}
	object { Benz_Tube () }
	}
// }
#end