POV-Ray : Newsgroups : povray.advanced-users : Putting objects into an array, then. . . Server Time
29 Jul 2024 18:29:07 EDT (-0400)
  Putting objects into an array, then. . . (Message 1 to 2 of 2)  
From: Arie L  Stavchansky
Subject: Putting objects into an array, then. . .
Date: 21 Sep 2001 22:57:55
Message: <3babfe33$1@news.povray.org>
Hi there,

Is it possible to create a loop such that I create a object (let's say a
sphere), then place that object into a declared array?  After which I can
manipulate an object depending on its place in the array?

Thanks for your help!


Post a reply to this message

From: Ken
Subject: Re: Putting objects into an array, then. . .
Date: 22 Sep 2001 00:19:41
Message: <3BAC127B.B2185357@pacbell.net>
"Arie L. Stavchansky" wrote:
> 
> Hi there,
> 
> Is it possible to create a loop such that I create a object (let's say a
> sphere), then place that object into a declared array?  After which I can
> manipulate an object depending on its place in the array?

You can describe the location of an object by storing it's coordinates
in an array and then use the data in the array with a while loop to
locate the objects. A simple example locates 5 spheres using an array -

#declare Dnum = 5;
#declare Data = array [Dnum][2]
{
  { 0, 0},
  {-1,-1},
  { 1, 1},
  {-1, 1},
  { 1,-1},
}

#declare Unit = sphere { 0,1 }

#declare Five_Spheres =
    union {
      #declare I=0;
       #while (I < Dnum)
        object { Unit 
            translate <Data[I][0],Data[I][1],0> 
             pigment{rgb 1}
           }
         #declare I=I+1;
       #end
}
 
camera{location<0,0,-7>look_at 0}
light_source{<-10,10,-20>rgb 1}

object { Five_Spheres }

-- 
Ken Tyler


Post a reply to this message

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