POV-Ray : Newsgroups : povray.text.tutorials : Q: Macro tutorial? Server Time
28 Mar 2024 10:26:12 EDT (-0400)
  Q: Macro tutorial? (Message 1 to 9 of 9)  
From: Børge Berg-Olsen
Subject: Q: Macro tutorial?
Date: 30 Jan 2000 14:13:35
Message: <38948CE7.EA06B171@dod.no>
Hi there,

Was wondering if there is a macro tutorial out there somewhere,
something else than the scene-language description of the povray
documentation.

Thanks!

-- 

------------------------------------------------------------------------
  +47 90 62 71 78        DoD#2101, NIC#015, Ducati M600, PJ#006, OGM#007
  azo### [at] dodno, "Do one thing every day that scares you." --Mary Schmich


Post a reply to this message

From: Nieminen Juha
Subject: Re: Q: Macro tutorial?
Date: 30 Jan 2000 14:21:43
Message: <38948f47@news.povray.org>

: Was wondering if there is a macro tutorial out there somewhere,
: something else than the scene-language description of the povray
: documentation.

  What do you mean by macro tutorial?
  When you say "macro", do you mean how to use the #macro feature of POV-Ray,
or do you mean how to make throughoutly useful include files? (I think that
the term "macro" is widely used to refer to any pov-script utility although
it may not use any #macro declaration.)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Ken
Subject: Re: Q: Macro tutorial?
Date: 30 Jan 2000 15:09:42
Message: <38949A61.505CEAC4@pacbell.net>
Nieminen Juha wrote:
> 

> : Was wondering if there is a macro tutorial out there somewhere,
> : something else than the scene-language description of the povray
> : documentation.
> 
>   What do you mean by macro tutorial?

I personally do not know of any online tutorials on how to make a
POV-Ray macro and doubt anyone could really explain all of their
possibilities in depth.

  When macros were first introduced Chris Colefax took a little
time to explain them to me and failed miserably - my fault not his.
In my opinion the best way to learn how macros work is by example.
On my web page you can download a .zip file that has many macros
with examples of how they are used. I would suggest you download
the file, take a look at how the macros are structured, how they
are used, and then try to write a very basic macro based on what
you learned. As you become more proficient with them you can get
more and more complicated with them.

 Since most macros rely heavily on math operations your ability
to use them will vary with your math skills and your knowledge
of POV-Ray's built in functions. A basic knowledge of programming
wouldn't hurt either but it not entirely necessary -  I am a
living example of that and have made a couple of useful macros
since they were introduced. Just learning how to use someone
else's macros will help you understand how they work.

  The most important thing to learn about macros is that all they
really do is to pass parameters to functions used by POV-Ray and
make it easy for the person using the macro to quickly change
variables when needed. You can eliminate a lot of declared variables
commonly found in a .inc file by using a macro instead.


-- 
Ken Tyler -  1300+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Jerry
Subject: Re: Q: Macro tutorial?
Date: 31 Jan 2000 13:46:34
Message: <jerry-3AEA64.10463131012000@news.povray.org>
In article <38949A61.505CEAC4@pacbell.net>, lin### [at] povrayorg 
wrote:
>I personally do not know of any online tutorials on how to make a
>POV-Ray macro and doubt anyone could really explain all of their
>possibilities in depth.

As all of my tutorials, this one is very basic, but it does cover an 
example macro. http://www.hoboes.com/html/NetLife/POV/Scripting/

Jerry


Post a reply to this message

From: Ken
Subject: Re: Q: Macro tutorial?
Date: 31 Jan 2000 13:55:04
Message: <3895DA7F.6F1F35@pacbell.net>
Jerry wrote:
> 
> In article <38949A61.505CEAC4@pacbell.net>, lin### [at] povrayorg
> wrote:
> >I personally do not know of any online tutorials on how to make a
> >POV-Ray macro and doubt anyone could really explain all of their
> >possibilities in depth.
> 
> As all of my tutorials, this one is very basic, but it does cover an
> example macro. http://www.hoboes.com/html/NetLife/POV/Scripting/
> 
> Jerry

It is descriptive enough that I will add it to the tutorials section
at http://www.povray.org/links

Thanks for making me aware of it.

-- 
Ken Tyler -  1300+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Børge Berg-Olsen
Subject: Re: Q: Macro tutorial?
Date: 31 Jan 2000 16:34:24
Message: <3895FF63.BCCEC19C@dod.no>
Jerry wrote:
> 
> In article <38949A61.505CEAC4@pacbell.net>, lin### [at] povrayorg
> wrote:
> >I personally do not know of any online tutorials on how to make a
> >POV-Ray macro and doubt anyone could really explain all of their
> >possibilities in depth.
> 
> As all of my tutorials, this one is very basic, but it does cover an
> example macro. http://www.hoboes.com/html/NetLife/POV/Scripting/

Nice one, thanks a lot. Just what I was looking for! ;-)

-- 

------------------------------------------------------------------------
  +47 90 62 71 78        DoD#2101, NIC#015, Ducati M600, PJ#006, OGM#007
  azo### [at] dodno, "Do one thing every day that scares you." --Mary Schmich


Post a reply to this message

From: Børge Berg-Olsen
Subject: Re: Q: Macro tutorial?
Date: 31 Jan 2000 16:46:05
Message: <38960220.69C3F824@dod.no>
Nieminen Juha wrote:
> 

> : Was wondering if there is a macro tutorial out there somewhere,
> : something else than the scene-language description of the povray
> : documentation.
> 
>   What do you mean by macro tutorial?

Sorry for not being specific enough. I want to learn how to use and make
functions for automating tedious tasks in povray.

I've read the thread and will look up Jerry's page with the basic
tutorial.

>   When you say "macro", do you mean how to use the #macro feature of POV-Ray,
> or do you mean how to make throughoutly useful include files? 

Both, actually ;-)

> (I think that
> the term "macro" is widely used to refer to any pov-script utility although
> it may not use any #macro declaration.)

Well, true ... my question was ambigous, sorry again.

-- 

------------------------------------------------------------------------
  +47 90 62 71 78        DoD#2101, NIC#015, Ducati M600, PJ#006, OGM#007
  azo### [at] dodno, "Do one thing every day that scares you." --Mary Schmich


Post a reply to this message

From: Nieminen Juha
Subject: Re: Q: Macro tutorial?
Date: 1 Feb 2000 04:23:49
Message: <3896a625@news.povray.org>
Jerry's tutorial is good. If you want a short answer, I'll try to write
something:

  If you have ever coded in C or C++, macros are like #defines which take
arguments. The general syntax is:

#macro MyMacro(argument1, argument2, argument3)
  (some pov-script here)
#end

  There can be any number of arguments. These can be used to generate the
pov-script. For example:

#macro WhiteSphere(Location, Radius)
  sphere { Location, Radius pigment { rgb 1 } }
#end

  Now if you write:

WhiteSphere(<1,2,3>, 4)

the povray parser will internally substitute with the following:

sphere { <1,2,3>, 4 pigment { rgb 1 } }

  You could also use macros as functions. For example:

#macro Double(Var)
  (Var)*2
#end

  Now if you type something like:

#declare Radius = Double(3);

it will be the same as:

#declare Radius = (3)*2;

  (Note the parentheses; guess why they are important?)


  Sometimes one wants a kind of return value from a complex calculation.
It can be achieved like this:

#macro ComplexCalculation(A, B, C)
  #local result = 0;
  #while(A>0)
    #local result = result + B*C;
    #local A = A-1;
  #end
  result
#end

  Note the last line which only has the identifier 'result' in it. It means
that the value of the whole macro will be the value of 'result' at the end
of the macro. Now you can use ComplexCalculation() as any other function.

  (Ok, this is not a very short answer after all...)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Børge Berg-Olsen
Subject: Re: Q: Macro tutorial?
Date: 1 Feb 2000 04:43:06
Message: <3896AA28.CCB55BE1@dod.no>
Nieminen Juha wrote:
> 
>   Jerry's tutorial is good. If you want a short answer, I'll try to write
> something:

[snip]

Great! Thanks, it made things a lot clearer! Now I just need to find
something nifty to use it for. ;-) 

Cheers,

-- 

------------------------------------------------------------------------
  +47 90 62 71 78        DoD#2101, NIC#015, Ducati M600, PJ#006, OGM#007
  azo### [at] dodno, "Do one thing every day that scares you." --Mary Schmich


Post a reply to this message

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