POV-Ray : Newsgroups : povray.general : Array... : Re: Array... Server Time
7 Aug 2024 15:20:49 EDT (-0400)
  Re: Array...  
From: JRG
Date: 15 Oct 2001 14:15:46
Message: <3bcb27d2@news.povray.org>
Hi F.Audet, wasn't you who wrote:
>
>

>
> > On Sun, 14 Oct 2001 21:39:23 -0400, F.Audet wrote:
> > >I decided to do what I wanted to do in simulating an array
> > >with two #while loops, and it finally worked.
> > >But if you could see why the famous array
> > >did not work,  here is the code :
> >
> > Maybe something having to do with returning a local from a macro; this
might
> > have been a bug in 3.1 as well.  Try rewriting the macro like this:
> >
> > >
> > >#declare s1 = seed(1);
> > >#macro bin_01 ()
> > >  #if ( rand(s1) <= 0.5 )
> > >    object { nice_zero }
> > >  #else
> > >    object { nice_one }
> > >  #end
> > >#end
> >
>
> ... It does parse and trace,  but nothing appears on the screen.
> Messages: 1 frame level object; 1 infinite.   // my plane object !
> ... I think it is my fault,  cause I just tried,  a minute ago,  with
> a simple csg object,  without any kind of randomness and #local,
> and it doesn' t work anymore !
>
> in fact,  the following code doesn' t work at all...
> #declare YOUR_ARRAY = array[20][20]
> #declare i = 0;
> #while (i<20)
> #declare j=0;
> #while (j<20)
> #declare YOUR_ARRAY[i][j] = sphere { 0, 1 pigment { White }}
> #declare j=j+1;
> #end
> #declare i=i+1;
> #end
>
> Have I to put it into "object {YOUR_ARRAY}", or something like that ?!?
>
> Alex Pilot

I think you misunderstood what an array is. Just having 400 objects put in
an array does not mean that you get them traced!
If you want to put your 400 objects in a 20x20 units grid you have to add
the following code:

 #declare i = 0;
 #while (i<20)
#declare j=0;
#while (j<20)
object {YOUR_ARRAY[i][j] translate <-10 +i, 0 , -10+j>}
#declare j=j+1;
#end
#declare i=i+1;
#end

But probably it's me who has misunderstood you...

--
Jonathan.


Post a reply to this message

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