|
![](/i/fill.gif) |
"twister" <twi### [at] o2 pl> wrote:
> Hi all,
>
> Is there any possibility to write a #macro that returns spline by value? I have
> made such macro but I have to pass a parameter to the macro that will be a
> place for spline. I excpect something like that:
>
> #declare new_spline = createSpline(myArray);
>
> Now I have to do it like that:
>
> #declare new_spline = 0;
> createSpline(myArr, new_spline)
> //now I have new_spline initialized
>
> Thanks in advance,
> twister
I think for whatever reason, splines have to be global in order to return
correctly from inside a macro. For instance, in my array -> spline macro below,
if you try to return the local spline, POV-Ray will crash:
Charles
//Usage:
//#local MyNewSpline = Spline_From_Array(MyArray,MyArray_Length);
// The_Array should be an array of vectors 4D vectors in the form <x,y,z,t>
// where t is the position value along the spline to be created.
#macro Spline_From_Array(The_Array,Array_Length)
//POV-Ray crashes if this gets changed to #local:
#local ATempSpline = spline{
cubic_spline
#local Ctr = 0;
#while (Ctr < Array_Length)
#local Tempfloat = The_Array[Ctr].t; //avoids error on next line.
Tempfloat, <The_Array[Ctr].x, The_Array[Ctr].y, The_Array[Ctr].z>,
#local Ctr = Ctr+1;
#end //end while
}
//The returned spline must be global or POV-Ray will crash:
#declare ATempSpline_G = ATempSpline; //create a global variable
//ATempSpline //Don't return this spline or POV-Ray will crash!
ATempSpline_G //Return this spline
#end //end #macro Spline_From_Array(The_Array,Array_Length)
Post a reply to this message
|
![](/i/fill.gif) |