POV-Ray : Newsgroups : povray.newusers : macro argument help : Re: macro argument help Server Time
30 Jul 2024 10:13:18 EDT (-0400)
  Re: macro argument help  
From: Christopher James Huff
Date: 28 May 2004 08:28:26
Message: <cjameshuff-141A45.07285928052004@news.povray.org>
In article <40b71634@news.povray.org>,
 Kaveh Bazargan <kav### [at] delete_thisfocalimagecom> wrote:

> I think there is a fundamental point here about macro arguments which I 
> need to learn. Why is segments zero in the line marked "//the back"? 
> Any pointers welcome.

Because you set it to 0 in the loop in sofa_seat(). Variables are passed 
"by reference", the macro can modify its parameters. Use something more 
like this:
#macro Sofa_Seat(Cushion_wd, Segments)  //calls Cushion
  union{
    #local Segs = Segments;
    #while (Segs > 0)
      object {Cushion(Cushion_wd, Cushion_dp, Cushion_ht) 
              translate (Segs-1)*Cushion_wd*x}
      #local Segs = Segs - 1;
    #end //while
  }
#end //macro Sofa_Seat 

Notice I made some naming changes...you should always use at least one 
capitalized letter in variable names in POV. Unlike other programming 
languages, the POV-Ray language has frequent additions, and doing so 
will avoid any problems with name conflicts. For example, a POV 3.1 
scene using the word "size" for a variable will not work with current 
versions, which use that word in the facets pattern. Keywords can be 
relied on to always be lower case.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.