![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
I've created a pigment type which depends on a variable, n. If I
#declare n before the pigment code, it runs correctly.
However, I would like to be able to call this pigment type many times,
with different values of n. I thought that I could simply remove the
#declare before the pigment code, and use the code like:
texture { #declare n=1
PigmentName
}
texture { #declare n=2
PigmentName
}
However, POV complains that n is undefined when it first encounters the
code.
How can I use the pigment code as a procedure, called with the variable?
I've tried #macro, but haven't gotton anything working.
Thanks!
Simon
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <39AC2738.5D9668D1@istar.ca>, sde### [at] istar ca wrote:
> I've created a pigment type which depends on a variable, n. If I
> #declare n before the pigment code, it runs correctly.
>
> However, I would like to be able to call this pigment type many times,
> with different values of n. I thought that I could simply remove the
> #declare before the pigment code, and use the code like:
You aren't "calling a pigment type", you are creating a copy of a
variable which has already been parsed.
> How can I use the pigment code as a procedure, called with the variable?
> I've tried #macro, but haven't gotton anything working.
The macro feature is what you want. Just wrap the pigment definition in
a macro statement and use the parameters to specify your variables. What
were you trying to do?
#macro Radial(Rays, ClrA, ClrB)
pigment {radial
frequency Rays
color_map {
[0 color ClrA]
[1 color ClrB]
}
}
#end
--
Christopher James Huff
Personal: chr### [at] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Chris Huff wrote:
> #macro Radial(Rays, ClrA, ClrB)
> pigment {radial
> frequency Rays
> color_map {
> [0 color ClrA]
> [1 color ClrB]
> }
> }
> #end
I'm using something nearly identical, but it is still not working.
My code is of the form:
#macro PigmentFunc (n)
#declare Pigment = pigment { bla bla n bla bla }
#end
I then try to call it by using:
PigmentFunc (0.5)
texture {Pigment}
However, Pov still complains when it gets to the first line of the code which
contains the n variable, saying "numeric expression expected but undeclared
identifier 'n' found instead."
Am I missing something fundamental here? Would there be any benifit in my
posing the code?
Simon
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
some single letters have been taken over by megapov as reserved words.
try making n a real word like my_n_variable to eliminate the possiblity
of conflict.
J Charter wrote:
>
> >
> > >#macro PigmentFunc (n)
> > #declare Pigment = pigment { bla bla n bla bla }
> > #end
> >
> >
> >
> > PigmentFunc (0.5)
> > texture {Pigment}
> >
>
> I take it you tried:
>
> n=0.5;
> PigmentFunc(n)
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <39AC60D1.D4A0E968@istar.ca>, sde### [at] istar ca wrote:
> However, Pov still complains when it gets to the first line of the
> code which contains the n variable, saying "numeric expression
> expected but undeclared identifier 'n' found instead."
This sounds like a typo somewhere. Make sure you use an upper-case
letter in all variables to avoid conflicts with keywords, and make sure
you use the same variable name in the pigment as you used in the macro
parameter list.
> Am I missing something fundamental here?
Try something more like this:
#macro PigmentFunc (n)
pigment { bla bla n bla bla }
#end
...
texture {PigmentFunc(0.5)}
You can also use the macro to declare a pigment, like this:
#declare MyPigment = PigmentFunc(0.35)
> Would there be any benifit in my posing the code?
It would help us to find what exactly is wrong with it, but you seem to
be doing it in a round-about way, you might want to completely change
the way you are doing it.
--
Christopher James Huff
Personal: chr### [at] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Wasn't it Simon de Vet who wrote:
>My code is of the form:
>
>#macro PigmentFunc (n)
> #declare Pigment = pigment { bla bla n bla bla }
>#end
>
>I then try to call it by using:
>
>PigmentFunc (0.5)
>texture {Pigment}
>
>
>However, Pov still complains when it gets to the first line of the code which
>contains the n variable, saying "numeric expression expected but undeclared
>identifier 'n' found instead."
>
>Am I missing something fundamental here? Would there be any benifit in my
>posing the code?
The problem is somewhere else, in part of the code that you're not
describing. The syntax you describe above works perfectly for me, e.g.
#macro PigmentFunc (n)
#declare Pigment = pigment{rgb <n,n,0>}
#end
PigmentFunc (0.2)
sphere{-x,1
texture{Pigment}
}
PigmentFunc(0.5)
sphere{0,1
texture{Pigment}
}
PigmentFunc(0.9)
sphere{x,1
texture{Pigment}
}
Works perfectly, though it might have been simpler to code it more like
this:-
#macro PigFun (n)
rgb <n,n,0>
#end
sphere {y,1 texture{pigment{PigFun(0.1)}}}
sphere {-y,1 texture{pigment{PigFun(0.9)}}}
Are you using the official POVRay, or MEGAPov? There can sometimes be
strange behaviour in MEGAPov in the following circumstances:
If you declare a #macro inside a #while loop.
If you declare one #macro inside another #macro declaration.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |