File talk:CRT color.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

POV-ray source code for Image:CRT color.png


 /*
 ================================================
 Cathode Ray Tube with cut-away for a peek inside
 ------------------------------------------------
 Created by Søren Peo Pedersen - see my user page
 at http://da.wikipedia.org/wiki/Bruger:Peo
 ================================================
 */
 
 #include "functions.inc"
 
 global_settings {
 max_trace_level 256
 max_intersections 128
 }
 
 #declare ColorCRT = yes;  // Use yes for color CRT, no for monochrome
 #declare Scope = no;      // Use yes for oscilloscope-type CRT, no for television-type CRT
                           // Oscilloscope-type MUST use ColorCRT = no
 #declare SeeScreen = yes; // Use yes for a close-up on the inside of the screen, no for general view
 
 
 #declare Copper=texture {           // Copper texture for coils
     pigment {color rgb<.5,.3,.2>}
     finish {
         phong yes
         phong_size 150
         reflection rgb<.5,.3,.2>
         metallic
         ambient .5
         }
     }
 
 #declare Iron=texture {             // Iron texture for coil yoke
     pigment {color rgb .2}
     finish {
         ambient .5
         reflection .3
         phong 1
         }
     }
 
 #declare ElectrodeMetal=texture {   // Metal texture for electron gun and other components
     pigment {color rgb .3}
     finish {
         ambient .5
         reflection .8
         phong 1
         phong_size 120
         }
     }
 
 #declare ScreenMetal=texture {          // Metal texture for the metal raster mask behind screen
     pigment {color rgbt <.3,.3,.3,.2>}
     finish {
         ambient .5
         reflection .8
         phong 1
         phong_size 120
         }
     }
 
 #declare ConnectorPinMetal=merge {      // Metal texture used on connector pins at rear
     cylinder {<-6,.5,0>,<-5.6,.5,0>,.07}
     sphere {<-6,.5,0>,.07}
     texture {ElectrodeMetal}
     }
 
 #declare EntireTube = difference {      // Shape of the entire CRT body, without cut-away
             merge {
                 
                 
                 // OUTSIDE SHAPE:
                 difference {    // The spherical front
                     sphere {0,10}
                     plane {<0,-1, 0>,0 rotate <0,  0, 20>}
                     plane {<0, 1, 0>,0 rotate <0,  0,-20>}
                     plane {<0, 0, 1>,0 rotate <0, 25,  0>}
                     plane {<0, 0,-1>,0 rotate <0,-25,  0>}
                     }
                     
                 difference {    // Rounded top edge of the front
                     torus {9.5,.5 rotate <0,0,20>}
                     plane {<0, 0, 1>,0 rotate <0, 25,  0>}
                     plane {<0, 0,-1>,0 rotate <0,-25,  0>}
                     }
     
                 difference {    // Rounded bottom edge of the front
                     torus {9.5,.5 rotate <0,0,-20>}
                     plane {<0, 0, 1>,0 rotate <0, 25,  0>}
                     plane {<0, 0,-1>,0 rotate <0,-25,  0>}
                     }
     
                 difference {    // Rounded right-hand edge of the front
                     torus {9.5,.5 rotate <90,-25,0>}
                     plane {<0,-1, 0>,0 rotate <0,  0, 20>}
                     plane {<0, 1, 0>,0 rotate <0,  0,-20>}
                     }
     
                 difference {    // Rounded left-hand edge of the front
                     torus {9.5,.5 rotate <90, 25,0>}
                     plane {<0,-1, 0>,0 rotate <0,  0, 20>}
                     plane {<0, 1, 0>,0 rotate <0,  0,-20>}
                     }
                 
                 // Spherically rounded corners of the front
                 sphere {<8.176549037, 2.976020469,-3.812787433>,.5}
                 sphere {<8.176549037, 2.976020469, 3.812787433>,.5}
                 sphere {<8.176549037,-2.976020469,-3.812787433>,.5}
                 sphere {<8.176549037,-2.976020469, 3.812787433>,.5}
                 
                 // Rounded edges between the four "sides" of the "funnel" part of the CRT
                 cylinder {0,<8.176549037, 2.976020469,-3.812787433>,.5}
                 cylinder {0,<8.176549037, 2.976020469, 3.812787433>,.5}
                 cylinder {0,<8.176549037,-2.976020469,-3.812787433>,.5}
                 cylinder {0,<8.176549037,-2.976020469, 3.812787433>,.5}
                 
                 
                 difference {    // Top and bottom sides of the "funnel"
                     sphere {0,9.5}
                     plane {<0,-1,0>,-.5 rotate <0,0,20>}
                     plane {<0, 1,0>,-.5 rotate <0,0,-20>}
                     plane {<0,0, 1>,0 rotate <0, 25,0>}
                     plane {<0,0,-1>,0 rotate <0,-25,0>}
                     }
     
                 difference {    // Left- and right-hand sides of the "funnel"
                     sphere {0,9.5}
                     plane {<0,0, 1>,-.5 rotate <0, 25,0>}
                     plane {<0,0,-1>,-.5 rotate <0,-25,0>}
                     plane {<0,-1,0>,0 rotate <0,0, 20>}
                     plane {<0, 1,0>,0 rotate <0,0,-20>}
                     }
                 
                 cylinder {<-4.5,0,0>,<5,0,0>,1.5}   // Cylindrical "neck" of the CRT
                 #if (Scope)   // If it is to be the "oscilloscope-type" CRT...:
                     sphere {<.5,1.4,0>,.3}    // Create spherical "nodes" where
                     sphere {<.5,-1.4,0>,.3}   // the voltage deflection electrodes
                     sphere {<.5,0,1.4>,.3}    // enter the CRT
                     sphere {<.5,0,-1.4>,.3}
                 #end
                 torus {1,.5 rotate <0,0,90> translate <-4.5,0,0>}
                 cylinder {<-4.5,0,0>,<-5,0,0>,1}
                 }
 
                 
                 
                 // SHAPE OF INSIDE CAVITY:
                 difference {    // The spherical front
                     sphere {0,9.3}
                     plane {<0,-1, 0>,0 rotate <0,  0, 20>}
                     plane {<0, 1, 0>,0 rotate <0,  0,-20>}
                     plane {<0, 0, 1>,0 rotate <0, 25,  0>}
                     plane {<0, 0,-1>,0 rotate <0,-25,  0>}
                     }
                 
                 difference {    // Rounded top edge of the front
                     torus {9,.3 rotate <0,0,20>}
                     plane {<0, 0, 1>,0 rotate <0, 25,  0>}
                     plane {<0, 0,-1>,0 rotate <0,-25,  0>}
                     }
     
                 difference {    // Rounded bottom edge of the front
                     torus {9,.3 rotate <0,0,-20>}
                     plane {<0, 0, 1>,0 rotate <0, 25,  0>}
                     plane {<0, 0,-1>,0 rotate <0,-25,  0>}
                     }
     
                 difference {    // Rounded right-hand edge of the front
                     torus {9,.3 rotate <90,-25,0>}
                     plane {<0,-1, 0>,0 rotate <0,  0, 20>}
                     plane {<0, 1, 0>,0 rotate <0,  0,-20>}
                     }
     
                 difference {    // Rounded left-hand edge of the front
                     torus {9,.3 rotate <90, 25,0>}
                     plane {<0,-1, 0>,0 rotate <0,  0, 20>}
                     plane {<0, 1, 0>,0 rotate <0,  0,-20>}
                     }
 
 
                 // Spherically rounded corners of the front
                 sphere {<7.746204351, 2.819387812,-3.612114411>,.3}
                 sphere {<7.746204351, 2.819387812, 3.612114411>,.3}
                 sphere {<7.746204351,-2.819387812,-3.612114411>,.3}
                 sphere {<7.746204351,-2.819387812, 3.612114411>,.3}
                 
                 // Rounded edges between the four "sides" of the "funnel" part of the CRT
                 cylinder {0,<7.746204351, 2.819387812,-3.612114411>,.3}
                 cylinder {0,<7.746204351, 2.819387812, 3.612114411>,.3}
                 cylinder {0,<7.746204351,-2.819387812,-3.612114411>,.3}
                 cylinder {0,<7.746204351,-2.819387812, 3.612114411>,.3}
                 
 
                 difference {    // Top and bottom sides of the "funnel"
                     sphere {0,9}
                     plane {<0,-1,0>,-.3 rotate <0,0,20>}
                     plane {<0, 1,0>,-.3 rotate <0,0,-20>}
                     plane {<0,0, 1>,0 rotate <0, 25,0>}
                     plane {<0,0,-1>,0 rotate <0,-25,0>}
                     }
     
                 difference {    // Left- and right-hand sides of the "funnel"
                     sphere {0,9}
                     plane {<0,0, 1>,-.3 rotate <0, 25,0>}
                     plane {<0,0,-1>,-.3 rotate <0,-25,0>}
                     plane {<0,-1,0>,0 rotate <0,0, 20>}
                     plane {<0, 1,0>,0 rotate <0,0,-20>}
                     }
                 
                 
                 #if (Scope)
                 difference {
                 #end
                     cylinder {<-4.5,0,0>,<6,0,0>,1.3}
                     #if (Scope)   // If it is to be the "oscilloscope-type" CRT...:
                       sphere {<.5,1.4,0>,.3}    // Create spherical "nodes" where
                       sphere {<.5,-1.4,0>,.3}   // the voltage deflection electrodes
                       sphere {<.5,0,1.4>,.3}    // enter the CRT
                       sphere {<.5,0,-1.4>,.3}
                     }
                     #end
                 torus {1,.3 rotate <0,0,90> translate <-4.5,0,0>}
                 cylinder {<-4,0,0>,<-4.8,0,0>,1}
                 cylinder {<-1,0,0>,<-8,0,0>,.7}
                         
                 
                 }
 
 
 
 #macro PhosporLevel(Level)    // Phosphor texture "glowing" at the given "Level" 
     #if (ColorCRT)
         pigment {   // Hexagonal red-green-blue pattern for use in color CRT
             hexagon rgb<1,0,0> rgb<0,1,0> rgb<0,0,1>
             rotate <0,0,90> translate <0,-.4,0> scale .003333
             }
          finish {ambient .8*Level+.2 diffuse (1-Level)*.6}
     #else
         pigment {color rgb<   // Monochrome (pale bluish for scope, warm "white" for black/white TV)
             #if (Scope)
                 .4+Level*.4,.5+Level*.5,.6+Level*.2
             #else
                 .9+Level*.1,.85+Level*.15,.75+Level*.25
             #end
             >}
         finish {ambient .5+Level/2 diffuse (1-Level)*.6}
     #end
 #end
 
 #local PhosporStripes=texture {   // Phosphor with some pattern on it
         #if (Scope)   // For oscilloscope-type CRT; a sine-wave curve:
             function {pow(600,-abs(y+1.75*cos(4*z)))*pow(1.2,z)}
             texture_map {
                 [0 PhosporLevel(0)]
                 [1 PhosporLevel(1)]
                 }
             }
         #else   // For TV-type CRTs: "Stripes" resembling the raster scan pattern used in a TV:
             radial
             texture_map {
                 [0.00 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.03 PhosporLevel(.1073741824) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.06 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.09 PhosporLevel(.134217728) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.12 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.15 PhosporLevel(.16777216) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.18 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.21 PhosporLevel(.2097152) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.24 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.27 PhosporLevel(.262144) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.30 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.33 PhosporLevel(.32768) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.36 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.39 PhosporLevel(.4096) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.42 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.45 PhosporLevel(.512) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.48 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.51 PhosporLevel(0.64) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.54 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.57 PhosporLevel(0.8) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.60 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.63 PhosporLevel(1) rotate <0,0,-21.5> rotate <90,0,0>]
                 [0.66 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 [1.00 PhosporLevel(0) rotate <0,0,-21.5> rotate <90,0,0>]
                 }
             frequency 7
             scale 5
             rotate <-90,0,21.5>
             }
         #end
         
 #local PhosporTexture=texture { // Texture for the entire CRT; partly glass, partly phospor pattern
     object {
         difference {
             sphere {0,9.35}
             plane {<0,-1, 0>,-.301 rotate <0,  0, 20>}
             plane {<0, 1, 0>,-.301 rotate <0,  0,-20>}
             plane {<0, 0, 1>,-.301 rotate <0, 25,  0>}
             plane {<0, 0,-1>,-.301 rotate <0,-25,  0>}
             }
         
         texture {pigment {color rgbf <.65,.75,.7,.9>} finish {ambient .5}}
         texture {
             object {
                 box {<0,-10,0>,<20, #if (Scope) 10 #else .27 #end ,10> rotate <0,0,-11>}
                 texture {PhosporStripes}
                 texture {
                     cylindrical
                     texture_map {
                         [0 PhosporLevel(0) scale .5 rotate <0,0,-79>]
                         [.975 PhosporLevel(0) scale .5 rotate <0,0,-79>]
                         [1 PhosporLevel(1) scale .5 rotate <0,0,-79>]
                         }
                     scale 10
                     rotate <0,0,79>
                     }
                 }
             }
         }
     }   
 
 #macro DeflCoilWinding(Radius,Level)  // One winding of a deflection coil at given radius and level
     #local Qtorus=intersection {
         torus {Radius,.05}
         box {<0,-1,0>,<10,1,10>}
         }
     
     merge {
         #object {Qtorus                 translate < .7,1.55+Level,0> rotate < 25,0,0>}
         #object {Qtorus scale <-1,1, 1> translate <-.7,1.55+Level,0> rotate < 25,0,0>}
         #object {Qtorus scale < 1,1,-1> translate < .7,1.55+Level,0> rotate <-25,0,0>}
         #object {Qtorus scale <-1,1,-1> translate <-.7,1.55+Level,0> rotate <-25,0,0>}
         
         cylinder {<-.7,1.55+Level, Radius>,<.7,1.55+Level, Radius>,.05 rotate < 25,0,0>}
         cylinder {<-.7,1.55+Level,-Radius>,<.7,1.55+Level,-Radius>,.05 rotate <-25,0,0>}
         difference {
             merge {
                 torus {1.55+Level,.05 rotate <0,0,90> translate <-.7-Radius,0,0>}
                 torus {1.55+Level,.05 rotate <0,0,90> translate < .7+Radius,0,0>}                
                 }
             plane {<0,1,0>,0 rotate < 65,0,0>}
             plane {<0,1,0>,0 rotate <-65,0,0>}
             }
         
         }
 #end                
 
 
 #declare DeflCoil=merge {   // One of four deflection coils
     #object {DeflCoilWinding(.1,0)}
     #object {DeflCoilWinding(.2,0)}
     #object {DeflCoilWinding(.3,0)}
     #object {DeflCoilWinding(.4,0)}
     #object {DeflCoilWinding(.4,.1)}
     #object {DeflCoilWinding(.4,.2)}
     #object {DeflCoilWinding(.4,.3)}
     #object {DeflCoilWinding(.3,.3)}
     #object {DeflCoilWinding(.2,.3)}
     #object {DeflCoilWinding(.1,.3)}
     #object {DeflCoilWinding(.1,.2)}
     #object {DeflCoilWinding(.1,.1)}
     translate <.5,0,0>
     texture {Copper}
     }
 
 
 difference {  // The CRT body with its textures applied
     #object {EntireTube
         texture {
             object {
                 merge {
                     difference {
                         sphere {0,9}
                         plane {<0,-1, 0>,-.301 rotate <0,  0, 20>}
                         plane {<0, 1, 0>,-.301 rotate <0,  0,-20>}
                         plane {<0, 0, 1>,-.301 rotate <0, 25,  0>}
                         plane {<0, 0,-1>,-.301 rotate <0,-25,  0>}
                         }
                     difference {
                         cylinder {<-3,0,0>,<4,0,0>,1.4}
                         cylinder {<-4,0,0>,<5,0,0>,1.299}
                         }
                     }
                 texture {PhosporTexture}
                 texture {pigment {color rgb .4} finish {ambient .5}}
                 }
             }
         interior {ior 1.5}
         }            
 
     box {<-10,0,-10>,<7.5,10,0>
         pigment {color rgb <1,0,0>}
         finish {ambient .7}
         }
     }
 
 #declare DeflElectrode=merge {    // Oscilloscope-type deflection electrode
     box {<-.5,.95,-.5>,<.5,1.05,.5>}
     cylinder {<0,1,0>,<0,3,0>,.05}
     texture {ElectrodeMetal}
     translate <.5,0,0>
     }
 
 
 #if (SeeScreen=no)  // If not rendering close-up of the screen itself...:
     #if (Scope) // For the oscilloscope-type CRT...:
         #object {DeflElectrode}                   // Use four of the above-
         #object {DeflElectrode rotate <90,0,0>}   // declared voltage
         #object {DeflElectrode rotate <180,0,0>}  // deflection electrodes
         #object {DeflElectrode rotate <270,0,0>}
     #else       // For the TV-type CRT...:
         #object {DeflCoil}                        // Use four of the above-
         #object {DeflCoil rotate <90,0,0>}        // declared deflection
         #object {DeflCoil rotate <180,0,0>}       // coil assemblies
         #object {DeflCoil rotate <270,0,0>}
     #end
         
         difference {    // Yoke for focusing coil
             merge {
                 difference {
                     cylinder {<-1.4,0,0>,<-1.2,0,0>,3}
                     cylinder {0,<-5,0,0>,1.6}
                     }
                 difference {
                     cylinder {<-1.6,0,0>,<-2.0,0,0>,1.8}
                     cylinder {0,<-5,0,0>,1.6}
                     }
                 difference {
                     cylinder {<-2.2,0,0>,<-2.0,0,0>,3}
                     cylinder {0,<-5,0,0>,1.6}
                     }
                 difference {
                     cylinder {<-1.4,0,0>,<-2.0,0,0>,3}
                     cylinder {0,<-5,0,0>,2.8}
                     }
                 texture {Iron}
                 }
             box {<-5,0,-10>,<0,10,0>
                 pigment {color rgb <1,0,0>}
                 finish {ambient .5}
                 }
             }
         
         difference {    // Windings on the focusing coil
             merge {
                 #local Layer=1.85;
                 #while (Layer<2.8)
                     #local Winding=-1.95;
                     #while (Winding<-1.4)
                         torus {Layer,0.05 rotate <0,0,90> translate <Winding,0,0>}
                         #local Winding=Winding+.1;
                     #end
                     #local Layer=Layer+.1;
                 #end
                 texture {Copper}
                 }
             intersection {
                 box {<-5,-5,-5>,<0,0,0> rotate <60,0,0>}
                 box {<-5,0,0>,<0,5,5> rotate <-90,0,0>}
                 pigment {color rgb <1,0,0>}
                 finish {ambient .5}
                 }
             }
         
         // ELECTRON GUN
         union {
             difference {    // Hollow cathode
                 merge {
                     difference {
                         cylinder {<-4.5,0,0>,<-3.55,0,0>,.3}
                         cylinder {<-5,0,0>,0,.2}
                         }
                     torus {.25,.05 rotate <0,0,90> translate <-3.55,0,0>}
                     cylinder {<-3.6,0,0>,<-3.5,0,0>,.25}
                     texture {ElectrodeMetal}
                     }
                 box {<-10,0,-10>,<0,10,0>
                     pigment {color rgb <1,0,0>}
                     finish {ambient .5}
                     }
                 }
     
             isosurface {    // Heating filament inside hollow cathode
                 function {f_helix1(y,x,z,1,60,0.02,.15,1,1,0)}
                 contained_by {box {-.5, .5}}
                 accuracy 0.001
                 max_gradient 4
                 pigment {
                     gradient x
                     color_map {
                         [0.0 color rgb <.8,.3,0>]
                         [0.3 color rgb <1,.7,0>]
                         [0.3 color rgb <1,.9,.2>]
                         [0.7 color rgb <1,.7,0>]
                         [1.0 color rgb <.8,.3,0>]
                         }
                     translate <-.4,0,0>
                     }
                 finish {ambient 1 diffuse 0}
                 translate <-4.1,0,0>
                 }
 
 
         difference {    // Controling electrode with cut-away and "full interior"
             merge {
                 difference {
                     cylinder {<-4.5,0,0>,<-3.25,0,0>,.5}
                     cylinder {<-5,0,0>,<-2,0,0>,.4}
                     }
                 torus {.45,.05 rotate <0,0,90> translate <-3.25,0,0>}
                 difference {
                     cylinder {<-3.3,0,0>,<-3.2,0,0>,.45}
                     cylinder {<-4,0,0>,<-3,0,0>,.1}
                     }
                 
                 texture {ElectrodeMetal}
                 }
             plane {<0,-1,0>,0 rotate <-45,0,0>
                 pigment {color rgb <1,0,0>}
                 finish {ambient .5}
                 }
             }
 
 
             #if (ColorCRT)  // If rendering a color CRT...:
                 translate <0,0.5*.6,-.866025>*.6  // Shift it off-center
             #end
             }
 
 
         #if (ColorCRT)  // If rendering a color CRT...:
             #local EkstraKanon=merge {  // Declare an electron gun not cut open
                 cylinder {<-4.5,0,0>,<-3.25,0,0>,.5}
                 torus {.45,.05 rotate <0,0,90> translate <-3.25,0,0>}
                 texture {ElectrodeMetal}
                 }
             #object {EkstraKanon translate <0,0.5*.6,.866025*.6>} // Place two of those in addition
             #object {EkstraKanon translate <0,-.6,0>}             // to the cut-open one above
         #end
              
              
         
         
         
         
         merge { // Rubber gasket where the anode voltage wire enters CRT
             difference {
                 cylinder {<5,.5,0>,<5,1,0>,1.2}
                 torus {1.2,.8 scale <1,.5,1> translate <5,1,0>}
                 }
             cylinder {<5,1,0>,<5,1.3,0>,.4}
             torus {.3,.1 translate <5,1.3,0>}
             cylinder {<5,1.3,0>,<5,1.4,0>,.3}
             pigment {color rgb .2}
             finish {ambient .5}
             rotate <0,0,20>
             }
         
         
         
         sphere_sweep {    // Anode voltage wire
             cubic_spline
             5
             <5,1.15,-1>,.15
             <5,1.15, 0>,.15
             <5,0   , 4>,.15
             <5,-5   , 6>,.15
             <5,-7   , 8>,.15
             pigment {color rgb<.8,.3,.4>}
             finish {ambient .5}
             rotate <0,0,20>
             }
 #end
 
 #macro Ebeam(OffsetX,OffsetY)   // Shape of an electron beam with given X and Y offsets
         sphere_sweep {
             linear_spline
             6
             <-3.75,OffsetY,OffsetX>,.4
             <-3.25,OffsetY*.95,OffsetX*.95>,.08
             <-1.70,OffsetY*.85,OffsetX*.85>,.5
             < 0.50,OffsetY*.65,OffsetX*.65>,.3
             < 8.8346,-1.7173,0>,.005
             < 9.1291,-1.7745-.03*OffsetY,-.03*OffsetX>,.015
             }
 #end
         
         #if (ColorCRT)  // If rendering a color CRT...:            
             // Place three electron beams:
             
             #object {Ebeam(-.519615242,.3)        // Blue beam
                 pigment {color rgbf <.7,.7,1,.7>}
                 finish {ambient 1 diffuse 0}
                 }
             
             #object {Ebeam( .519615242,.3)        // Green beam
                 pigment {color rgbf <.7,1,.7,.7>}
                 finish {ambient 1 diffuse 0}
                 }
 
             #object {Ebeam(0,-.6)                 // Red beam
                 pigment {color rgbf <1,.7,.7,.7>}
                 finish {ambient 1 diffuse 0}
                 }
             
             
             #difference {     // Mask just behind the phospor coated screen
                 difference {
                     sphere {0,9.01}
                     sphere {0,8.99}
                     plane {<0,1,0>,0 rotate <0,0,-20>}
                     plane {<0,-1,0>,0 rotate <0,0,20>}
                     plane {<0,0,1>,0 rotate <0,25,0>}
                     plane {<0,0,-1>,0 rotate <0,-25,0>}
                     
                     #if (SeeScreen) // If rendering close-up of screen:
                         // Make holes in the mask:
                         #local Ccnt=-2;
                         #while (Ccnt<4)
                             #local Rcnt=-38;
                             #while (Rcnt<-32)
                                 cylinder {0,<12,0,0>,.01 rotate <0,6*Ccnt*.8660254037845/10,(Rcnt+.33333)*3/10>}
                                 cylinder {0,<12,0,0>,.01 rotate <0,6*(Ccnt+.5)*.8660254037845/10,(Rcnt-.16667)*3/10>}
                                 #local Rcnt=Rcnt+1;
                             #end
                             #local Ccnt=Ccnt+1;
                         #end                    
                         texture {ElectrodeMetal}
                     #else
                         texture {ScreenMetal}
                     #end
                     }
                 
                 box {<-15,0,-15>,<15,15,0> rotate <0,0,-11>
                     pigment {color rgb <1,0,0>}
                     finish {ambient .7}
                     }
                 
                 }
         
         #else // If rendering a monochrome or oscilloscope-type CRT...:
             #object {Ebeam(0,0) // Place a single electron beam
                 pigment {color rgbf <.8,.9,1,.6>}
                 finish {ambient 1 diffuse 0}
                 }
         #end
 
         merge {     // Connector at the rear end of the CRT
             difference {
                 cylinder {<-5.4,0,0>,<-5.3,0,0>,.8}
                 torus {.8,.1 rotate <0,0,90> translate <-5.4,0,0>}
                 }
             cylinder {<-5.4,0,0>,<-5.5,0,0>,.7}
             torus {.6,.1 rotate <0,0,90> translate <-5.5,0,0>}
             difference {
                 cylinder {<-5.4,0,0>,<-5.6,0,0>,.6}
                 cylinder {<-6,0,0>,<-5,0,0>,.4}
                 }
             torus {.4,.1 rotate <0,0,90> translate <-5.5,0,0>}
             cone {<-5.3,0,0>,.8,<-5.2,0,0>,1}
             cylinder {<-5.2,0,0>,<-5,0,0>,1}
             cylinder {<-5,0,0>,<-4.8,0,0>,.7}
             cylinder {<-4.8,0,0>,<-4.5,0,0>,1}
             pigment {color rgb <0,.5,1>}
             finish {ambient .5}
             }
                       
         #object {ConnectorPinMetal rotate <  0,0,0>}
         #object {ConnectorPinMetal rotate < 60,0,0>}
         #object {ConnectorPinMetal rotate <120,0,0>}
         #object {ConnectorPinMetal rotate <180,0,0>}
         #object {ConnectorPinMetal rotate <240,0,0>}
         #object {ConnectorPinMetal rotate <300,0,0>}
 
         
         
         
         #if (SeeScreen) // Cameraposition for:
             camera {location <-7,7,-7> look_at <9,-1.74,0> angle 1}   // Close-up of screen and mask
         #else
             camera {location <-7,7,-7> look_at <1.05,.05,0> angle 62} // General overview
         #end
         
         
         // Surroundings: Completely white in the direction the camera "looks", but
         // with a "spotty" pattern elsewhere to enhance reflective surfaces
                 
         #local SpottyPattern=pigment {
             granite
             color_map {
                 [0 color rgb 0]
                 [1 color rgb 1]
                 }
             }
         sky_sphere {
             pigment {
                 gradient y
                 pigment_map {
                     [0.00 color rgb <1,1,1>]
                     [0.12 color rgb <1,1,1>]
                     [0.15 SpottyPattern]
                     [1.00 SpottyPattern]
                     }
                 translate -.5
                 scale 2
                 rotate <-56,51,0>
                 }
             }
         
         // Light sources
         light_source {< 200,100,-100> color rgb 1}
         light_source {<-200,200, 100> color rgb 1}
         light_source {< 200,100, 200> color rgb 1}

Start a discussion about File:CRT color.png

Start a discussion