|
|
hi,
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:
#macro calcPoint(pv_,clock_)
#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_);
#end
and then pass the variable to some other macro to place the object, etc.
as always, comments, feedback, criticisms, all (equally) welcome.
enjoy, jr.
Post a reply to this message
Attachments:
Download 'pvars.inc.txt' (5 KB)
|
|
|
|
Op 28/03/2022 om 01:16 schreef jr:
> hi,
>
> 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.
>
Interesting stuff. I need to study this carefully as it could help me to
plant trees (or other objects) in a more streamlined way than what I do now.
--
Thomas
Post a reply to this message
|
|
|
|
hi,
Thomas de Groot <tho### [at] degrootorg> wrote:
> Op 28/03/2022 om 01:16 schreef jr:
> > the aim of 'pvars.inc' is ...
>
> Interesting stuff. I need to study this carefully as it could help me to
> plant trees (or other objects) in a more streamlined way than what I do now.
thanks v much for looking it over, hope the code will simply .. slot in.
attached is version 2. there was one typo (boolean misspelled) and the wrong
file name in the '#debug' (an oversight when renaming from "working title");
also took the opportunity to reformat 'pvClear()'.
regards, jr.
Post a reply to this message
Attachments:
Download 'pvars.inc.txt' (5 KB)
|
|