POV-Ray : Newsgroups : povray.newusers : Macro help, please... Server Time
6 Nov 2024 08:16:32 EST (-0500)
  Macro help, please... (Message 1 to 6 of 6)  
From: Patrick Hagerty
Subject: Macro help, please...
Date: 21 Jan 1999 13:10:35
Message: <36A76E2D.C920A720@hagware.com>
I'm used to using macros in programming, but I can't seem to get the
hang of POV macros.  There seems to be some inconsistencies in how they
work.

For example:  If I choose to 'stub out' a macro and force a value
thusly..

#macro TestMacro()
  (1)
#end

... it works fine.  But, if I try to select from several values using a
switch statement thusly...

#macro TestMacro( xValue )
    #switch (xValue)
      #range (0,9)
         (0)
      #break
      #range (10, 19)
         (0.5)
      #break
      #else
         (1.0)
   #end
#end

... I get errors.

What I'm trying to do is calculate a color value [I'm using different
macros for fRed(), fGreen() and fBlue()] based upon a rotation value
(passed as xValue).  I'm using the macros in a statement like this:

    "color [rgb<fRed(xAngle), fGreen(xAngle), fBlue(xAngle)>]"

Any suggestions anyone can make would be greatly appreciated.


Patrick Hagerty
pat### [at] hagwarecom


Post a reply to this message

From: Ron Parker
Subject: Re: Macro help, please...
Date: 21 Jan 1999 13:40:37
Message: <36a774a5.0@news.povray.org>
On Thu, 21 Jan 1999 13:13:01 -0500, Patrick Hagerty <pat### [at] hagwarecom> wrote:
>    "color [rgb<fRed(xAngle), fGreen(xAngle), fBlue(xAngle)>]"

Are those square brackets really there in what you're using?  The
only place I've ever seen square brackets is in the various maps
(color_map, pigment_map, etc.)


Post a reply to this message

From: Patrick Hagerty
Subject: Re: Macro help, please...
Date: 21 Jan 1999 14:29:38
Message: <36A780B8.7E490C95@hagware.com>
No, as a matter of fact I totally screwed up the syntax.  I am actually using it in
a color_map, but I tried to short-cut the syntax for the purposes of illustration.
The actual code is:

    color_map
    {
        [0 rgbt <fRed(xAngle), fGreen(xAngle), fBlue(xAngle), 0>]
        [1 rgbt <fRed(xAngle), fGreen(xAngle), fBlue(xAngle), 1>]
    }

Sorry for the confusion.

Patrick

Ron Parker wrote:

> On Thu, 21 Jan 1999 13:13:01 -0500, Patrick Hagerty <pat### [at] hagwarecom> wrote:
> >    "color [rgb<fRed(xAngle), fGreen(xAngle), fBlue(xAngle)>]"
>
> Are those square brackets really there in what you're using?  The
> only place I've ever seen square brackets is in the various maps
> (color_map, pigment_map, etc.)


Post a reply to this message

From: Ron Parker
Subject: Re: Macro help, please...
Date: 21 Jan 1999 15:52:03
Message: <36a79373.0@news.povray.org>
On Thu, 21 Jan 1999 13:13:01 -0500, Patrick Hagerty <pat### [at] hagwarecom> wrote:
>What I'm trying to do is calculate a color value [I'm using different
>macros for fRed(), fGreen() and fBlue()] based upon a rotation value
>(passed as xValue).  I'm using the macros in a statement like this:
>
>    "color [rgb<fRed(xAngle), fGreen(xAngle), fBlue(xAngle)>]"
>
>Any suggestions anyone can make would be greatly appreciated.

I tried the implementation of TestMacro that you posted, and I 
can use it without problems in the following code:

#declare xangle=11;
#declare yangle=5;
#declare zangle=20;              

sphere {0,1 
  texture {
    pigment {
      gradient y 
      color_map {
        [0 rgb <TestMacro(xangle),TestMacro(yangle),TestMacro(zangle)>]
        [1 rgb 1]
      }
    }
  }
}

Perhaps you could post the exact code of one of your macros, or 
tell us what error you're getting.


Post a reply to this message

From: gemelli david
Subject: Re: Macro help, please...
Date: 22 Jan 1999 04:01:38
Message: <36A83E64.F358E587@imerir.asso.fr>
I had the same problem in my Particles Generator file. So I used a variable to
return the value.

#macro MyMacro(value, return)
    #switch (value)
        #case (0)
            #declare return = value * 20;
        #break
        #case (1)
            #declare return = value *10;
        #break
#end
Hope it helps !

            David GEMELLI


Post a reply to this message

From: Patrick Hagerty
Subject: Re: Macro help, please...
Date: 22 Jan 1999 10:20:12
Message: <36A897C3.91939F9A@hagware.com>
Well, I'm red-faced.  I can't for the life of me figure out what happened.  As a
result of your message I revisited my source and what I thought didn't work is now
working.  Maybe I had a typo that I hadn't noticed before or something, but
everything is working as I wanted it too.

Thanks for your comments.  I really appreciate your taking the time to help me while
I worked through this.

Patrick
pat### [at] hagwarecom

Ron Parker wrote:

> On Thu, 21 Jan 1999 13:13:01 -0500, Patrick Hagerty <pat### [at] hagwarecom> wrote:
> >What I'm trying to do is calculate a color value [I'm using different
> >macros for fRed(), fGreen() and fBlue()] based upon a rotation value
> >(passed as xValue).  I'm using the macros in a statement like this:
> >
> >    "color [rgb<fRed(xAngle), fGreen(xAngle), fBlue(xAngle)>]"
> >
> >Any suggestions anyone can make would be greatly appreciated.
>
> I tried the implementation of TestMacro that you posted, and I
> can use it without problems in the following code:
>
> #declare xangle=11;
> #declare yangle=5;
> #declare zangle=20;
>
> sphere {0,1
>   texture {
>     pigment {
>       gradient y
>       color_map {
>         [0 rgb <TestMacro(xangle),TestMacro(yangle),TestMacro(zangle)>]
>         [1 rgb 1]
>       }
>     }
>   }
> }
>
> Perhaps you could post the exact code of one of your macros, or
> tell us what error you're getting.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.