|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I have a scene file which has stuff like this:
#macro bigthing(_this, _that, _other)
..... do this big thing
#end // bigthing
#macro blah(_index)
bigthing(ThisArr[_index], ThatArr[_index], OtherArr[_index])
#end // blah
blah(1)
blah(2)
blah(3)
..... and so forth
Is there any way I can condense the multiple blah() calls into something like:
#for _index in 1..10
blah(_index)
#end // for
That would rule. Thanks!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mathuin wrote:
> I have a scene file which has stuff like this:
>
> #macro bigthing(_this, _that, _other)
> ..... do this big thing
> #end // bigthing
>
> #macro blah(_index)
> bigthing(ThisArr[_index], ThatArr[_index], OtherArr[_index])
> #end // blah
>
> blah(1)
> blah(2)
> blah(3)
> ..... and so forth
>
> Is there any way I can condense the multiple blah() calls into something like:
>
> #for _index in 1..10
> blah(_index)
> #end // for
>
> That would rule. Thanks!
There's no "for" but you can use "while" for the same purpose. For example:
#declare Count = dimension_size(ThisArr, 1);
#declare Ct = 0;
#while(Ct < Count)
blah(Ct)
#declare Ct = Ct + 1;
#end
--
// The Mildly Infamous Blue Herring
#version 3.61;#include"functions.inc"global_settings{assumed_gamma
2.2}isosurface{function{-f_strophoid(x/2-.45,y,z*3,1,1.2,1,1.5)-.05}
contained_by{box{<-2.1,-1,-1/3>,<1.4,1,1/3>}}max_gradient 12inverse
hollow pigment{rgbf 1}interior{media{samples 8 emission<3,80,150>/255
density{crackle metric 1color_map{[0rgb 6][.03rgb 0][1rgb 0]}scale<1,
2,1>warp{turbulence<.5,.75,.5>}scale 1/3}}}translate z*3}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Mathuin" <mat### [at] gmailcom> wrote:
....
> Is there any way I can condense the multiple blah() calls into something like:
>
> #for _index in 1..10
> blah(_index)
> #end // for
Would #switch, #case, #range, help?
Stephen S
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Blue Herring <pov### [at] bherringcotsenet> wrote:
> Mathuin wrote:
> > I have a scene file which has stuff like this:
> >
> > #macro bigthing(_this, _that, _other)
> > ..... do this big thing
> > #end // bigthing
> >
> > #macro blah(_index)
> > bigthing(ThisArr[_index], ThatArr[_index], OtherArr[_index])
> > #end // blah
> >
> > blah(1)
> > blah(2)
> > blah(3)
> > ..... and so forth
> >
> > Is there any way I can condense the multiple blah() calls into something like:
> >
> > #for _index in 1..10
> > blah(_index)
> > #end // for
> >
> > That would rule. Thanks!
>
> There's no "for" but you can use "while" for the same purpose. For example:
>
> #declare Count = dimension_size(ThisArr, 1);
> #declare Ct = 0;
> #while(Ct < Count)
> blah(Ct)
> #declare Ct = Ct + 1;
> #end
I should have remembered that from C! Thanks!
>
> --
> // The Mildly Infamous Blue Herring
> #version 3.61;#include"functions.inc"global_settings{assumed_gamma
> 2.2}isosurface{function{-f_strophoid(x/2-.45,y,z*3,1,1.2,1,1.5)-.05}
> contained_by{box{<-2.1,-1,-1/3>,<1.4,1,1/3>}}max_gradient 12inverse
> hollow pigment{rgbf 1}interior{media{samples 8 emission<3,80,150>/255
> density{crackle metric 1color_map{[0rgb 6][.03rgb 0][1rgb 0]}scale<1,
> 2,1>warp{turbulence<.5,.75,.5>}scale 1/3}}}translate z*3}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> There's no "for" but you can use "while" for the same purpose.
Although it would be nice to have a for loop as well. I understand
the concept of semantic sugar, but there must be a reason why every
programming language in popular use has such a construct. And in
SDL in particular I think most loops I've ever seen were actually
counter-based loops (placing objects, subdivide angles, arrays).
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 07-Oct-08 22:55, Christian Froeschlin wrote:
>
>> There's no "for" but you can use "while" for the same purpose.
>
> Although it would be nice to have a for loop as well. I understand
> the concept of semantic sugar, but there must be a reason why every
> programming language in popular use has such a construct.
And preferably with a counter whose scope is limited to the loop.
Would you like to have arbitrary next item functions or just simply
numeric increment?
> And in
> SDL in particular I think most loops I've ever seen were actually
> counter-based loops (placing objects, subdivide angles, arrays).
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
andrel wrote:
> Would you like to have arbitrary next item functions or just simply
> numeric increment?
an increment would be just fine
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
andrel <a_l### [at] hotmailcom> wrote:
> Would you like to have arbitrary next item functions or just simply
> numeric increment?
I think arbitrary next-item functions are best.
If this is the example loop:
#declare Count=0;
#while (Count<MaxItems)
blah(Count)
#declare Count=Count+1;
#end // while (Count<MaxItems)
This form would be perfectly familiar to all the C users out there:
#for (Count=0; Count<MaxItems; Count=Count+1)
blah(Count)
#end // for (Count=0; Count<MaxItems; Count=Count+1)
Other languages are different, of course, but C seems to be "common ground".
I don't think assignments, comparisons, or statements can be passed as macro
arguments, but if they could be, something like this would almost work:
#macro for(init, check, inc, body)
#declare init
#while (check)
body
#declare inc
#end // macro for
>
> > And in
> > SDL in particular I think most loops I've ever seen were actually
> > counter-based loops (placing objects, subdivide angles, arrays).
That's what I've seen in other source files -- wish I had more experience, but
I'm still the new guy. :-P
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mathuin wrote:
> I don't think assignments, comparisons, or statements can be passed as macro
> arguments, but if they could be, something like this would almost work:
>
> #macro for(init, check, inc, body)
well, in case somebody loves odd syntactic constructs, here
is a somewhat silly macro for a counter-based loop, although
in this form not nestable for multiple loops:
#macro FROM_TO(FROM,TO)
#local i = FROM;
#while (i < TO)
FOR(i)
#declare i = i + 1;
#end
#end
Ponder it for a while and scroll down if confused ;)
...
Scroll some more
...
// Here is how to actually write a loop with it:
#macro FOR(I)
sphere {<I,0,0>,1 pigment {color rgb 1}}
#end FROM_TO(0,10)
... and what a good thing that macros can be redefined ;)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|