// Persistence of Vision Ray Tracer Scene Description File
// File: ?.pov
// Vers: 3.5
// Desc: Basic Scene Example
// Date: mm/dd/yy
// Auth: ?
//

#version 3.5;

#include "colors.inc"
#include "body.inc"
#include "mrg_misc2.inc"
// some standard finishes
#include "finish.inc" 

global_settings {
  assumed_gamma 1.0
  ambient_light color rgb <.5,.5,.5> 
  max_trace_level 8
}
camera {
  location  <1, .5, .7>*120
    //   location (3*z+2*y)*4
  direction 1.5*z
  right     x*image_width/image_height
  look_at   0
}
#declare cel_sphr_rad=40;
#declare stars=union{
     #declare num=0;
     #declare ra=0;
     #declare dec=0;
     #declare mag=0;
     #declare vpara=0;
     #declare con="aaa";
     #fopen MyFile "decimal_bsc5.csv" read
     #read (MyFile,num,ra,dec,mag,vpara,con)
     #declare star_origin=cel_sphr_rad*(z);
     #declare altitude_axis=vcross(star_origin,y);
     #declare altitude_axis=altitude_axis/vlength(altitude_axis);
     #while (mag<5)
          sphere { star_origin, 0.008*(1-mag/8)*cel_sphr_rad
               texture{
                    pigment{color rgb 2*sqrt(1-mag/8)}
                    finish{Luminous}
               }
               rotate altitude_axis*dec //rotate towards y for "altitude" like declination
               rotate -y*ra //right ascension in a left handed coord system...
                
          }
          #read (MyFile,num,ra,dec,mag,vpara,con)
          

     #end
     #fclose MyFile

     #declare ra=0;
     #declare dec=0;
     #declare pen=0;
     #declare con="aaa";
     #declare cline_rad=0.0075*.35*cel_sphr_rad;
     #fopen MyFile2 "pattern.star.csv" read
     #read (MyFile2,ra,dec,pen,con)
     #while (pen<=1)  //fake last lines  with pen =3
           #declare cline_start=vrotate(vrotate(star_origin,altitude_axis*dec),-y*ra);
          #read (MyFile2,ra,dec,pen,con)
          #declare rflag=ra;
   
          #declare cline_end=vrotate(vrotate(star_origin,altitude_axis*dec),-y*ra);

          #if (pen=1)
               difference{
                    cylinder{cline_start,cline_end,cline_rad
                    }
                    union{
                         sphere{cline_start,2*cline_rad}
                         sphere{cline_end,2*cline_rad}
                    }
                    pigment{color rgb <.9,.0,.0>}
                    finish{ambient 1 diffuse 0}
              }       
          #end
          #declare cline_start=cline_end;
     #end
     #fclose MyFile2
   
      //CELESTIAL SPHERE lines
     #declare mycount=0;
     #while (mycount < 4)
          torus { cel_sphr_rad*1.001, cline_rad*.75
               pigment{color rgb <.9,.7,.0>}
               finish{ambient 1 diffuse 0}
               rotate x*90
               rotate y*mycount*45
          }     

         #declare mycount=mycount+1;
     #end
     #declare lmax=4;
     #declare mycount=-lmax;
     #while (mycount <= lmax)
          #declare tr= cos(radians(mycount/(lmax+1)*90))*cel_sphr_rad*1.001;
          #declare ty= sin(radians(mycount/(lmax+1)*90))*cel_sphr_rad*1.001;
          torus { tr, cline_rad*.75
               pigment{color rgb <.9,.7,0>}
               finish{ambient 1 diffuse 0}
               translate y*ty
          }     

         #declare mycount=mycount+1;
     #end 
     cylinder{  -y,y,cline_rad pigment {Green} finish{Luminous} scale <1, cel_sphr_rad*1.2,1>}
 /*    
     //Ecliptic
     torus { cel_sphr_rad, cline_rad
          rotate altitude_axis*23 //rotate towards y for "altitude" like declination
          
          pigment{color rgb <.0,.7,.5>}
          finish{ambient 1 diffuse 0}
     }     
  
 */         
};
#declare lat=45;
#declare hour=90*2.8;
object { stars rotate y*hour rotate x*lat}               

#declare pointer=prism {
         linear_sweep
         linear_spline
         0, // sweep the following shape from here ...
         .1, // ... up through here
         4, // the number of points making up the shape ...
         <-1,0>, <1,0>, <0,5>, <-1,0>
         pigment { Green }
}
#declare subpointer=prism {
         linear_sweep
         linear_spline
         0, // sweep the following shape from here ...
         .099, // ... up through here
         4, // the number of points making up the shape ...
         <-.75,0>, <.751,0>, <0,4>, <-.75,0>
         pigment { Red*2 }
}
union{
     object{pointer}
     object{pointer rotate y*90}
     object{pointer rotate y*-90}
     object{pointer rotate y*180}
     object{subpointer rotate y*45}
     object{subpointer rotate y*135}
     object{subpointer rotate y*-45}
     object{subpointer rotate y*-135}
     cylinder{0,.101*y,1.4
       texture {
                    pigment{color rgb <.2,.2,.2>}
                    finish{ambient .5 diffuse .5}
       }
     }
     #declare text_texture=texture{
                    pigment{color rgb 5*<.1,.1,.1>}
                    finish{ambient .9 diffuse .15}
     }
     text {
       ttf
       "times.ttf", "N", .02, 0   
          rotate x*90 translate y*.102-x*.35+z*5.2
       texture {text_texture}
     }
     text {
       ttf
       "times.ttf", "S", .02, 0   
          rotate x*90 translate y*.102-x*.35+z*5.2 rotate y*180
       texture {text_texture }
     }
     text {
       ttf
       "times.ttf", "E", .02, 0   
          rotate x*90 translate y*.102-x*.35+z*5.2 rotate y*90
       texture {text_texture }
     }
     text {
       ttf
       "times.ttf", "W", .02, 0   
          rotate x*90 translate y*.102-x*.35+z*5.2 rotate y*-90
       texture { text_texture }
     }
     scale 5
}     


#declare LandArea = texture {
 pigment {  Brown }  
}
#declare OceanArea = texture {
 pigment {
   bozo
   turbulence .2
   lambda 1
    color_map {
     [0.00, 0.5 color rgb <0, 0, 1>
                 color rgb <0, 0, 1>]
     [0.5, 0.75 color rgbf <1, 1, 1, 1>
                 color rgbf <1, 1, 1, 1>]
     [0.75, 1.00 color rgb <0, 0, 1>
                 color rgb <0, 0, 1>]
   }
 }
}

cylinder {
  0.0, -.2*y, cel_sphr_rad*.98
    texture { LandArea scale 14}
    texture { OceanArea scale 15 translate x*20+z*5}
    /* texture {
               pigment{color rgb <.0,.0,.3>}
               finish{ambient .35 diffuse .25}
     }*/
}


#declare BT=texture{T_Gold_1A};
#declare body=union{
     object{torso texture{BT}}
     object{leg texture{BT} translate -(hipw-hipb)/2*x-hipb/2*y}
     object{leg texture{BT} translate +(hipw-hipb)/2*x-hipb/2*y }
     object{Rarm texture{BT} rotate x*90 rotate z*-10 translate -(shoulderw-.0*shoulderb)/2*x+torsoh*y }
     object{Larm texture{BT} rotate z*10 translate (shoulderw-.0*shoulderb)/2*x+torsoh*y }
     object{ head translate y*(torsoh+shoulderh)}
translate (thighlen+calflen+ankleb)*y
}

object{body translate y*.145 rotate y*180 scale 7}