|
|
Wasn't it Kevin Loney who wrote:
>two things, is it possible to return a 2 dimensional array from macro, and
>then assign it to another matrix? povray won't let me do this and I'm not
>sure if there is a way to do it. there is nothing on it in the docs.
>
>eg.
>currentPositions = evaluateInitialPositions( lengthSegs, widthSegs, clothL,
>clothW, randomness )
>
>currentPositions and the value returned from evaluateInitialPositions both
>have the same dimensions
I think your problem lies in the fact that you expect a macro to
*return* something (like a function in C++). In POV code, a macro
doesn't return anything it just *is* something.
The following code works.
#macro Fred(A,B)
array[2][2]{{0,A},{2,B}}
#end
#declare Jim = Fred(1,3)
You don't need to pre-declare Jim as a 2d array. It even works if you
had previously declared Jim to be a completely different data type.
Another way of thinking about what POV macros return would be to
consider that Fred(1,3) doesn't return an array, it returns the *text*
"array[2][2]{{0,1}{2,3}}", which then gets parsed as if you had typed
"#declare Jim = array[2][2]{{0,1}{2,3}}". This is very different from
what happens in C++ function.
>second question, is there anyway to set up a refernece parameter in a macro?
>for example in c++ you add an ampersand(&) infront of the variable in the
>function definition
I reckon that such a concept is meaningless in the context of POV
macros.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|