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

  1. // Persistence of Vision Ray Tracer POV-Ray 3.1 Sample Scene
  2. // by Chris Young
  3. // MACRO4.POV demonstrates basic use of a macro as a type
  4. // of procedure that "returns" a value via a parameter but
  5. // only when a lone identifier is passed.  If a constant
  6. // or expression is passed, the value cannot be returned.
  7. #include "colors.inc"
  8.  
  9. light_source { <100,1000,-1000>, White}
  10.  
  11. camera { location <0,-1,-16> direction 2*z look_at <0,-1,0>}
  12.  
  13. plane{-z,-10  pigment{checker Cyan,Yellow}}
  14.  
  15. // Define the macro.  Parameters are:
  16. //   V:  The value to be incremented.  New value
  17. //       is returned via this parameter so it must be
  18. //       a lone identifier.  It cannot be a constant or 
  19. //       an expression.
  20. #macro Inc(V)
  21.   #local V=V+1;
  22. #end
  23.  
  24. #declare Value=5;
  25.  
  26. union{
  27.  text{ttf "timrom.ttf" "#macro Inc(V)",0.1,0 translate 2*y}
  28.  text{ttf "timrom.ttf" "  #local V=V+1;",0.1,0 translate y}
  29.  text{ttf "timrom.ttf" "#end",0.1,0 }
  30.  
  31.  text{ttf "timrom.ttf" concat("#declare Value=",str(Value,0,0),";"),0.1,0 translate -y}
  32.  
  33.  Inc(Value+0)  // Expression won't work
  34.  
  35.  text{ttf "timrom.ttf" concat("Inc(Value+0)=",str(Value,0,0)),0.1,0 translate -2*y}
  36.  
  37.  Inc(+Value)  // This too is an expression so it won't work
  38.  
  39.  text{ttf "timrom.ttf" concat("Inc(+Value)=",str(Value,0,0)),0.1,0 translate -3*y}
  40.  
  41.  Inc(Value)   // Lone identifier works.  It accepts return value.
  42.  
  43.  text{ttf "timrom.ttf" concat("Inc(Value)=",str(Value,0,0)),0.1,0 translate -4*y}
  44.  
  45.  pigment{Red}
  46.  translate -3.75*x
  47. }
  48.