POV-Ray : Newsgroups : povray.general : "To Render" pointer in include files. : Re: "To Render" pointer in include files. Server Time
1 Aug 2024 22:19:21 EDT (-0400)
  Re: "To Render" pointer in include files.  
From: Mike Williams
Date: 28 Mar 2005 06:37:36
Message: <w54$RDAYx+RCFw+5@econym.demon.co.uk>
Wasn't it brandon who wrote:
>Just an idea for a possible feature.
>
>I'm often stuck tunning some parameter in an include file. It'd be nice if
>there were some way to "point" POV-Ray to the actual source to render
>rather than the include. That way, I wouldn't have to modify, switch back
>to main pov file, render, switch back to include, repeat.
>
>So, in someinclude.inc I would put something like:
>#render "myfile.pov"
>If I tried to render the include file, it would render myfile.pov instead.
>
>I know...I'm lazy.


Such functionality is already available. The thing to notice is that POV
doesn't distinguish a .POV file from a .INC file, so you can just as
easily #include the POV from the INC.

If you #include in both directions, you get into a loop, unless you
#declare variables to manage the control flow.

It's possible to code things slightly simpler than this example if you
are willing to lose some flexibility in the order in which the code gets
executed, and whether you can call the include file more than once, but
the method used in this example gives you total flexibility.

// --- FOO.POV ------------------------------------------
#declare Foo_Pov_Temp = 1;

#version 3.6;
global_settings {assumed_gamma 1.0}
camera {location  <0,0,-10> look_at <0,0,0> angle 30}
background {rgb 1}
light_source {<-30, 100, -30> color rgb 1}

#declare T = texture{pigment {rgb 1}}
#include "bar.inc"
object {Thing}

#declare T=texture{pigment {rgb x}}
#include "bar.inc"
object {Thing translate x}
//-------------------------------------------------------


// --- BAR.INC ------------------------------------------
#ifndef(Foo_Pov_Temp)
  #include "foo.pov"
#else
  // Replace this with your included code
  #declare Thing = sphere {0,1 texture {T}}
#end
//-------------------------------------------------------

If you run FOO.POV, it sets the special variable. When BAR.INC gets
called it checks the special variable, and since it is defined, it
performs the included code.

If you run BAR.POV, it checks the special variable. In this case it is
defined, so it calls FOO.POV and skips the included code. Then FOO.POV
calls BAR.INC with the special variable defined and the included code
gets performed.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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