POV-Ray : Newsgroups : povray.general : help w/simple macro : Re: help w/simple macro Server Time
9 Aug 2024 19:38:28 EDT (-0400)
  Re: help w/simple macro  
From: Tor Olav Kristensen
Date: 19 May 2000 18:47:18
Message: <3925C3DF.4A4F0913@hotmail.com>
Tor Olav Kristensen wrote:
> 
> 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
> }
> 

Now I have read your question thoroughly.
(as I should have done in the first place :)

And I have also tested your code.

Below you find the code for my new suggestion.
The "big" difference is the passing of the 
spike shape trough a variable; "Thing" to 
the macro.

(POV-Ray does not force you to do this, but
I think this is good programming practice.)


#macro Make_Grid(Thing, spacing, size)

  #local xCnt = 0;
  #while (xCnt < size)
    #local zCnt = 0;
    #while (zCnt < size)
      object {
        Thing
        translate spacing*<xCnt, 0, zCnt> 
      }
      #local zCnt = zCnt + 1;
    #end    
    #local xCnt = xCnt + 1;
  #end

#end


#declare Spike = cone { <0, 0, 0>, 0.2, <0, 1, 0>, 0 }

#declare Grid_1 = 
union {
  Make_Grid(Spike, 0.5, 6)
  pigment { color Yellow }
}

object {
  Grid_1
  rotate 45*x
  translate 3*y
}


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


PS:
You can also have the macro apply changes 
to the Thing object with #declare.
E.g.: In the macro you can say 

#declare Thing = object { Thing scale <1, 2, 1> }

And then after you have called the macro
the Spike will be twice as high as before.


Post a reply to this message

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