home *** CD-ROM | disk | FTP | other *** search
/ ANews 3 / AnewsCD3.iso / atari / GRAPHX / POV / 68030.060 / POV31G30 / POVRAY_3.1G / SCENES / MACROS / PYRAMID2.POV < prev   
Text File  |  1999-10-30  |  1KB  |  65 lines

  1. // Persistence of Vision Ray Tracer POV-Ray 3.1 Sample Scene
  2. // by Chris Young
  3. //    Based on a POV-Ray 3.0 file by
  4. //    Sven Hilscher * 3D-Max usergroup germany
  5. //    email: sven@rufus.central.de
  6. // PYRAMID2.POV demonstrates basic use of macros and local
  7. // identifiers in recursive calls.  Creates a fractal
  8. // pyramid from spheres.
  9. //
  10. // This version is more complicated but it eliminates
  11. // some reduntant spheres.
  12.  
  13. // Define the macro.  Parameters are:
  14. //   X:  position of sphere
  15. //   Y:  position of sphere
  16. //   Z:  position of sphere
  17. //   R:  radius of sphere
  18. //   L:  level of recursion
  19. #macro Pyramid(X,Y,Z,R,L,D)
  20.  
  21.   sphere { <X,Y,Z>,R}
  22.  
  23.   #if (L > 0)
  24.     #local New_L = L - 1;
  25.     #local New_R = R / 2;
  26.     #local Pos   = New_R * 3;
  27.  
  28.     #if (D!=2)
  29.        Pyramid(X+Pos,Y,Z,New_R,New_L,1)
  30.     #end       
  31.     #if (D!=1)
  32.        Pyramid(X-Pos,Y,Z,New_R,New_L,2)
  33.     #end       
  34.     #if (D!=4)
  35.        Pyramid(X,Y+Pos,Z,New_R,New_L,3)
  36.     #end       
  37.     #if (D!=3)
  38.        Pyramid(X,Y-Pos,Z,New_R,New_L,4)
  39.     #end       
  40.     #if (D!=6)
  41.        Pyramid(X,Y,Z+Pos,New_R,New_L,5)
  42.     #end       
  43.     #if (D!=5)
  44.        Pyramid(X,Y,Z-Pos,New_R,New_L,6)
  45.     #end       
  46.   #end       
  47. #end
  48.  
  49.  
  50.  
  51.  
  52. union {
  53.   Pyramid(0,0,0,4,6,0)
  54.  
  55.   pigment { color rgb <1,1,0> } 
  56. }
  57.  
  58. light_source { <2,20,10> color rgb <1,1,1> }
  59.  
  60. background { color rgb <.4, .3, .2> }
  61.  
  62. camera { location <5,17,19>
  63.          look_at  <0,0,0>
  64. }
  65.