POV-Ray : Newsgroups : povray.text.scene-files : Recursive image macro Server Time
31 Oct 2024 14:11:07 EDT (-0400)
  Recursive image macro (Message 1 to 2 of 2)  
From: Nieminen Juha
Subject: Recursive image macro
Date: 31 Dec 1999 05:30:13
Message: <386c85b5@news.povray.org>
Everyone has probably seen an image where there's a painting or a
photo of the image itself. The painting/photo in the image has also the
image itself, and so on, to the infinity.
  I made a little macro to help making this kind of images. The usage is
pretty simple. Use it in a pigment-block as if it were an image_map (well,
actually it is that). For example:

box { 0,<1,1,.1> pigment { RecPigment("example") } scale <4/3,1,1> }

  The parameter to the macro is the name of the current file without
extension (ie. example.pov in this case).
  Then set the final frame number to a desired value. The last frame
calculated will be the resulting image. (The easiest way would be setting
for example +kff10 in the command line (field)).
  The first pigment will be just "rgb 0" but the next pigments will be the
previously calculated frame.

  The macro assumes by default that the output file type is TGA. If you use
another output file type you can either change the values in the macro or
you can set an identifier and a macro for this. For example, if your output
image type is PNG you can set these two:
  #declare OutputFilenameType=".png"
  #macro OutputImageType() png #end

  Here is the macro and an example scene. A final frame number of 5 will
be enough for this scene.

//--------------------------------------------------------------------------
#macro RecPigment(filename)
  #if(clock=0)
    rgb 0
  #else
    #local frames = 1/clock_delta;
    #local digits = int(log(frames)/log(10))+1;
    #local framenumber = clock/clock_delta+1;
    #if(strlen(filename)+digits > 8)
      #local filename = substr(filename, 1, 8-digits)
    #end
    #ifndef(OutputFilenameType) #local OutputFilenameType=".tga" #end
    #ifndef(OutputImageType) #macro OutputImageType() tga #end #end
    #local imagename =
      concat(filename, str(framenumber-1, -digits, 0), OutputFilenameType)
    #debug concat("Reading image: ", imagename, "\n")
    image_map { OutputImageType() imagename interpolate 2 }
  #end
#end

//----

camera { location <-2,.5,-5> look_at y*.5 angle 35 }
light_source { <20,50,-150> 1 }

box { <-3,0,-2><3,-1,2> pigment { rgb <1,.8,.3> } }
cylinder { 0,y,.25 pigment { rgb y } finish { specular .5 } translate x }
sphere { y*.3, .3 pigment { rgb x } finish { specular .5 } }
plane
{ -y,-500
  pigment { bozo color_map { [0 rgb 1][1 rgb z] } turbulence .5 scale 1000 }
  finish { ambient 1 }
}
union
{ box
  { 0,<1,1,.1>
    pigment { RecPigment("Recursion") }
  }
  box { <-.1,-.1,.01><1.1,1.1,.11> pigment { rgb x } } 
  scale <4/3,1,1>
  translate -x*.5 rotate y*-20 translate -x*1.1+y*.1
}
//--------------------------------------------------------------------------

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Bill DeWitt
Subject: Re: Recursive image macro
Date: 31 Dec 1999 10:21:54
Message: <386cca12@news.povray.org>
That's kinda fun... add a separate one with spherical and one with
cylindrical mapping for added fun...


Post a reply to this message

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