POV-Ray : Newsgroups : povray.newusers : local variables in macros : Re: local variables in macros Server Time
5 Sep 2024 08:14:17 EDT (-0400)
  Re: local variables in macros  
From: Elias Pschernig
Date: 20 May 2001 09:58:23
Message: <3b07cd7f$1@news.povray.org>
> I am far from expert, but sounds... curious. Weird. Never encountered
> anything like that myself. If you post the source, I might be able to
help
> you better. My best _guess_ is that there is some automatic vector
> expansion going on, and by making it explicit in the macro you could
avoid
> the weirdness. Btw: what version of POV are you using?

Here is the source. The problem is, without the +0, the value of the pos
vector gets changed. What i'm looking for is probably a way to change
the parameter type or something like that.

I've read the documentation (so I understand f.e. the difference between
%rec and $rec), but I didn't find anything about how to change the
parameters type.

#version unofficial MegaPov 0.7;

%rec = 0;

#macro tree(pos, dir, scl)
   $rec = rec + 1;
   cylinder { pos pos + dir * scl .1 * scl }
   %pos = pos + dir * scl;
   #if(rec < 10)
      %ldir = vaxis_rotate(dir, z, 30);
      %rdir = vaxis_rotate(dir, z, -30);
      tree(pos+0, ldir, scl*0.9) // If i don't write the '+0', it goes
wrong
      tree(pos+0, rdir, scl*0.9)
   #end
   $rec = rec - 1;
#end

tree(-4*y, <0,1,0>, 1)


Post a reply to this message

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