|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi there people,
First, apologies if I'm posting this in thewrong section, I'm pretty new to the
board.
I'm currently working on an animation interface to use within POV-Ray SDL files.
It is basically using the good old array-based structures, but I'd like to get
it to the next level and apply basic principles of Object-Oriented Programming
with POVRay.
For those of you who know about the thing, is there any way to pass macros ( and
by that I mean the real macro identifier, not a macro application ) as another
macro argument ? It would be kinda best way to infer the notion of "method" into
POVRay structures.
Thanks by advance,
Alex.
PS : my animation system is based on the use of multiple coordinate systems with
different origins, being transformed one regarding another. This allows easy
relative movement ( object 1 rotationg around object 2 which is translating
along the axis by which object 3 is oriented, where object 3 is an object
translated from origin and then rotated twice... You got the idea )
Post a reply to this message
|
|
| |
| |
|
|
From: Christian Froeschlin
Subject: Re: Passing macros as macro arguments ?
Date: 14 Jan 2010 17:44:27
Message: <4b4f9e4b$1@news.povray.org>
|
|
|
| |
| |
|
|
> First, apologies if I'm posting this in thewrong section, I'm pretty new to the
> board.
povray.general would have been appropriate. This section is
about about the programming *of* POV-Ray, not *in* POV-Ray.
> For those of you who know about the thing, is there any way to pass macros (and
> by that I mean the real macro identifier, not a macro application) as another
> macro argument ?
I was going to say it's not supported by the language, but you may
in fact bend the rules a little if you write each macro body into
a separate source file, so by passing the macro name you can then
actually include code as required.
I just made the following sample:
--- BEGIN mymacro.inc ---------------
// #macro mymacro(VALUE)
// Map generic parameter names to functional names
#local VALUE = P1;
// Actual macro body
#debug concat("MyMacro Invocation: ", str(VALUE,1,3), "\n")
--- END mymacro.inc ---------------
--- BEGIN user.pov ---------------
// Sample for misusing include files to allow passing macros as
// parameters to other macros.
// Note that both include file macro bodies and local
// macro wrappers need to follow a fixed naming convention
// such as P1,P2,P3,... for the parameter names. Of course,
// the number of parameters must be known in advance as it
// forms the signature contract for the expected macro.
// There may be restrictions regarding nesting and cycles.
#macro MetaMacro(MACRO_NAME,VALUE)
#macro LOCAL_MACRO(P1)
#include concat(MACRO_NAME,".inc")
#end
LOCAL_MACRO(VALUE)
#end
// Invocation
MetaMacro("mymacro",5)
--- END user.pov ---------------
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Christian Froeschlin <chr### [at] chrfrde> wrote:
> I was going to say it's not supported by the language, but you may
> in fact bend the rules a little if you write each macro body into
> a separate source file, so by passing the macro name you can then
> actually include code as required.
>
> I just made the following sample:
>
> --- BEGIN mymacro.inc ---------------
> // #macro mymacro(VALUE)
>
> // Map generic parameter names to functional names
> #local VALUE = P1;
>
> // Actual macro body
> #debug concat("MyMacro Invocation: ", str(VALUE,1,3), "\n")
> --- END mymacro.inc ---------------
>
>
> --- BEGIN user.pov ---------------
> // Sample for misusing include files to allow passing macros as
> // parameters to other macros.
>
> // Note that both include file macro bodies and local
> // macro wrappers need to follow a fixed naming convention
> // such as P1,P2,P3,... for the parameter names. Of course,
> // the number of parameters must be known in advance as it
> // forms the signature contract for the expected macro.
>
> // There may be restrictions regarding nesting and cycles.
>
> #macro MetaMacro(MACRO_NAME,VALUE)
>
> #macro LOCAL_MACRO(P1)
> #include concat(MACRO_NAME,".inc")
> #end
>
> LOCAL_MACRO(VALUE)
>
> #end
>
> // Invocation
>
> MetaMacro("mymacro",5)
> --- END user.pov ---------------
Seems very unpractical to me in the way I have to employ it, but still, good to
know that little trick ! Thanks for answering it.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|