// 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"
// macros for generating various shapes
// 
#include "shapes.inc"
#include "mrg_misc3.inc"

global_settings {
  assumed_gamma 1.0
  max_trace_level 15
  ambient_light color rgb .5

}
#declare lclock=clock+0;            //clock goes 0 to 18 for 360 frames
#declare t1=trans((lclock-1)/4);    //move in 1-5
#declare t2=ltrans((lclock-6)/3);   //split  6-9
#declare t3=ltrans((lclock-12)/1);   //unsplit  12-13
#declare t4=trans((lclock-13)/3);   //rise  13-16


// ----------------------------------------
#declare c1=<0.0,+ 0, -4.0>*40;
#declare c2=<0.0,+ 2, -4.0>*4;
#declare c3 = vrotate (c2, 50*x); 
#declare cpos=c1*(1-t1)+t1*vrotate (c2, 50*t4*x);

#declare sp_ang=.1+90*(t2-t3);
//#declare sp_rot=180-sp_ang/2;
#declare sp_rot=190-sp_ang;


camera {
  location  cpos
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
  angle 30
}
//light source at center
light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  //translate <-30, 30, -30>
}
//extrta light source for 3-d shape cues
light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>*.5  // light's color
  translate <0, 390, 10>
}
light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>*.5  // light's color
  translate <0, -390, 10>
}

// ----------------------------------------

#include "functions.inc"
#declare  S = function {f_torus(x,9*y,z,1.3,0.8)} //disk
#declare  T = function {f_torus(x,.6*y,z,.6,0.2)} //buldge
difference{
     isosurface {
       function { S(x,y,z) * T(x,y,z)-.05 }
             max_gradient 20.5
             accuracy 0.001
             contained_by{sphere{0,2.5}}
     }       
//     box{-15*(x+y),15} 

#declare cm_old=                     color_map {
                       [0.00 color rgb <.1,0.1,0.1> ]
                       [0.20 color rgb <50,50,50>/255 ]
                       [0.30 color rgb <75,75,75>/255 ] //255.204.51
                       [0.40 color rgb <150,100,100>/255 ] //255.204.51
                       [0.6 color rgb <150,175,125>/255 ]
                       [0.7 color rgb <150,150,255>/255 ]
                       [0.99 color rgb <1.0,1,1> ]
                       [1.00 color rgb <1.0,1,1>*2 ]
                     }
#declare cm=                     color_map {
                       [0.00 color rgb .3*<1,1,1> ]
                       [0.20 color rgb .05*Red+.5*<1,1,1> ]
                       [0.30 color rgb .2*Red+.7*<1,1,1> ] //255.204.51
                       [0.40 color rgb .5*Red+.1*Yellow+.4*<1,1,1> ] //255.204.51
                       [0.6 color rgb .3*Red+.3*Yellow+.3*<1,1,1> ]
                       [0.7 color rgb .5*Yellow+.5*<1,1,1> ]
                       [0.99 color rgb <1.0,1,1.5> ]
                       [1.00 color rgb <1.0,1,1>*2 ]
                     }

     object{Wedge( sp_ang) rotate (sp_rot)*y}
             pigment {
               //spherical
               cylindrical     
                     color_map {  cm
                     }
                 scale <1,.4,1>*2
            } 
     finish{ambient .9 diffuse .55 specular .75}
     no_shadow   no_reflection    
}           


//black hole
sphere{0,.1 pigment{Black} no_shadow no_reflection}

//inner haze
difference{
sphere{0,.5}
object{Wedge( sp_ang) rotate (sp_rot)*y}
 
     pigment { rgbt 1 } hollow
   interior
      { media
     { emission 1
       density
       { cylindrical density_map
         {
                       [0.00 color rgb <.1,0.1,0.1> ]
                       [0.20 color rgb <50,50,50>/255 ]
                       [0.30 color rgb <75,75,75>/255 ] //255.204.51
                       [0.40 color rgb <150,100,100>/255 ] //255.204.51
                       [0.6 color rgb <150,175,125>/255 ]
                       [0.7 color rgb <150,150,255>/255 ]
                       [1.00 color rgb <1.0,1,1>*2 ]
         }
         scale .4
       }
     }
   }

}


//dust torus

#declare  S2 = function {f_torus(x,1.4*y,z,3.5,0.5)} //disk
#declare  T2 = function {f_torus(x,.7*y,z,2.8,0.3)} //buldge
#declare R=3.8;
difference{
     isosurface {
            function { .5*S2(x,y,z) * T2(x,y,z)-.05 }
                  max_gradient 20.5
                  accuracy 0.001
                  contained_by{sphere{0,2*R}}
     }       
     object{Wedge( sp_ang) rotate (sp_rot)*y}
                  pigment {color rgb .055 } 
     finish{ambient .8 diffuse .45 specular .35}

}//jets
#declare vjet=20;

#declare ttube=cylinder{0,40*y,1 
     pigment { rgbt 1 } hollow
   interior
      { media
     { emission 1
       density
       { cylindrical density_map
         { [0 rgb 0]
           [0.25 rgb 0]
           [0.35 rgb <.25,.25,.5>]
           [0.5 rgb 0]
           [.65 rgb <.35,.35,.45>]
           [0.75 rgb 0]
           [1 rgb 0]
         }
         #declare ts=2;
         scale 1/ts
         turbulence 0.9+.1*sin(lclock*4*pi) 
         scale ts
       scale <1.0,2,1.0>
       translate y*lclock*vjet 
       }
     }
   }
   scale<1/3,1,1/3>
 }
  
#declare pc=0;
#declare pc_tot=100;
#if(t1>.75)
     #declare pc_tot =2;
#end

#declare pc_L=40;  
#declare dy=pc_L/pc_tot;
#while(pc<pc_tot)
     intersection{
          object{ttube}
          cylinder{.001*dy*y,dy*y,2
               pigment{color rgbt 1}  hollow
               translate pc*dy*y
          }
          scale (1+pc/pc_tot*4)*(x+z)+y  no_shadow   no_reflection  
     }
     #declare pc=pc+1;
#end

#declare btube=cylinder{0,-40*y,1 
     pigment { rgbt 1 } hollow
   interior
      { media
     { emission 1
       density
       { cylindrical density_map
         { [0 rgb 0]
           [0.25 rgb 0]
           [0.35 rgb <.25,.25,.5>]
           [0.5 rgb 0]
           [.65 rgb <.35,.35,.45>]
           [0.75 rgb 0]
           [1 rgb 0]
         }
         #declare ts=2;
         scale 1/ts
         turbulence 0.9+.1*sin(lclock*4*pi) 
         scale ts
       scale <1.0,2,1.0>
       translate -y*lclock*vjet-30*y 
       }
     }
   }
   scale<1/3,1,1/3>
 }
  
#declare pc=0;
#declare dy=-pc_L/pc_tot;
#while(pc<pc_tot)
     intersection{
          object{btube}
          cylinder{.001*dy*y,dy*y,2
               pigment{color rgbt 1}  hollow
               translate pc*dy*y
          }
          scale (1+pc/pc_tot*4)*(x+z)+y
     }
     #declare pc=pc+1;
#end
/**/