|
 |
So, as those playing from home know:
I am collecting all of the various functions, macros, small scenes, tricks,
tools, etc. into one place to serve as a master library / to-do list for
developing useful tools for new users and experienced alike, in order to make
SDL more useable and identify and highlight where features, syntax, and inbuilt
versions of externally included code would be desirable in POV-Ray 4.0.
Yesterday I went hunting for my bitwise operator macros, and number-base
conversion macros.
I am unable to find them. (which is weird)
I also distinctly recall coding an XOR pattern, yet I can find no image post on
these newsgroups for that. Nor can I find a scene file or rendered image in any
of my directories. :O
Does anyone recall that? Can you find that thread?
I think we ought to have a thread on things like this that we can recall, but
we're unable to find (the sources) . . .
- The render of the SDL text file with keyword highlighting
- The gorgeous rotating stone pyramid with SSLT
Anyway, as I was thinking about the XOR pattern, it's apparent that I didn't
make that as a pigment {function}} since I'm pretty sure all I wrote were
macros.
In order to do that, I'd need to convert the fractional decimal values of the
unit square to binary values, and then perform an XOR on the results of x and y.
But I can't do loops in functions.
Or CAN I . . .
I figure that if I declare a function with two arguments - the number I want to
convert, and a counter, then I can make it a recursive function, and decrement
the counter until it hits 0. then I can use select () to either return the
(binary) result of the last digit (which is all I need), or do another round.
I'm currently in the middle of other things, and have no access to a functional
POV-Ray parser to test the code, but I was wondering if this would work:
#declare D2B = function (digits, num) {
select (digits, 0, mod(num*2,1),
D2B (digits-1, floor(mod(num*2,1)))
)
}
#declare XOR = function (A, B) {select (A-B, 1, 0, 1)}
#declare Pattern = function {XOR (D2B(mod(x,1)), D2B(mod(y,1)))}
plane {z, 0 pigment {function {Pattern (x,y,z)}}}
Thanks for any help, rewriting, debugging, and test renders.
(and yes, mod in Pattern ought to be replaced with an fmod () that behaves
across the -N, 0, +N transition )
- BW
Post a reply to this message
|
 |