POV-Ray : Newsgroups : povray.general : Explanation of recursive macros. : Re: Explanation of recursive macros. Server Time
8 Aug 2024 22:16:12 EDT (-0400)
  Re: Explanation of recursive macros.  
From: Gilles Tran
Date: 12 Sep 2000 15:47:06
Message: <39BE87B6.90917B5C@inapg.inra.fr>
BigCeef wrote:

> Would some kind person be willing to explain to me how to, say, build a
> branch that splits into twigs a couple of levels? Or point me toward a
> tutorial that would serve my purposes?

Explaining I don't know, but the code below is as simple as possible so it may
be self-explanatory (I hope).
#version 3.1
camera{location  -z*4  direction 1.5*z  right     4/3*x  look_at  0}
light_source{<-1,1,-1>*100 rgb 1}
#macro Recurs(L)
union{
#if (L>0)
    #local M=L-1;
    cylinder{0,y,0.1}
    object{Recurs(M) rotate z*45 translate y}
    object{Recurs(M) rotate -z*45 translate y}
#end
}
#end
object{Recurs(4) scale 0.5 translate -y pigment{rgb x}}

G.


Post a reply to this message

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