POV-Ray : Newsgroups : povray.general : Q: Your scripting style : Re: Q: Your scripting style Server Time
8 Aug 2024 06:19:03 EDT (-0400)
  Re: Q: Your scripting style  
From: Ron Parker
Date: 12 Feb 2001 08:38:03
Message: <slrn98fpps.15n.ron.parker@fwi.com>
On Mon, 12 Feb 2001 13:53:52 +0100, Marc-Hendrik Bremer wrote:
>That works, but I find myself often scrolling about large parts of the
>scene, cause if I have to change the length of an iso-wood-beam, I have to
>change the rbox-function, too and so on. But if I group this function with
>the isosurface declaration, I break my block-scheme and it will probably be
>much harder to use the same function elsewhere.
>
>So, how are you doing these things?

I find that the best way to organize my code, though it takes a little
longer, is to generalize to the point of excess.  Macros are good for this,
as are good old fashioned include files.  I try to put everything that
has to do with a single physical object into one file, and everything that
has to do with the stage in another file, and finally include them all
into one big scene that's nothing more than #includes and object placement
and lighting and a camera.  I also try to have a test scene #ifdef'd at the
bottom of each include file, so I can preview the objects or the stage as
I model them.

Now, more about that "generalizing to the point of excess":  Basically, I
try to parameterize everything, so if that lamp needs to be a little taller
to fit in the scene, I just have to change one number and it becomes taller.
If it needs to be fatter, change one number and it's fatter.  This leads to 
a long list of variables at the beginning of the file, but it serves three
noble purposes:

First, it makes the object (which is in its own include file, remember) far
more portable to other scenes.  Reusability is good.

Second, it makes it very easy to use multiple variations of the same object
in the same scene without a lot of work, should that become necessary.

Third, it makes the object declaration itself far more readable, because
each magic number has a name that describes its purpose.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

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