// POV-Ray 3.6 / 3.7 Scene File "Tube_Fork_000.pov"
// author: Friedrich A. Lohmueller, June-2009/Aug-2009/Jan-2011
// homepage: www.f-lohmueller.de
//--------------------------------------------------------------------------
#version 3.6; // 3.7;
global_settings{ assumed_gamma 1.0 }
#default{ finish{ ambient 0.1 diffuse 0.9 }} 
//------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
#include "glass.inc"
#include "metals.inc"
#include "golds.inc"
#include "stones.inc"
#include "woods.inc"
#include "shapes.inc"
#include "shapes2.inc"
#include "functions.inc"
#include "math.inc"
#include "transforms.inc"
//------------------------------------------------------------------------
#declare Camera_0 = camera {/*ultra_wide_angle*/ angle 35      // front view
                            location  <0.0 , 1.0 ,-10.0>
                            right     x*image_width/image_height
                            look_at   <0.0 , 1.0 , 0.0>}
#declare Camera_1 = camera {/*ultra_wide_angle*/ angle 15   // diagonal view
                            location  <20.0 , 20.0 ,-20.0>
                            right     x*image_width/image_height
                            look_at   < 0.00, 0.000,  0.00> }
#declare Camera_2 = camera {/*ultra_wide_angle*/ angle 39  //right side view
                            location  < 3.50, 5.00,-4.00>
                            right     x*image_width/image_height
                            look_at   < 0.00, 0.000,  0.00> }
#declare Camera_3 = camera {/*ultra_wide_angle*/ angle 90        // top view
                            location  <0.0 , 3.0 ,-0.001>
                            right     x*image_width/image_height
                            look_at   <0.0 , 1.0 , 0.0>}
camera{Camera_2}
//------------------------------------------------------------------------
// sun -------------------------------------------------------------------
light_source{<500,1500,-2500> color White*0.9}           // sun light
// sky -------------------------------------------------------------------
sky_sphere{ pigment{ gradient <0,1,0>
                     color_map{ [0   color rgb<1,1,1>         ]//White
                                [0.4 color rgb<0.14,0.14,0.56>]//~Navy
                                [0.6 color rgb<0.14,0.14,0.56>]//~Navy
                                [1.0 color rgb<1,1,1>         ]//White
                              }
                     scale 2 }
           } // end of sky_sphere 
//------------------------------------------------------------------------

//------------------------------ the Axes --------------------------------
//------------------------------------------------------------------------
#macro Axis_( AxisLen, Dark_Texture,Light_Texture) 
 union{
    cylinder { <0,-AxisLen,0>,<0,AxisLen,0>,0.05
               texture{checker texture{Dark_Texture } 
                               texture{Light_Texture}
                       translate<0.1,0,0.1>}
             }
    cone{<0,AxisLen,0>,0.2,<0,AxisLen+0.7,0>,0
          texture{Dark_Texture}
         }
     } // end of union                   
#end // of macro "Axis()"
//------------------------------------------------------------------------
#macro AxisXYZ( AxisLenX, AxisLenY, AxisLenZ, Tex_Dark, Tex_Light)
//--------------------- drawing of 3 Axes --------------------------------
union{
#if (AxisLenX != 0)
 object { Axis_(AxisLenX, Tex_Dark, Tex_Light)   rotate< 0,0,-90>}// x-Axis
 text   { ttf "arial.ttf",  "x",  0.15,  0  texture{Tex_Dark} 
          scale 0.5 translate <AxisLenX+0.05,0.4,-0.10>}
#end // of #if 
#if (AxisLenY != 0)
 object { Axis_(AxisLenY, Tex_Dark, Tex_Light)   rotate< 0,0,  0>}// y-Axis
 text   { ttf "arial.ttf",  "y",  0.15,  0  texture{Tex_Dark}    
           scale 0.5 translate <-0.75,AxisLenY+0.50,-0.10>}
#end // of #if 
#if (AxisLenZ != 0)
 object { Axis_(AxisLenZ, Tex_Dark, Tex_Light)   rotate<90,0,  0>}// z-Axis
 text   { ttf "arial.ttf",  "z",  0.15,  0  texture{Tex_Dark}
               scale 0.5 translate <-0.75,0.2,AxisLenZ+0.10>}
#end // of #if 
} // end of union
#end// of macro "AxisXYZ( ... )"
//------------------------------------------------------------------------

#declare Texture_A_Dark  = texture {
                               pigment{ color rgb<1,0.45,0>}
                               finish { phong 1}
                             }
#declare Texture_A_Light = texture { 
                               pigment{ color rgb<1,1,1>}
                               finish { phong 1}
                             }

object{ AxisXYZ( 4.2, 3.0, 6, Texture_A_Dark, Texture_A_Light) scale 0.5   no_shadow}
//-------------------------------------------------- end of coordinate axes


// ground -----------------------------------------------------------------
//---------------------------------<<< settings of squared plane dimensions
#declare RasterScale = 0.5;
#declare RasterHalfLine  = 0.025;
#declare RasterHalfLineZ = 0.025;
//-------------------------------------------------------------------------
#macro Raster(RScale, HLine) 
       pigment{ gradient x scale RScale
                color_map{[0.000   color rgbt<1,1,1,0>*0.6]
                          [0+HLine color rgbt<1,1,1,0>*0.6]
                          [0+HLine color rgbt<1,1,1,1>]
                          [1-HLine color rgbt<1,1,1,1>]
                          [1-HLine color rgbt<1,1,1,0>*0.6]
                          [1.000   color rgbt<1,1,1,0>*0.6]} }
 #end// of Raster(RScale, HLine)-macro    
//-------------------------------------------------------------------------
    
plane { <0,1,0>, 0    // plane with layered textures
        texture { Raster(RasterScale,RasterHalfLine ) rotate<0,0,0> }
        texture { Raster(RasterScale,RasterHalfLineZ) rotate<0,90,0>}
        no_shadow
      }
plane { <0,1,0>, 0    // plane with layered textures
        texture { pigment{color White*1.1}
                  finish {ambient 0.45 diffuse 0.85}}
        translate<0,-1,0>
      }
//------------------------------------------------ end of squared plane XZ

//--------------------------------------------------------------------------
//---------------------------- objects in scene ----------------------------
//--------------------------------------------------------------------------

//--------------------------------------------------------------------------
#macro Tube_Fork_000 ( R1, // ~0.50
                       R2, // ~0.35 ~0.65
                       Tube_D, // ~0.05; // tube material thickness 
                       Bloby, // Blobfactor, // 0.1~0.002  
                       Cor, //   radius correction
                       Test_Cylinders_ON, // on = 1; off = 0
                       ) // ------------------------------------------------
//--------------------------------------------------------------------------
#local D = 0.0001; // just a little bit !!!
#local Box_L = 4*R1; 
//--------------------------------------------------------------------------
//---------------------------------------------- default textures ----------
#ifndef (Slide_Body_Texture)
#declare Slide_Body_Texture = 
  texture{ pigment{ color rgb<1,1,1>*0.85}
           normal { bumps 0.05 scale 0.3005} 
           finish { phong 0.7 reflection 0.05}}
#end
#ifndef (Slide_Inside_Texture)
#declare Slide_Inside_Texture = 
  texture{ pigment{ color rgb<1,1,1>*0.7}}

#end
#ifndef (Test_Tube_Texture)
#declare Test_Tube_Texture = 
           texture { pigment { color rgb<0.7,0.3,1>}} 
                    
#end
//--------------------------------------------------------------------------
//------------------------------------------------------- main part --------
union{ // main union  
 
#if(Test_Cylinders_ON=1) 
union{ // 1
#end

difference{ 
 union{  
 isosurface { //-------------------------------------------------------------
  function { (1+Bloby)
              - pow( Bloby, ( sqrt(x*x+y*y)-(R1+Cor) ) )
              - pow( Bloby,( sqrt( y*y+z*z)-(R2+Cor) ) )
  }
  contained_by { box {  <0,-Box_L,-Box_L>, <Box_L,Box_L,Box_L>} }
  accuracy 0.001
  max_gradient 7
 } // end of isosurface ----------------------------------------------------- 
 
 isosurface { //-------------------------------------------------------------
  function { (1+Bloby)
              - pow( Bloby, ( sqrt(x*x+y*y)-(R1+Cor) ) )
              - pow( Bloby,( sqrt(y*y+z*z +x*x)-(R2+Cor) ) )
  }
  contained_by { box { <-Box_L,-Box_L,-Box_L>, <0,Box_L,Box_L> } }
  accuracy 0.001
  max_gradient 7
 } // end of isosurface ----------------------------------------------------- 
 
 texture{Slide_Body_Texture}
 }// end of union
 
 cylinder { <0,0,-Box_L-D>,<      0,0,Box_L+D>, R1-Tube_D texture{ Slide_Inside_Texture }}
 cylinder { <0,0,       0>,<Box_L+D,0,      0>, R2-Tube_D texture{ Slide_Inside_Texture }}
}//end of difference  //

#if(Test_Cylinders_ON=1)
 union{ // 'test'
   cylinder { <    0,0, Box_L       >,<           0,0,Box_L+0.5*R1>, R1} 
   cylinder { <    0,0,-Box_L-0.5*R1>,<           0,0,-Box_L      >, R1} 
   cylinder { <Box_L,0,            0>,<Box_L+0.5*R1,0,           0>, R2} 
   texture { Test_Tube_Texture }} 
 }// end union 'test'
} // end union of '#if(Test_Cylinders_ON = 1)'
#end // Test_Cylinders_ON=1
// ---------

} // end union main  
#end // --------------------------------------------------- end of macro
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------



// ---------------------------------------------------------------------------
// ------------------------------------------------ optional textures 
#declare Slide_Body_Texture = 
  texture{ pigment{ color rgb<0.75,1,0>*1}
           finish { phong 1 reflection 0.10}}
#declare Slide_Inside_Texture = 
  texture{ pigment{ color rgb<0.3,0.7,0>*1.1}
           finish { phong 1}}
#declare Test_Tube_Texture = 
           texture { pigment { color rgb<1,0.7,0>}
                   //normal  { bumps 0.5 scale <0.25, 0.005,0.005>}  
                     finish  {  phong 0.5 reflection 0.00 }
                   } // end of texture

// ---------------------------------------------------------------------------
object{ Tube_Fork_000 ( // total container box length = 4*R1 
                          0.50, // R1, // main tube radius:  1 ~ 0.25
                          0.35, // R2, // side tube radius:  1.5 ~ 0.20
                          0.05, // Tube_D, // tube material thickness 
                          0.15, // Blobfactor; // 0.1~0.002 ; maximum ~ 0.20 !! 
                          0.06, // radius correction, ~ 0.06
                          0, // Test_cylinders_ON;  on = 1; off = 0
                        ) // -------------------------------------------------
      // rotate <0,0,90>
         translate <0,0,0>
      } // -------------------------------------------------------------------
// ---------------------------------------------------------------------------
      
      
