// Grappe de 13 sphères autour d'une sphère centrale (mais de rayon plus grand)
// cf Pour La Science, n°427, mai 2013, La grappe de sphères collantes
// Le rayon de la sphère centrale est calculé dans le fichier 13spherec.mws.

#include "colors.inc"
#include "textures.inc"
#include "shapes.inc"
#include "stones.inc"
#include "woods.inc"                                                
#include "glass.inc"


// ***************************
// Installation de la caméra *
// ***************************
// On installe la caméra et on définit son orientation.
// L'axe des x est vers la droite, l'axe des y vers le haut, l'axe des z vers le fond.

#declare cl=clock/400;    // cl=clock/400; pour une animation de 400 images, clock variant de 1 à 400

camera {orthographic
#declare DistanceObservateur = 8;
#declare HauteurObservateur = 3;
#declare Angle = 2;  // < 0 pour l'oeil gauche (G.POV) . L'image devra être placée à DROITE en vision croisée
                     // > 0 pour l'oeil droit (D.POV) (en degré), l'image devra être placée à GAUCHE. 
                     // En général 3 à 5° degré d'écart entre les deux yeux. Angle est en degré. 

//Définir l'angle pour choisir l'oeil
location  <DistanceObservateur*cos(Angle/180*3.142), HauteurObservateur, DistanceObservateur*sin(Angle/180*3.142)> 



look_at  <0, 2, 0>

    
  }

// On définit le fond (par défaut noir)

background { color Black}  


// ********
// Objets *
// ********            

#declare a = 1.351995684;
#declare b = 2.675150356;
#declare c = 3.631563983;
#declare xx = 2.082639215;
#declare yy = 1.242029181;
#declare h = 1.540418538;
#declare r = 1.091145445;
#declare DistPlan = -1;

// *****************      
// Le plan de base *
// *****************

//#declare Floor_Texture =
//    texture { pigment { P_WoodGrain18A color_map { M_Wood18A }}}
//    texture { pigment { P_WoodGrain12A color_map { M_Wood18B }}}
//    texture {
//        pigment { P_WoodGrain12B color_map { M_Wood18B }}
//        finish { reflection 0.25 }
//    }

#declare Floor_Texture =
    texture { pigment { P_WoodGrain18A color_map { M_Wood18A }}}
    texture { pigment { P_WoodGrain12A color_map { M_Wood18B }}}
    texture {
        pigment { P_WoodGrain12B color_map { M_Wood18B }}
        finish { reflection 0.15 }
    }

union {    
sphere {
    <-1, 0, -1>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <-40, 10, 80>
    }}                                                          

sphere {
    <1, 0, -1>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <20, 30, 40>
    }}                                                          

sphere {
    <1, 0, 1>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <-40, 10, 80>
    }}                                                          

sphere {
    <-1, 0, 1>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <-40, 10, 80>
    }}                                                          
      
sphere {
    <-xx, a, 0>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <-30, 60, -10>
    }}                                                          

sphere {
    <0, a, -xx>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <-50, -10, 20>
    }}                

sphere {
    <xx, a, 0>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <-30, 60, -10>
    }}                                                          

sphere {
    <0, a, xx>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <-30, 60, -10>
    }}                                                          

sphere {
    <-yy, b, -yy>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <60, 50, -40>
    }}                                                          
                                          
sphere {
    <yy, b, -yy>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <40, -60, 20>
    }}                                                          

sphere {
    <yy, b, yy>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <60, 50, -40>
    }}                                                          
                                          
sphere {
    <-yy, b, yy>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <60, 50, -40>
    }}                                                          
                                          

sphere {
    <0, c, 0>, 1
    texture {
        T_Wood10
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <30, 50, -30>
    }}

sphere {<0,h,0>, r 
       texture {
        T_Wood6
        finish { specular 0.5 roughness 0.005 ambient 0.35 }
        rotate <45, 0, 20>
        }}

box {<-5,-1,-5> <5,-1.3,5>
    texture { Floor_Texture
        scale 0.25
        rotate <10, 0, 15>
        translate z*4
    }}  


rotate y*360*cl
rotate -z*80*sin(cl*pi)*sin(cl*pi)
translate <0,2*sin(cl*pi)*sin(cl*pi),0>          
}
   



// *********
// Lumière *
// *********

                
//light_source { <0, 10, 0> color White shadowless}
//light_source { <10, 0, 0> color White shadowless}
//light_source { <0, 0, -10> color White shadowless}
//light_source { <10, -10, -10> color White shadowless}

#declare Dist=80.0; // 80.0
#declare AutreDist=10; // 10
light_source {< -5*AutreDist, 2.5*AutreDist, -5*AutreDist> color White
     fade_distance Dist fade_power 2
     adaptive 1
}

light_source {< 10*AutreDist, 5*AutreDist,  -4> color White
     fade_distance Dist fade_power 2
     adaptive 1
}

light_source {< 0, 10*AutreDist,  0> color White
     fade_distance Dist fade_power 2
     adaptive 1
}


