POV-Ray : Newsgroups : povray.newusers : Recursive #includes? : Recursive #includes? Server Time
29 Jul 2024 18:15:43 EDT (-0400)
  Recursive #includes?  
From: John
Date: 12 May 2005 02:00:05
Message: <web.4282f02eb4d902fd56675f080@news.povray.org>
Hi.  I have been studying some POV code lately and I am trying to figure out
how this works.  In my mind it would be an endless loop but it works.  Here
is a snippet of an older POV file from the IRTC site.  It's code to produce
a 3D Snowflake by Andreas Kahler.

The main file has this code to reference an #include file....

#declare TotalLevel = 4;

// the 3D snowflake
#render "nadding 3D snowflake...n"

#declare Tetra = intersection {
   plane {-y,1}
   plane {-z,1 rotate <19.47,    0, 0>}
   plane {-z,1 rotate <19.47, -120, 0>}
   plane {-z,1 rotate <19.47,  120, 0>}
   bounded_by { sphere { <0,0,0>, 3.0 }}
}

#declare level=TotalLevel - 1
union {
  object {
    Tetra
    rotate 180*x
    pigment {color rgb <0.1,0,0.7>}
    finish { ambient 0.1 diffuse 0.5 brilliance 1 phong 0.6 phong_size 60 }
  }
  #include "snowflak.inc"
  pigment {color rgb <0.9,0,0.1>}
  finish { ambient 0.1 diffuse 0.6 brilliance 1 phong 0.6 phong_size 60
reflection 0.1}
  scale 0.1
  rotate <90,30,0>
  translate <-0.7,0.9,0.7>
}

And the #include file "snowflak.inc"

#if (level > 0)
  #declare level = level - 1;

  object { Tetra }
  union {
    #include "snowflak.inc"
    scale 0.5
    translate -1.5*y
  }
  union {
    #include "snowflak.inc"
    scale 0.5
    translate -1.5*y
    rotate <0,180,0>
    rotate <109.47,0,0>
  }
  union {
    #include "snowflak.inc"
    scale 0.5
    translate -1.5*y
    rotate <0,180,0>
    rotate <109.47,120,0>
  }
  union {
    #include "snowflak.inc"
    scale 0.5
    translate -1.5*y
    rotate <0,180,0>
    rotate <109.47,-120,0>
  }

  #declare level = level + 1;

#else
  object { Tetra }
  object { Tetra }
#end


If anyone could tell me how this works I'd be grateful.

Thanks.
John


Post a reply to this message

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