the aim of 'pvars.inc' is to provide a way to reduce the number of global
variables used in one's POV-Ray scenes, and to have to hand a convenient "type"
much like a small 'array mixed', for related variables.
the "idea" came about from a (not infrequent) need to keep two index and one
boolean variable, for each of many objects. also perhaps influenced by BC's
"PROOF" threads, that is thinking about "abstractions" and such, and about one's
"footprint" in the global namespace.
a "packed variable" is simply a 4-vector where the four components can be
treated as individual variables/elements, addressed via a zero-based index.
the include file contains a small number of macros which make up the
"interface". visible (global) identifiers in the file are prefixed 'pv'.
POV-Ray's vector operands and functions will work as expected.
the "documentation" consists of a brief description of the macros in the include
file's header, and example usage in the scene code I will post in p.b.a. "Ulam
Spiral Fun" next.
as an example, say I want to animate a number of objects/shapes, and in each
frame need to calculate the new point where each object will be. my packed
variable might then be '<x,y,z,i>', where 'i' is an index for the 'shapes'
array. and to update the point, likely, I'd use a small macro, something like:
#local (x_,y_,z_,i_) = pvUnpack(pv_);
/* calc new x,y,z.
* can, of course, still use 'pv_.x' etc directly.
#local pv_ = pvPack(x_,y_,z_,i_);
and then pass the variable to some other macro to place the object, etc.
as always, comments, feedback, criticisms, all (equally) welcome.
Post a reply to this message
Download 'pvars.inc.txt' (5 KB)