POV-Ray : Newsgroups : povray.text.scene-files : My first Macro :) Server Time
25 Dec 2024 00:56:25 EST (-0500)
  My first Macro :) (Message 1 to 1 of 1)  
From: Glenn Bech
Subject: My first Macro :)
Date: 22 Sep 1999 07:27:45
Message: <37e8bd31@news.povray.org>
Here is a listing of my first macro in pov ever :-) It is used to create a
4x4
tile pattern of wood, to be used in floors etc.

Hinst would be appreciated in the following areas ;

1. I find it diffucult to make the individual pieces of wood look different
from
eachother, i DO translate and scale the texture to make variations, but Its
not
enough... Therefore I introduced the #gap, that defines a space between all
the wooden pieces, this however looks real silly... Any hints ?

2. Macro programmig! More efficient, or bad style in my macro ? Tell me!

PS...

If you dont want to render the image, I have posted a sample in
povray.binaries.images...


---- Include ----

#include "colors.inc"
#include "woods.inc"

#macro twoRowsOfWood(mat)

        union {
                box { <-8+gap,-1,-16+gap>,< 0-gap,1,8-gap>
                        texture {
                                mat
                                translate <1.2,0,10>
                        }
                }
                box { <-8+gap,-1,8+gap>,< 0-gap,1,16-gap>
                         texture

                                mat
                                translate <5.5,1.2,5>
                        }
                }

                box { <0+gap,-1,-16+gap>,< 8-gap,1,-8-gap>
                         texture {
                                mat
                                translate <10.6,0.3,6.5>
                        }
                }
                box { <0+gap,-1,-8+gap> ,<8-gap,1,16-gap>
                         texture {
                                mat
                                translate <12.1,0.9,0>
                        }
                }
        }
#end


#macro  woodenTile(mat)
        union

                object {
                        twoRowsOfWood (mat)
                        translate <-8,0,0>
                }

                object {
                        twoRowsOfWood (mat)
                        rotate <0,180,0>
                        translate <8,0,0>
                }
         }
#end


#macro fourXfourTiles (mat1,mat2)
        union

                object {
                        woodenTile ( mat2)
                        rotate y*90
                        rotate z*180
                        translate <-16,0,16>
                }

                object

                        woodenTile ( mat1)
                        rotate z*180
                        translate <16,0,16>
                }

                object {
                        woodenTile ( mat1 )
                        rotate z*180
                        translate <-16,0,-16>
                }

                object

                        woodenTile ( mat2)
                        rotate y*90
                        rotate x*180
                        translate <16,0,-16>
                }

        }
#end


#macro woodenFloor(xmax,ymax,mat1,mat2)

#local xc = 0 ;
#local yc = 0 ;

    union

    #while (yc < ymax)
        #while (xc < xmax)
                    object

                        fourXfourTiles(mat1,mat2)
                        translate <xc*64,0,yc*64>
                    }
        #declare xc = xc + 1 ;
        #end
     #declare yc = yc + 1 ;
     #declare xc = 0 ;
     #end
    translate <-xmax/2*32, 0, -ymax/2*32>
    }
#end

light_source { <0,40,0> rgb <1,1,1>* 2 }

camera

        location <0,140,0>
        look_at <0,0,0>
}


object

        #declare gap = 0.3 ;
        woodenFloor(2,2,T_Wood30,T_Wood3)
}

------


Post a reply to this message

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