|
|
If I'm understanding correctly you want to use #macro BLOCK() ...blah...
#end, instead of #declare. #declared things get parsed when the code is
encountered, #macros get parsed every time they're used, exactly like a
procedural scripting language :)
--
Tek
http://evilsuperbrain.com
"David Instone" <d.i### [at] gmailcom> wrote in message
news:45800f7c@news.povray.org...
> Is it possible to define a reusable object in Povray similar to how it is
> done in a programming language? Here is a simple scene.
>
> #version 3.6;
>
> #include "colors.inc"
> #include "metals.inc"
> #include "glass.inc"
> #include "stones.inc"
>
> global_settings {
> assumed_gamma 1.0
> }
>
> // ----------------------------------------
>
> camera {
> location <5.0, 80.0, 5.0>
> direction 1.5*z
> right x*image_width/image_height
> look_at <0.0, 0.0, 0.0>
> }
>
> sky_sphere {
> pigment {
> gradient y
> color_map {
> [0.0 rgb <0.6,0.7,1.0>]
> [0.7 rgb <0.0,0.1,0.8>]
> }
> }
> }
>
> light_source {
> <0, 0, 0> // light's position (translated below)
> color rgb <1, 1, 1> // light's color
> translate <-30, 30, -30>
> }
>
> // ----------------------------------------
>
> plane {
> y, -1
> pigment { color rgb <0.5, 0.5, 0.5> }
> }
>
> #declare RADIUS = 1.3;
> #declare BACKGROUND = T_Stone11;
> #declare TITLE = color Yellow;
> #declare ZMIN = -7.5;
>
> //box { <-2, -0.5, -2.5>, <4, 0.5, -7.5> texture{BACKGROUND} } // 10
> //box { <-4, -0.5, -2.5>, <-2, 0.5, -7.5> pigment{TITLE} }
> //cylinder { <-4, 0.5, -2.5>, <4, 0.5, -2.5>, 0.01 pigment{color Black}}
>
> //box { <-2, -0.5, -2.5>, <4, 0.5, 2.5> texture{BACKGROUND} } // 10
> //box { <-4, -0.5, -2.5>, <-2, 0.5, 2.5> texture{T_Stone11} }
> //cylinder { <-4, 0.5, 2.5>, <4, 0.5, 2.5>, 0.01 pigment{color Black}}
>
> //box { <-2, -0.5, 2.5>, <4, 0.5, 7.5> texture{BACKGROUND} } // 10
> //box { <-4, -0.5, 2.5>, <-2, 0.5, 7.5> pigment{TITLE} }
> //cylinder { <-4, 0.5, 7.5>, <4, 0.5, 7.5>, 0.01 pigment{color Black}}
>
> #declare BLOCK = union
> {
> box { <-2, -0.5, ZMIN>, <4, 0.5, (ZMIN + 5)> texture{BACKGROUND} }
> // 10
> box { <-4, -0.5, ZMIN>, <-2, 0.5, ZMIN + 5> pigment{TITLE} }
> cylinder { <-4, 0.5, ZMIN>, <4, 0.5, ZMIN>, 0.01 pigment{color
> Black}}
> //#declare ZMIN = ZMIN+5;
> }
>
> BLOCK
> #declare TITLE = color Red;
> #declare ZMIN = ZMIN + 5;
> sphere { <0, 0, ZMIN>, RADIUS pigment{TITLE}}
> object{ BLOCK translate <0, 0, ZMIN> }
>
> #declare TITLE = color Green;
> #declare ZMIN = ZMIN + 5;
> sphere { <0, 0, ZMIN>, RADIUS pigment{TITLE}}
> object{ BLOCK translate <0, 0, ZMIN> }
>
> #declare TITLE = color Blue;
> #declare ZMIN = ZMIN + 5;
> sphere { <0, 0, ZMIN>, RADIUS pigment{TITLE}}
> object{ BLOCK translate <0, 0, ZMIN> }
>
> The commented sections are what I would like to produce (with a little
> more
> frills) The bottom section is the object declaration and how I would like
> to
> use it to produce the same. The sphere's are purely diagnostic and given
> that they work I can conclude that the BLOCK object is parsed only once at
> declaration. Thereafter it doesn't matter what ZMIN or TITLE are changed
> to.
> Hence it does not work. However if sphere and other basic shapes can be
> defined like this can I not declare(?) or describe and use BLOCK with
> replaceable parameters as well. Hope somebody can help as I get the
> distinct
> idea I have missed something very fundamental and this is a really dumb
> question.
>
> Many thanks
>
>
Post a reply to this message
|
|