|
|
I'm new to povray, and have been getting on OK with most of the programming
aspect of it, but I've run into something I can't figure out. Here's the
relevant bit of code:
---------snip-----------
#declare Norm = <0, 0, 0>;
#declare n = 0;
#macro Ring(Up)
#while (n < 360)
#declare r=<sin(radians(n)),0,cos(radians(n))>;
#declare Pos = trace (
Pot, // object to test
<0,Up,0>, // starting point
r, // direction
Norm ); // normal
// if intersection is found, normal differs from 0
#if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)
sphere {Pos,0.1 pigment {colour Yellow}}
#end
#declare n=n+10;
#end
#end
object{ Pot scale 1}
Ring(0.5)
Ring (0.0)
Ring (1)
------------------snip------------
I've got a patch object called Pot, and I'm using the trace() function to
put tiny yellow spheres on its surface. The Ring() macro takes a given
height (Up) and finds the intersections with the pot every ten degrees in a
full circle at that height. (hopefully that is clearer from the code than
from my explanation). So far, so good, but the trouble is, when I try to
do this for a number of heights (eg 0, 0.5 and 1 in the example above) only
the ring corresponding to the first instance of the macro (y=0.5) shows up.
There's probably a simple explanation; if anyone could point it out to me I
would be very grateful :-)
If it would be helpful to post the whole scene file, let me know
Thanks
moj34
Post a reply to this message
|
|
|
|
Hi,
After the first call of the Ring macro, n=360, so the #while statement
of subsequent calls of this macro will abort immediately. Putting the
line with "#declare n = 0;" between "#macro Ring(Up)" and "#while"
should correct this.
"#local AngleDegrees = ...;" is even better -- "#local" avoids unwanted
side effects on variables outside the macro, "AngleDegrees" is easier
to understand, and every identifier should have at least one uppercase
letter to avoid possible conflicts with (future) keywords. (Keywords will
never have uppercase letters.)
Sputnik
--
----------------------------
fr### [at] computermuseumfh-kielde
----------------------------
Post a reply to this message
|
|