POV-Ray : Newsgroups : povray.general : The Language of POV-Ray : Re: The Language of POV-Ray Server Time
10 Aug 2024 17:29:59 EDT (-0400)
  Re: The Language of POV-Ray  
From: Chris Huff
Date: 10 Mar 2000 07:20:45
Message: <chrishuff_99-CC07EC.07223210032000@news.povray.org>
In article <38C816BE.35E35A1C@hotmail.com>, Tor Olav Kristensen 
<tor### [at] hotmailcom> wrote:

> But what if the loop control variable is a vector that is shared
> between several nested loops? (See my example macro below.)
> 
> Would this be possible with nested for-loops?

It would be possible, but not necessarily the best way to do it. 
Something like this:


#macro ObjectSplit(Thing, Point1, Point2, nnv)
// Cuts an object into several "box"-parts
// Result is returned in an array of such parts

  //#local nnv = <nx, ny, nz>;
  #local ThingArray = array[nnv.x][nnv.y][nnv.z]
  #local dPoint = (Point2 - Point1)/nnv;

  #for(Cntv = <0,0,0>; Cntv.z < nnv.z; Cntv.z += 1)
    #for(Cntv.y = 0; Cntv.y < nnv.y; Cntv.y += 1)
      #for(Cntv.x = 0; Cntv.x < nnv.x; Cntv.x += 1)
        #local ThingArray[Cntv.x][Cntv.y][Cntv.z] =
          intersection {
            object { Thing }
            box { Point1 + dPoint*Cntv, Point1 + dPoint*(Cntv+Unitv) }
          }
      #end // for
    #end // for
  #end // for

  ThingArray

#end // macro ObjectSplit

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

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