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

  1. // Persistence of Vision Ray Tracer POV-Ray 3.1 Sample Scene
  2. // by Chris Young
  3. // MACRO3.POV demonstrates basic use of a macro as a type
  4. // of "inline function" that "returns" a value like a built-in
  5. // function.
  6. #include "colors.inc"
  7.  
  8. light_source { <100,1000,-1000>, White}
  9.  
  10. camera { location <0,0,-15> direction 2*z look_at <0,0,0>}
  11.  
  12. plane{-z,-1  pigment{checker Cyan,Yellow}}
  13.  
  14. // Define the macro.  Parameters are:
  15. //   T:  Middle value of time
  16. //   T1: Initial time
  17. //   T2: Final time
  18. //   P1: Initial position (may be float, vector or color)
  19. //   P2: Final position (may be float, vector or color)
  20. //   Result is a value between P1 and P2 in the same proportion
  21. //    as T is between T1 and T2.
  22. #macro Interpolate(T,T1,T2,P1,P2)
  23.    // Note: Without outermost parens this doesn't work as expected
  24.    //       in the Location calculations.
  25.    (P1+(T1+T/(T2-T1))*(P2-P1))
  26.  
  27. #end
  28.  
  29. #declare Here  = <-5,-2,0>;
  30. #declare There = <5,3,0>;
  31. #declare This_Color = rgb <1,1,0>;
  32. #declare That_Color = rgb <1,0,1>;
  33. #declare Size1 = 0.3;
  34. #declare Size2 = 0.5;
  35.  
  36. #declare I=0;
  37. #while (I<15)
  38.   // Interpolate vector location from Here to There
  39.   #declare Location=<0,0,-1> + Interpolate(I,0,15,Here,There) * 0.8;
  40.  
  41.   sphere{ 
  42.     Location,
  43.     // Interpolate float radius
  44.     Interpolate(I,0,15,Size1,Size2)
  45.     pigment{
  46.       // Interpolate color 
  47.       color Interpolate(I,0,15,This_Color,That_Color)
  48.     }
  49.   }
  50.   #declare I=I+1;
  51. #end
  52.