POV-Ray : Newsgroups : povray.advanced-users : Macro Question Server Time
30 Jul 2024 08:26:55 EDT (-0400)
  Macro Question (Message 1 to 5 of 5)  
From: David Heys
Subject: Macro Question
Date: 27 Sep 1999 16:53:32
Message: <37EFD3C7.FFA3FB3B@hotmail.com>
Hey guys,

As I've said in other posts, math is not my strong point. As such, the
concept of marcos gives me headaches. :{P

But, I'm willing to learn. Most examples I've seen don't seem to be
simple enough for me to grasp how I could put them to good use. So, when
I was working on my first attempt at creating a bush on my own, I
thought, "This may be a good way to get suggestions on using macros to
make things easier."

Can anyone take a peek at the following code and give me any suggestions
as to how/if macros might help make things run more smoothly/compactly?
BTW, I've posted an image of the bush on p.b.i.

//=============================================
global_settings {assumed_gamma 2.2}
global_settings { max_trace_level 20}

#include "colors.inc"

#declare Cm5=
 camera {
  location <30, 25, -45>
  direction <0, 0, 1>
  up  <0, 1, 0>
  right <4/3, 0, 0>
  look_at <0, 5, 10>
 }

camera {Cm5}

light_source { <35, 30, -40> color rgb <0.9,0.3,0.3>
 area_light <32, 27, -37>, <38, 33, -43>, 2, 2
 fade_distance 75
 fade_power 30
}

light_source { <32, 33, -40> color rgb <0.3,0.9,0.3>
 area_light <29, 30, -37>, <35, 36, -43>, 2, 2
 fade_distance 75
 fade_power 30
}

light_source { <38, 33, -40> color rgb <0.3,0.3,0.9>
 area_light <35, 30, -37>, <41, 36, -43>, 2, 2
 fade_distance 75
 fade_power 30
}

#declare Rot1=0;
#declare Ytran1=0;
#declare Scaler1=1;
#declare R1=seed(8732);

#declare BR1=
 blob {
  threshold 0.65
  #while (Rot1 <=720)
   cylinder {<-0.5,0,0>,<0.5,0,0>,1,1
    translate rand(R1)*0.5
    scale Scaler1
    translate -0.5*z
    translate Ytran1*y
    rotate Rot1*y
   }
   #declare Rot1=Rot1+10;
   #declare Ytran1=Ytran1+0.3;
   #declare Scaler1=Scaler1-(1/100);
  #end
  pigment {rgb<0.8,0.6,0.2>}
  finish {specular 0.4 roughness 0.007}
 }

#declare BR2=
 union {
  blob {
   threshold 0.65

   #declare Rot1=0;
   #declare Ytran1=0;
   #declare Scaler1=1;
   #declare R1=seed(8732);
   #declare Counter1=1;
   #declare Ytran2=2;

   #while (Rot1 <=720)
    cylinder {<-0.5,0,0>,<0.5,0,0>,1,1
     translate rand(R1)*0.5
     scale Scaler1
     translate -0.5*z
     translate Ytran1*y
     rotate Rot1*y
    }
    #declare Rot1=Rot1+10;
    #declare Ytran1=Ytran1+0.3;
    #declare Scaler1=Scaler1-(1/100);
   #end
   pigment {rgb<0.8,0.6,0.2>}
   finish {specular 0.4 roughness 0.007}
  }

  #declare Rot1=0;
  #declare Rot2=0;
  #declare Ytran1=3;
  #declare Scaler1=1;
  #declare R1=seed(8732);

  #while (Rot1 <=720)
   triangle {<1,0.6,0>,<1,-0.6,0>,<3,0,0>
    pigment {green 1}
    rotate Rot2*x
    translate rand(R1)*0.5
    scale Scaler1
    translate -0.5*z
    translate Ytran1*y
    rotate Rot1*y
   }
   triangle {<1,0.6,0>,<1,-0.6,0>,<3,0,0>
    pigment {green 1}
    rotate Rot2*x
    translate rand(R1)*0.5
    scale Scaler1
    translate -0.5*z
    translate Ytran1*y
    rotate -Rot1*y
   }
   #declare Rot1=Rot1+30;
   #declare Rot2=Rot2+30;
   #declare Ytran1=Ytran1+0.65;
   #declare Scaler1=Scaler1-(1/100);
  #end
 }

#declare Counter1=1;
#declare Ytran2=5;
#declare Scaler2=0.75;
#declare Rotater1=55;
#declare Rotater2=0;

#declare BR3=
 union {
  object {BR1 rotate 90*y}
  #while (Counter1 <= 4)
   object {BR2 scale Scaler2 rotate Rotater1*x translate Ytran2*y rotate
(45+Rotater2)*y}
   object {BR2 scale Scaler2 rotate Rotater1*x translate Ytran2*y rotate
(165+Rotater2)*y}
   object {BR2 scale Scaler2 rotate Rotater1*x translate Ytran2*y rotate
(275+Rotater2)*y}
   #declare Counter1=Counter1+1;
   #declare Ytran2=Ytran2+4;
   #declare Scaler2=Scaler2-0.2;
   #declare Rotater1=Rotater1-7;
   #declare Rotater2=Rotater2-15;
  #end
 }

#declare Counter1=1;
#declare Ytran2=5;
#declare Scaler2=0.75;
#declare Rotater1=55;
#declare Rotater2=0;

#declare BR4=
 union {
  object {BR1 rotate 90*y}
  #while (Counter1 <= 4)
   object {BR3 scale Scaler2 rotate Rotater1*x translate Ytran2*y rotate
(45+Rotater2)*y}
   object {BR3 scale Scaler2 rotate Rotater1*x translate Ytran2*y rotate
(165+Rotater2)*y}
   object {BR3 scale Scaler2 rotate Rotater1*x translate Ytran2*y rotate
(275+Rotater2)*y}
   #declare Counter1=Counter1+1;
   #declare Ytran2=Ytran2+4;
   #declare Scaler2=Scaler2-0.2;
   #declare Rotater1=Rotater1-7;
   #declare Rotater2=Rotater2-15;
  #end
 }

// bush
object {BR4 scale 1.5}

// floor
plane {y,0
 pigment {
  marble
  color_map {
   [0.00 rgb<0.8,0.76,0.6>]
   [0.35 rgb<0.8,0.76,0.6>]
   [0.50 rgb<0.45,0.45,0.45>]
   [0.65 rgb<0.8,0.76,0.6>]
   [1.00 rgb<0.8,0.76,0.6>]
  }
  scale 15
 }
}

// mirrored backdrop
cylinder {<0,-10,0>,<0,500,0>,60
 clipped_by {box{<-80,-20,80>,<80,600,0>}}
 scale <2,1,1>
 texture {
  pigment {rgb 0}
  finish {specular 0.3 roughness 0.003 reflection 0.995}
 }
}

// floor molding at edge of backdrop
torus {60,5
 clipped_by {box{<-80,-20,80>,<80,600,0>}}
 scale <2,1,1>
 texture {
  pigment {rgb<0.8,0.49,0.19>}
  normal {granite 0.3 turbulence 0.7 scale 10}
  finish {specular 0.8 roughness 0.003 brilliance 32 ambient 0.2 diffuse
0.9 reflection 0.8}
 }
}

// black cylinder behind camera
cylinder {<0,-10,0>,<0,500,0>,60
 clipped_by {box{<-80,-20,-80>,<80,600,0>}}
 scale <2,1,1>
 pigment {rgb 0}
}

//=========================================


Post a reply to this message

From: Remco de Korte
Subject: Re: Macro Question
Date: 27 Sep 1999 17:14:40
Message: <37EFDE7B.C27B535F@xs4all.nl>
Not really an answer but perhaps it may reassure you: macros are not really
about math, they're more about structure. And about not wanting to type the same
thing over and over again. And then there is recursion.... and then there's
headaches...
Sorry, I've tried too much macros lately to be able to read your code and
understand it.

Remco


Post a reply to this message

From: Nieminen Juha
Subject: Re: Macro Question
Date: 28 Sep 1999 05:32:06
Message: <37f08b16@news.povray.org>
There are no macros in your code.
  What are you talking about?

-- 
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: Macro Question
Date: 28 Sep 1999 05:38:52
Message: <37F08C49.63440C48@pacbell.net>
Nieminen Juha wrote:
> 
>   There are no macros in your code.
>   What are you talking about?

He knows that there are no macros in his code. What he wants is for someone
to show him how to turn his code into a macro if possible so that he can
learn from the experience.

-- 
Ken Tyler
1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Nieminen Juha
Subject: Re: Macro Question
Date: 28 Sep 1999 06:16:09
Message: <37f09569@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
: He knows that there are no macros in his code. What he wants is for someone
: to show him how to turn his code into a macro if possible so that he can
: learn from the experience.

  Oh, sorry. I didn't understand what did he mean.
  Please don't understand my question as aggressive or arrogant.

-- 
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

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