// Persistence of Vision Ray Tracer Scene Description File // File: brickwall.inc // Vers: 3.14159 Megapov 0.3 // Desc: Macro to create a brick wall // Date: 8 Jan 2000 // Auth: Gail Shaw #declare Windowx1=-1; #declare Windowx2=-1; #declare Windowy1=-1; #declare Windowy2=-1; #declare Start=<0,0,0>; // if any of the window variables are greater than zero then a window is created in the wall. // The numbers specify the number of bricks along and up the window starts and finishes. // (the window was specified this way to prevent fractions of bricks.) The value for the window // should be a multiple of 1/2 and should not be closer than one brick to the start or end of the wall // The variable Start allows multiple walls to look continous. The wall is translated BEFORE // texturing. // creates a brick wall in the x-y plane #macro BrickWall(Length,Height,MaxLength,MaxHeight,MortarThickness,BrickPig1,BrickPig2,BrickTex1,MortarTex) // Length and Height are the desired dimensions of the wall. // MaxLength and MaxHeight are the maximum desired sized of the bricks // MortarThickness is a percentage of the brick width. 10% to 15% looks quite good. // The two brick pigments are used in a bozo pattern with repeat warps to generate different colours for // each brick. For a monocoloured wall set them to the same pigment. // BrickTex is the remainder of the texture (normal and finish) for the bricks. // MortarTex is the texture for the mortar. #local BrickHeight=Height/ceil((Height+MaxHeight*MortarThickness/120)/(MaxHeight+MaxHeight*MortarThickness/120)); #local BrickLength=Length/ceil((Length+BrickHeight*MortarThickness/80)/(MaxLength+BrickHeight*MortarThickness/80)); #local EffectiveLength = BrickLength+BrickHeight*MortarThickness/80; #local EffectiveHeight = BrickHeight+BrickHeight*MortarThickness/120; #local NoOfBricks=floor(Length/EffectiveLength); #local NoOfRows=floor(Height/EffectiveHeight); //#debug concat("No Of Bricks is: ",str(NoOfBricks,0,0),"\n") //#debug concat("No Of Rows is: ",str(NoOfRows,0,0),"\n") //#debug concat("Windows is from: ",str(Windowx1,0,1),",",str(Windowy1,0,1)," to ",str(Windowx2,0,1),",",str(Windowy2,0,1),"\n")*/ #local Loop1=0; #local Loop2=0; #local BrickPigA= pigment { bozo pigment_map { [0.0 BrickPig1] [1.0 BrickPig2] } scale Length } #local BrickPigB = pigment { BrickPigA warp {repeat x*EffectiveLength offset <0,Height,0>} } #local BrickPig = pigment { BrickPigB warp {repeat y*EffectiveHeight offset <7.5*EffectiveLength,0,0>} } #local BrickTex = texture { BrickTex1 pigment {BrickPig} } union { #if (Windowx1 >0 | Windowx2>0 | Windowy1>0 | Windowy2 >0) difference { box { , } box { , } texture {MortarTex} } #debug concat("Windows is from: ",str(EffectiveLength*(Windowx1-0.5)+BrickLength/2-BrickHeight*MortarThickness/100,0,3),",",str(EffectiveHeight*Windowy1-BrickHeight*MortarThickness/100,0,3)," to ",str(EffectiveLength*(Windowx2+1)+BrickHeight*MortarThickness/100,0,3),",",str(EffectiveHeight*Windowy2+BrickHeight*MortarThickness/200,0,3),"\n") #else box { , texture {MortarTex} } #end #while (Loop1Windowx1 & (Loop2-1)Windowy1 & Loop1, translate } #end #local Loop2=Loop2+1; #end #if ((Windowx1 > 0 | Windowx2>0) & (Loop1+1)>Windowy1 & Loop1, translate } box { <0,0,0>, translate } #end #local Loop2=0; #local Loop1=Loop1+1; #if (Loop1, translate <0,EffectiveHeight*Loop1,0> } box { <0,0,0>, translate } #end #while ((Loop2Windowx1 & (Loop2-0.5)Windowy1 & Loop1, translate } #end #local Loop2=Loop2+1; #end #if ((Windowx1 > 0 | Windowx2>0) & (Loop1+1)>Windowy1 & Loop1, translate } box { <0,0,0>, translate } #end #local Loop2=0; #local Loop1=Loop1+1; #end translate Start texture {BrickTex} bounded_by { box { <-BrickHeight*MortarThickness/200,-BrickHeight*MortarThickness/200,-BrickHeight*MortarThickness/200>, translate Start } } } #end /* Example follows object { BrickWall(5,3,0.8,0.2,10,pigment{Gray30},pigment{Gray70},texture{BrickTex},texture{Mortar}) translate <-2.5,-0.5,0> } */