home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / MISC / WG5.ZIP / WG5.DAT
Encoding:
Text File  |  1991-09-17  |  8.9 KB  |  275 lines

  1. // Persistence of Vision Raytracer
  2.    {  Dan Farmer
  3.       1001 e. 80th St. #102
  4.       Bloomington, mn 55425
  5.                                                                                
  6.       Wine glass with red wine, marbled checkerboard behind it.
  7.                                                                                
  8.       This data file is for use with pv-Trace and is file
  9.       is released to the public domain and may be used or altered by           
  10.       anyone as desired.
  11.    }
  12.  
  13. #include "colors.dat"
  14. #include "shapes.dat"
  15. #include "textures.dat"
  16.  
  17. // A viewpoint somewhat up, to the right, and back 75 units
  18. view_point
  19.    location <50.0  55.0  -75.0>
  20.    direction <0.0 0.0  2.0>
  21.    up  <0.0  1.0  0.0>
  22.    right <1.33333 0.0 0.0>
  23.    look_at <-10.0 18.0 0.0>  { Let's look to our left a little, and down }
  24. end_view_point
  25.  
  26. object { Light source #1, backliting, slightly to the right }
  27.    sphere <0.0  0.0  0.0>  2.0 end_sphere
  28.    translate <10.0  50.0  50.0>
  29.    colour White
  30.    texture
  31.        ambient 1.0  diffuse 0.0
  32.        colour White
  33.    end_texture
  34.    light_source
  35. end_object
  36.  
  37. object  { Light source #2, above, behind, and to the left of the viewer }
  38.    sphere <0.0  0.0  0.0>  2.0 end_sphere
  39.    translate <-35.0  30.0  -150.0>
  40.    colour White
  41.    texture
  42.        ambient 1.0 diffuse 0.0
  43.        colour White
  44.    end_texture
  45.    light_source
  46. end_object
  47.  
  48. // This is not necessarily the _best_ glass, just the best for my purpose
  49. // this time.  I also use Glass2 in this file, but I didn't want the
  50. // "Shine" in the default glass texture for the top of the wineglass;
  51. // it interfered with the color of the wine.
  52. ##declare MyGlass = texture
  53.    color red 1.0 green 1.0 blue 1.0 alpha 1.0
  54.    ambient 0.0
  55.    diffuse 0.0
  56.    reflection 0.1
  57.    refraction 1.0
  58.    ior 1.33
  59.    phong 0.3
  60.    phongsize 90
  61.    transmit 0.0
  62. end_texture
  63.  
  64. // Define the color and texture for the wine in the glass
  65. #declare Wine = color red 1.0 alpha 0.85
  66. #declare Liquid = texture
  67.    reflection 0.05
  68.    refraction 1.0
  69.    ior 1.2
  70. end_texture
  71.  
  72. // This will be used for glass beads on the stem of the glass
  73. // I used Quadric spheres so the whole composite could be scaled.
  74. // Procedural (regular) SPHERES cannot be scaled unevenly.
  75. #declare Bead = object
  76.     quadric QSphere scale <1.65 0.65 1.65> end_quadric
  77.     color red 1.0 blue 1.0
  78.     texture Glass2 end_texture
  79. end_object
  80.  
  81.  
  82. // The next shape declared is a thin torus that will be used to give
  83. // the rim of the glass a beaded edge.
  84. {
  85.    Torus generated using Truman's Torus Generator 1.0 (c) 1991 Truman Brown
  86.    Torus specs:                                                                  
  87.       Major radius: 0.975000      Minor radius: 0.025000
  88.       Outer radius: 1.000000      Inner radius: 0.950000
  89. }
  90. #declare Rim = object
  91.     quartic
  92.     <    1.000000 0.000000 0.000000 0.000000 2.000000
  93.          0.000000 0.000000 2.000000 0.000000 -1.902500
  94.          0.000000 0.000000 0.000000 0.000000 0.000000
  95.          0.000000 0.000000 0.000000 0.000000 0.000000
  96.          1.000000 0.000000 0.000000 2.000000 0.000000
  97.          1.900000 0.000000 0.000000 0.000000 0.000000
  98.          1.000000 0.000000 -1.902500 0.000000 0.902500 >
  99.     end_quartic
  100.     clipped_by plane <0.0 -1.0 0.0> 0.0 end_plane end_clip
  101.     scale <15.0 10.0 15.0>
  102.     translate <0.0 24.0 0.0>
  103.     color red 1.0
  104.     texture Gold_Texture end_texture
  105. end_object
  106.  
  107. // The top of the glass.  Remember, a cone is infinite in both directions.
  108. // The clipping shape and the intersection with a plane "chops" off the
  109. // portion that I want to use.  This cone is pointed downwards.
  110. #declare Top = object
  111.     intersection
  112.         plane <0.0 1.0 0.0> 1.0  end_plane
  113.         quadric Cone_Y end_quadric
  114.         quadric Cone_Y scale <0.97 1.0 0.97> inverse end_quadric
  115.     end_intersection
  116.     clipped_by
  117.         plane <0.0 1.0  0.0> 0.0  inverse end_plane
  118.     end_clip
  119.     scale <15.0 10.0 15.0>
  120.     translate <0.0 14.0 0.0>
  121.     color green 1.0
  122.     texture MyGlass end_texture
  123. end_object
  124.  
  125. // A cylinder, also "cut" by two planes to keep it from running off into
  126. // infinity.
  127. #declare Stem = object
  128.     quadric Cylinder_Y end_quadric
  129.     clipped_by
  130.         plane <0.0 1.0 0.0> -1.0 inverse end_plane
  131.         plane <0.0 1.0 0.0>  1.0 end_plane
  132.     end_clip
  133.     scale <1.0 12.0 1.0>
  134.     translate <0.0 6.0 0.0>
  135.     color blue 1.0
  136.     texture Glass2 end_texture
  137. end_object
  138.  
  139. // Another cone segment, this one pointed upwards, and scaled quite flat.
  140. #declare Base = object
  141.     quadric Cone_Y end_quadric
  142.     clipped_by
  143.         plane <0.0 1.0  0.0> 0.0  end_plane
  144.         plane <0.0 1.0 0.0> -1.0 inverse end_plane
  145.     end_clip
  146.     translate <0.0 1.0 0.0>   { This actually puts the base of the cone on y=0}
  147.     scale <12.0 3.25 12.0>
  148.     translate <0.0 0.0 0.0> {Does nothing: just for clarity }
  149.     color red 1.0 green 1.0
  150.     texture Glass2 end_texture
  151. end_object
  152.  
  153. // The wine in the glass is actually another cone nested inside of the
  154. // top of the glass.  If it weren't for a temporary bug in the PV program
  155. // that I'm writing this with, I'd try for some gentle ripples on the
  156. // top intersecting plane.
  157. #declare Wine = object
  158.     intersection
  159.         plane <0.0 1.0 0.0> 0.9
  160.         end_plane
  161.         quadric Cone_Y scale <0.95 1.0 0.95> end_quadric
  162.     end_intersection
  163.     clipped_by
  164.         plane <0.0 1.0  0.0> 0.0  inverse
  165.         end_plane
  166.     end_clip
  167.     scale <14.9 10.0 14.9>
  168.     translate <0.0 14.0 0.0>
  169.     color White
  170.     texture Liquid
  171.         color Wine
  172.     end_texture
  173. end_object
  174.  
  175. // The nice blue ground plane
  176. object
  177.     plane <0.0 1.0 0.0> -0.0 end_plane
  178.     color DimGray
  179.  
  180.     // The 0.2 is a random dithering value.
  181.     // Gives it that nice blue speckled texture.
  182.     texture 0.2 color RichBlue end_texture
  183.  
  184. end_object
  185.  
  186. // This is four cylinder segments that will be used to frame the
  187. // checkerboard.  I gave them a nice, soft silvery texture, much like
  188. // brushed aluminum.
  189. #declare Frame = object
  190.     union
  191.  
  192.         intersection X_Disk    { Front rounded edge }
  193.             scale <240.0 4.5 4.5>
  194.             translate<-120.0 0.0 -120.0>
  195.         end_intersection
  196.         intersection Z_Disk    { Left rounded edge }
  197.             scale <4.5 4.5 240.0>
  198.             translate <-120.0 0.0 -120.0>
  199.         end_intersection
  200.  
  201.         // Actually, these next two don't show, so I'm going to comment
  202.         // out to speed up the rendering somewhat.  If you should change
  203.         // the viewpoint, you may need to put these back in.
  204. {*********
  205.         intersection X_Disk    { Rear rounded edge }
  206.             scale <240.0 4.5 4.5>
  207.             translate<-120.0 0.0 +120.0>
  208.         end_intersection
  209.         intersection Z_Disk    { Right rounded edge }
  210.             scale <4.5 4.5 240.0>
  211.             translate <+120.0 0.0 -120.0>
  212.         end_intersection
  213. **********}
  214.     end_union
  215.     color red 1.0
  216.     texture Silver_Texture end_texture
  217. end_object
  218.  
  219. // You guessed it... the checkerboard.  What's a raytracing without one?
  220. #declare ChessBoard = object
  221.     intersection Cube
  222.        scale <120.0 4.0 120.0>
  223.     end_intersection
  224.     color Cyan
  225.  
  226.     // This texture could be done as well with the Checker_Texture texture
  227.     // This came to mind easier at the time, that's all.
  228.  
  229.     texture White_Marble scale <20.0 1.0 20.0> reflection 0.12 end_texture
  230.     texture checker color Black color White alpha 1.0
  231.         scale <30.0 4.001 30.0>
  232.         reflection 0.12
  233.     end_texture
  234.  
  235. end_object
  236.  
  237. // And here, we put all of the wine glass parts together into a composite.
  238. // We could simply construct and display it here, instead of declaring it
  239. // as a named object, but this will make it much easier to either move it
  240. // later, or to copy it to another location.
  241. #declare WineGlass = composite
  242.     object Rim   end_object   { The torus beaded rim }
  243.     object Wine  end_object   { The liquid in the glass }
  244.     object Top   end_object   { The top of the glass }
  245.  
  246.     // Four glass bumps on the stem
  247.     object Bead  translate <0.0 14.5 0.0> end_object
  248.     object Bead  translate <0.0 10.0 0.0> end_object
  249.     object Bead  translate <0.0  7.0 0.0> end_object
  250.     object Bead  translate <0.0  3.0 0.0> end_object
  251.  
  252.     object Stem  end_object   { Obviously, the stem of the glass }
  253.     object Base  end_object   { and the foot of the glass }
  254.     bounded_by                { Enclose it in a bounding shape for efficiency }
  255.         intersection Y_Disk
  256.             scale <15.5 25.0 15.5>
  257.         end_intersection
  258.     end_bound
  259.     scale <1.0 1.50 1.0>     { I decided it needed to be taller }
  260. end_composite
  261.  
  262. // Now we're ready to place the objects in the scene...
  263.  
  264. // The checkerboard
  265. composite
  266.     object Frame end_object        { The outside... }
  267.     object ChessBoard end_object   { and the inside }
  268.     translate <0.0 4.0 145.0>
  269. end_composite
  270.  
  271. // And the wineglass.
  272. composite WineGlass end_composite
  273.  
  274. {End of file }
  275.