|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I have the following:
//macro to make a tube of rings of spheres
#macro sphereTube(height, tubeRadius, elements, bottomSurface, topSurface,
place)
#declare i = 10;
#declare shift = <0, 0, 0>;
#while (i < height)
objectRing(
tubeRadius, //radius of ring
elements, //number of objects in ring
bottomSurface, //start texture of object
topSurface, //end texture of object
place + shift //place away from origin
)
#declare shift = shift + <0, ballRadius(tubeRadius, elements)*2*i, 0>;
#declare i = i+1;
#end
#end
The problem is that the macro inside the loop (which functions properly) is
not being called more than once. In fact, even the message I am given says
there are only a certain amount of frame level objects, as opposed to a
certain amount of frame level objects times the height (which is the loop
condition).
If you replace the macro inside the loop with a simple prmitive, such as a
sphere, then you will see the many spheres. Why is the macro not being
called multiple times?
Thanks for your help,
Arie
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Arie L. Stavchansky <ari### [at] bellatlanticnet> wrote:
> I have the following:
[snip]
> The problem is that the macro inside the loop (which functions properly)
is
> not being called more than once. In fact, even the message I am given
says
> there are only a certain amount of frame level objects, as opposed to a
> certain amount of frame level objects times the height (which is the loop
> condition).
>
> If you replace the macro inside the loop with a simple prmitive, such as a
> sphere, then you will see the many spheres. Why is the macro not being
> called multiple times?
Check that your objectRing macro is actually returning the objects you want
in the scene, rather than declaring them as object variables. Otherwise, it
might help to see the code for that macro as well...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it Arie L. Stavchansky who wrote:
>I have the following:
>
>//macro to make a tube of rings of spheres
>#macro sphereTube(height, tubeRadius, elements, bottomSurface, topSurface,
>place)
>
> #declare i = 10;
> #declare shift = <0, 0, 0>;
>
> #while (i < height)
>
> objectRing(
>
> tubeRadius, //radius of ring
> elements, //number of objects in ring
> bottomSurface, //start texture of object
> topSurface, //end texture of object
> place + shift //place away from origin
>
> )
>
> #declare shift = shift + <0, ballRadius(tubeRadius, elements)*2*i, 0>;
> #declare i = i+1;
>
> #end
>
>#end
>
>The problem is that the macro inside the loop (which functions properly) is
>not being called more than once. In fact, even the message I am given says
>there are only a certain amount of frame level objects, as opposed to a
>certain amount of frame level objects times the height (which is the loop
>condition).
>
>If you replace the macro inside the loop with a simple prmitive, such as a
>sphere, then you will see the many spheres. Why is the macro not being
>called multiple times?
>
>Thanks for your help,
>Arie
>
>
Since it works with simple primitives, I'd guess that one of the macros
you call "ballRadius" or "objectRing" is clobbering the value of your
counter variable "i".
The way to fix this is to change your #declares into #locals. This
allows each macro to have its own copy of the variable which then won't
interfere with similarly names variables in the calling macro or in the
top level of the scene file.
When you use "#declare i" you are changing the value of the global
variable called "i". So, if objectRing() uses "i" as its counter, and
counts up to "elements", when control returns out from objectRing() into
sphereTube(), the value of "i" has been changed from 10 to elements. If
elements+1 is greater than height, the while clause of sphereTube() is
satisfied, and the macro terminates.
If this is the case, then you're lucky that height is less than
elements+1, otherwise it could easily have gone into an infinite loop.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
That was it Mike! I had not declared them as local. I didn't know that
directive existed. Thanks for the help!
Arie
"Mike Williams" <mik### [at] nospamplease> wrote in message
news:B$i7SBABN9z7Ew+p### [at] econymdemoncouk...
> Wasn't it Arie L. Stavchansky who wrote:
> >I have the following:
> >
> >//macro to make a tube of rings of spheres
> >#macro sphereTube(height, tubeRadius, elements, bottomSurface,
topSurface,
> >place)
> >
> > #declare i = 10;
> > #declare shift = <0, 0, 0>;
> >
> > #while (i < height)
> >
> > objectRing(
> >
> > tubeRadius, //radius of ring
> > elements, //number of objects in ring
> > bottomSurface, //start texture of object
> > topSurface, //end texture of object
> > place + shift //place away from origin
> >
> > )
> >
> > #declare shift = shift + <0, ballRadius(tubeRadius, elements)*2*i, 0>;
> > #declare i = i+1;
> >
> > #end
> >
> >#end
> >
> >The problem is that the macro inside the loop (which functions properly)
is
> >not being called more than once. In fact, even the message I am given
says
> >there are only a certain amount of frame level objects, as opposed to a
> >certain amount of frame level objects times the height (which is the loop
> >condition).
> >
> >If you replace the macro inside the loop with a simple prmitive, such as
a
> >sphere, then you will see the many spheres. Why is the macro not being
> >called multiple times?
> >
> >Thanks for your help,
> >Arie
> >
> >
>
> Since it works with simple primitives, I'd guess that one of the macros
> you call "ballRadius" or "objectRing" is clobbering the value of your
> counter variable "i".
>
> The way to fix this is to change your #declares into #locals. This
> allows each macro to have its own copy of the variable which then won't
> interfere with similarly names variables in the calling macro or in the
> top level of the scene file.
>
> When you use "#declare i" you are changing the value of the global
> variable called "i". So, if objectRing() uses "i" as its counter, and
> counts up to "elements", when control returns out from objectRing() into
> sphereTube(), the value of "i" has been changed from 10 to elements. If
> elements+1 is greater than height, the while clause of sphereTube() is
> satisfied, and the macro terminates.
>
> If this is the case, then you're lucky that height is less than
> elements+1, otherwise it could easily have gone into an infinite loop.
>
> --
> Mike Williams
> Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|