POV-Ray : Newsgroups : povray.general : help w/simple macro : Re: help w/simple macro Server Time
9 Aug 2024 19:38:51 EDT (-0400)
  Re: help w/simple macro  
From: Tor Olav Kristensen
Date: 19 May 2000 17:44:50
Message: <3925B53F.DD41BC62@hotmail.com>
ross litscher wrote:
> 
> Hi, ive recently been trying to ween myself off modellers and do some
> hand coding. So I made a simple macro as practice, well.. it's short so
> here it is. (my_spike is just a cone really)
> 
> #macro Make_Grid (spacing, size)
> 
>         #local grid = 0;
>         #while (grid < size)
> 
>                 #local zee = spacing * grid;
>                 #local copy = 0;
> 
>                 #while (copy < size)
>                 object {
>                         my_spike
>                         translate <spacing*copy, 0, zee>
>                         }
>                 #local copy = copy + 1;
>                 #end
> 
>         #local grid = grid + 1;
>         #end
>         //A cheap fix for it not putting a cone at <0,0,0>
>         object { my_spike }
> #end
> 
> then i do:
> 
> #declare Grid_1 = Make_Grid(.5, 2)
> 
> and this renders and all. But how do I do anything with Grid_1 now? Say
> I want to
> rotate it 45*x and translate it 3*y.
> 
> Am I doing things at all close to correct? Thanks for the help...
> 
> Ross


I have not tried your code, 
but as far as I can see it looks OK.

Now you just have to change your last #declare to this

#declare Grid_1 = 
union {
  Make_Grid(.5, 2)
  rotate 45*x
  translate 3*y
}



You could also have done this:

#macro Make_Grid(spacing, size)

  union {
    // place the rest of your 
    // macro code here
  }

#end // macro Make_Grid


And then the last declare could/should 
be done like this:

#declare Grid_1 = 
object {
  Make_Grid(.5, 2)
  rotate 45*x
  translate 3*y
}




And (of coarse) you can use other CSG operators instead of union


Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

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