POV-Ray : Newsgroups : povray.general : Macro parameter type checking? Server Time
31 Jul 2024 04:24:14 EDT (-0400)
  Macro parameter type checking? (Message 1 to 3 of 3)  
From: Cousin Ricky
Subject: Macro parameter type checking?
Date: 5 Dec 2007 14:45:00
Message: <web.4756fc514f1c0e3f6a1b3c30@news.povray.org>
Is there any way or any trick for checking the type of a parameter from within a
macro?  For example, it would be useful to have a texture apply optionally to a
portion of a union:

#macro Neat_object (Param1, Param2, Texture)
   union
   {  object { ... }
      object
      {  ...
         #if ( /* Texture is really a texture and not the float value 0 */ )
            texture { Texture }
         #end
      }
   }
#end

Since macro arguments must be defined, #ifdef is useless here.  Another common
situation would be passing in a color or a texture:

texture
{  #if ( /* Texture is a vector */ )
      pigment { color Texture }
   #else
      Texture
   #end
}


Post a reply to this message

From: Jan Dvorak
Subject: Re: Macro parameter type checking?
Date: 5 Dec 2007 16:11:15
Message: <475713f3$1@news.povray.org>
Cousin Ricky napsal(a):
> Is there any way or any trick for checking the type of a parameter from within a
> macro?  For example, it would be useful to have a texture apply optionally to a
> portion of a union:
> 
> #macro Neat_object (Param1, Param2, Texture)
>    union
>    {  object { ... }
>       object
>       {  ...
>          #if ( /* Texture is really a texture and not the float value 0 */ )
>             texture { Texture }
>          #end
>       }
>    }
> #end
> 
> Since macro arguments must be defined, #ifdef is useless here.  Another common
> situation would be passing in a color or a texture:
> 
> texture
> {  #if ( /* Texture is a vector */ )
>       pigment { color Texture }
>    #else
>       Texture
>    #end
> }
> 
> 
> 
> 
It's not possible in pure pov-ray but it is possible int mega-pov. See 
2.2.6.5 in mega-pov documentation.


Post a reply to this message

From: Florian Brucker
Subject: Re: Macro parameter type checking?
Date: 6 Dec 2007 11:35:36
Message: <475824d8$1@news.povray.org>
Cousin Ricky wrote:
> For example, it would be useful to have a texture apply optionally to a
> portion of a union:
> 
> #macro Neat_object (Param1, Param2, Texture)
>    union
>    {  object { ... }
>       object
>       {  ...
>          #if ( /* Texture is really a texture and not the float value 0 */ )
>             texture { Texture }
>          #end
>       }
>    }
> #end

You could use the following workaround:

#macro Neat_object (Param1, Param2, Texture, UseTexture)
  union
    {  object { ... }
       object
       {  ...
       #if (UseTexture)
         texture { Texture }
       #end
     }
  }
#end

Neat_object(Foo, Bar, MightBeATexture, defined(MightBeATexture)


HTH,
Florian


Post a reply to this message

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