POV-Ray : Newsgroups : povray.advanced-users : Putting objects into an array, then. . . : Re: Putting objects into an array, then. . . Server Time
29 Jul 2024 16:21:01 EDT (-0400)
  Re: Putting objects into an array, then. . .  
From: Ken
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.