POV-Ray : Newsgroups : povray.newusers : While Loop Help : Re: While Loop Help Server Time
30 Jul 2024 18:13:56 EDT (-0400)
  Re: While Loop Help  
From: Mike Williams
Date: 19 Oct 2003 00:16:59
Message: <CGssfBAe+gk$Ewly@econym.demon.co.uk>
Wasn't it Brent G who wrote:
> I can't figure out how to get the stupid while loops to create a 
>checkerboard shape :-/ This is what I've gotten so far (the MyGrass 
>Objects are both 5x5 shapes):
>
>#declare X = 0;
>#while (X <= 5)
>
>         #declare Z = 0;
>         #while(Z <= 6)
>
>                 object { MyGrass1 translate <-12.5-(X*5),0,1.9+(Z*5)> }
>                 object { MyGrass1 translate <12.5+(X*10),0,1.9+(Z*5)>  }
>
>                 #declare Z = Z + 2;
>         #end
>
>         #declare X = X + 2;
>#end

You might consider doing something like this:

#declare Chequer = union {
  object {MyGrass1}
  object {MyGrass2 translate <5,0,0>}
  object {MyGrass1 translate <5,0,5>}
  object {MyGrass2 translate <0,0,5>}
}

#declare X = 0;
#while (X <= 5)
   #declare Z = 0;
   #while(Z <= 6)
      object { Chequer translate <-12.5-(X*5),0,1.9+(Z*5)> }
      object { Chequer translate <12.5+(X*5),0,1.9+(Z*5)>  }
      #declare Z = Z + 2;
   #end
   #declare X = X + 2;
#end


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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