![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
~
does Povray support for loops , if so, then how?
I want to create a row of 10 spheres along the x-axis.
Instead of copying the sphere code 10 times, I tried to use a for loop, but
nothing doing.
#include "colors.inc"
camera {
location <0, 0, -10>
look_at <0, 0, 0>
}
for (int x = 0, x < 10; x++)
{
sphere {
<x, 0, 0>, .5 // I wanted to draw 10 spheres,
with x starting at 0, going to 10
texture {
pigment { color Red }
}
}
}
light_source { <0, 0, -5> color White}
Is it possible to use a for loop, or is the easiest way to use the brute
force method?
thanks....
out
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Jose Garcia wrote:
> ~
> does Povray support for loops , if so, then how?
the only loop structure is while-loops. but as you maybe know you can
simulate for-loops with while
#declare i = 0;
#while (i<=10);
> sphere {
>
> <i, 0, 0>, .5 // I wanted to draw 10 spheres,
> with x starting at 0, going to 10
> texture {
> pigment { color Red }
> }
> }
> }
#declare i = i + 1;
#end
- Micha
--
objects.povworld.org - The POV-Ray Objects Collection
book.povworld.org - The POV-Ray Book Project
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
try this
#declare x = 0;
#while(x<10)
sphere {
<x, 0, 0>, .5
texture {
pigment { color Red }
}
}
#declare x=x+1;
#end
--
Kevin
http://www.geocities.com/qsquared_1999/
#macro _(r)#if(r<12)#local i=asc(substr("oqshilacefg",r,1))-97;
disc{<mod(i,7)-3,div(i,7)-1,6>,z,.4pigment{rgb 10}}_(r+1)
#end#end _(1)//KL
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> Is it possible to use a for loop, or is the easiest way to use the brute
> force method?
Hi!
Yes, POV-Ray supports loops
This creates 10 red spheres along the x axis:
camera {
location <5, 0, -10>
look_at <5, 0, 0>
}
#declare Q = 0;
#while (Q < 10)
sphere {<Q,0,0>,.5
texture {pigment { rgb <1,0,0> }}
}
#declare Q = Q+1;
#end
light_source { <0,0,-5> rgb 1}
Hope that helps!
(Check out the docs [6.2.6.4] The #while...#end Directive)
-Peter
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Jose Garcia wrote:
>
> ~
> does Povray support for loops , if so, then how?
Check this out -
http://www.students.tut.fi/~warp/povQandT/whileloops.html
--
Ken Tyler
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
No, don't actually try that!! x is a pre-defined vector
( <1,0,0> ) and re-defining it would be "a bad thing"...
Here's a variation (just to play around with vectors!):
#declare myvec = x;
#declare endvec = x*10;
#while (myvec <= endvec)
sphere
{
myvec, .5 texture{ pigment { color rgb myvec/10 } }
}
#declare myvec = myvec + x;
#end
'because I can'...
Emory
Kevin Loney wrote:
>
> try this
>
> #declare x = 0;
> #while(x<10)
> sphere {
> <x, 0, 0>, .5
> texture {
> pigment { color Red }
> }
> }
> #declare x=x+1;
> #end
>
> --
> Kevin
> http://www.geocities.com/qsquared_1999/
> #macro _(r)#if(r<12)#local i=asc(substr("oqshilacefg",r,1))-97;
> disc{<mod(i,7)-3,div(i,7)-1,6>,z,.4pigment{rgb 10}}_(r+1)
> #end#end _(1)//KL
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
oops, whats was I thinking :-P
thanks for pointing that out
--
Kevin
http://www.geocities.com/qsquared_1999/
#macro _(r)#if(r<12)#local i=asc(substr("oqshilacefg",r,1))-97;
disc{<mod(i,7)-3,div(i,7)-1,6>,z,.4pigment{rgb 10}}_(r+1)
#end#end _(1)//KL
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |