|
|
|
|
|
|
| |
| |
|
|
From: David Wallace
Subject: #include files in macros undefine the parameters
Date: 30 Mar 2002 08:54:50
Message: <3ca5c3aa@news.povray.org>
|
|
|
| |
| |
|
|
Put this in one file,
----------------
#macro MakePara(ip,op)
#include ip
#debug concat("Initializing ",op," data...\n")
#end
MakePara("stormdef.inc", "storm.inc")
----------------
and this in "stormdef.inc"
----------------
#declare uMin = 0; // Minimum u value
#declare uMax = radians(180); // Maximum u value
#declare uNum = 90; // Number of points in u direction
#declare uWrap = 0; // u wraps around if != 0
#declare uSeed = 2252; // Random number seed for u parameter
#declare vMin = 0; // Minimum v value
#declare vMax = radians(358); // Maximum v value
#declare vNum = 180; // Number of points in v direction
#declare vWrap = 1; // v wraps around if != 0
#declare vSeed = 7335; // Random number seed for v parameter
#declare IsRnd = false; // True if random number used
#declare Detail = "Partial"
// Optional variables and subfunctions
#declare fnDimp = function { pattern {
granite
warp {
black_hole 0, 2
strength 0.4
inverse
}
} } #end
// point function
#macro pnt(i, j, p, q)
#local rd = sin(i)*(sin(6*j)+1.1);
#local xp = rd*cos(j);
#local yp = cos(i);
#local zp = rd*sin(j);
#local dp = <9,2,9>*(1+fnDimp(xp,yp,zp)*.02);
#local pt0 = <xp,yp,zp>*dp;
#local pt1 = vrotate(pt0, y*rd*90);
pt1
#end
#declare Smooth = 0; // Smooth flag
----------------
Bad things happen. Specifically, I suspect that any attempt to include a
file within a macro undefines the parameters sent to it. Some of my more
complex attempts were able to access the parameters just before but not
after the include.
Intel Beta 14, Duron 800MHz, 512MB DDR, Win98SE
Post a reply to this message
|
|
| |
| |
|
|
From: Tor Olav Kristensen
Subject: Re: #include files in macros undefine the parameters
Date: 30 Mar 2002 13:31:08
Message: <3ca6046c$1@news.povray.org>
|
|
|
| |
| |
|
|
I have not tested your code, but I suspect that the
extra #end after your fnDimp declaration is
causing this trouble.
The macro declaration is ended prematurely.
And therefore this line:
#debug concat("Initializing ",op," data...\n")
- is actually outside the macro, where the op
parameter is not defined
Tor Olav
David Wallace <dar### [at] earthlinknet> wrote in message
news:3ca5c3aa@news.povray.org...
> Put this in one file,
> ----------------
> #macro MakePara(ip,op)
> #include ip
> #debug concat("Initializing ",op," data...\n")
> #end
>
> MakePara("stormdef.inc", "storm.inc")
> ----------------
> and this in "stormdef.inc"
> ----------------
> #declare uMin = 0; // Minimum u value
> #declare uMax = radians(180); // Maximum u value
> #declare uNum = 90; // Number of points in u direction
> #declare uWrap = 0; // u wraps around if != 0
> #declare uSeed = 2252; // Random number seed for u parameter
>
> #declare vMin = 0; // Minimum v value
> #declare vMax = radians(358); // Maximum v value
> #declare vNum = 180; // Number of points in v direction
> #declare vWrap = 1; // v wraps around if != 0
> #declare vSeed = 7335; // Random number seed for v parameter
>
> #declare IsRnd = false; // True if random number used
>
> #declare Detail = "Partial"
>
> // Optional variables and subfunctions
> #declare fnDimp = function { pattern {
> granite
> warp {
> black_hole 0, 2
> strength 0.4
> inverse
> }
> } } #end
>
> // point function
> #macro pnt(i, j, p, q)
> #local rd = sin(i)*(sin(6*j)+1.1);
> #local xp = rd*cos(j);
> #local yp = cos(i);
> #local zp = rd*sin(j);
> #local dp = <9,2,9>*(1+fnDimp(xp,yp,zp)*.02);
> #local pt0 = <xp,yp,zp>*dp;
> #local pt1 = vrotate(pt0, y*rd*90);
> pt1
> #end
>
> #declare Smooth = 0; // Smooth flag
> ----------------
> Bad things happen. Specifically, I suspect that any attempt to include a
> file within a macro undefines the parameters sent to it. Some of my more
> complex attempts were able to access the parameters just before but not
> after the include.
>
> Intel Beta 14, Duron 800MHz, 512MB DDR, Win98SE
>
>
>
Post a reply to this message
|
|
| |
| |
|
|
From: Tor Olav Kristensen
Subject: Re: #include files in macros undefine the parameters
Date: 30 Mar 2002 13:54:58
Message: <3ca60a02$1@news.povray.org>
|
|
|
| |
| |
|
|
David Wallace <dar### [at] earthlinknet> wrote in message
news:3ca5c3aa@news.povray.org...
>...
> // point function
> #macro pnt(i, j, p, q)
> #local rd = sin(i)*(sin(6*j)+1.1);
> #local xp = rd*cos(j);
> #local yp = cos(i);
> #local zp = rd*sin(j);
> #local dp = <9,2,9>*(1+fnDimp(xp,yp,zp)*.02);
> #local pt0 = <xp,yp,zp>*dp;
> #local pt1 = vrotate(pt0, y*rd*90);
> pt1
> #end
>...
If you are returning a local variable that is either
a number or a vector from a macro, then I
recommend that you put brackets around it,
like this:
(pt1)
By doing so, you are avoiding problems with
this bug:
* Macro bug (job000146)
http://news.povray.org/povray.beta-test/22807/
Here's a direct link to the bug-report:
http://news.povray.org/povray.beta-test/18763/121582/
In your macro above, another way of avoiding
this bug, is to return this expression instead of
a local variable:
vrotate(pt0, y*rd*90)
Like this:
#macro pnt(i, j, p, q)
#local rd = sin(i)*(sin(6*j)+1.1);
#local xp = rd*cos(j);
#local yp = cos(i);
#local zp = rd*sin(j);
#local dp = <9,2,9>*(1+fnDimp(xp,yp,zp)*.02);
#local pt0 = <xp,yp,zp>*dp;
vrotate(pt0, y*rd*90)
#end
And finally:
I recommend you to only use variable names
that have at least one capital letter in them.
IIRC this is because any/many lower case
words may be used as reserved words in
future POV versions.
Tor Olav
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|