Site hosted by Angelfire.com: Build your free website today!

Macros

candles.jpg (6148 bytes) Candle Macro - while not a really complex macro, the candle macro came about from modelling the wax drippings down the side of the candle.  The macro below will generate a variety of height candles with different wax flows on each candle.

Code:

#macro FCandle(R1S,CH)
// R1S is a seed value for the wax dripping
// CH is Candle Height

light_source{<0,.17,0> color Orange/2 fade_distance 2 fade_power 3}  // if you want light on the candle

difference{                    // makes the candle with a blob cut out of the top for the wick and flame
cylinder{<0,0,0><0,CH,0>.01} 
sphere{<.005,CH,0> .012}
// sphere{<0,.12,0> .0025}
texture{pigment{color Wheat}}
}

cylinder{<0,.05,0><0,.06,0> .01025 texture{pigment{color Red}}}  // decorations
cylinder{<0,.03,0><0,.04,0> .01025 texture{pigment{color Red}}}

#declare C1=1;                 // Wax flow 1
#declare R1=seed(R1S);
#while (C1<80)
#declare RSY=rand(R1)*6+.5;
#declare RSZ=rand(R1)*.5+.5;
#declare RSX=rand(R1)*1+.5;
#declare RYP=rand(R1)*(CH-.01);
#declare ROY=rand(R1)*35;
#declare ROZ=rand(R1)*15;
sphere{<0,0,0> .0025 scale<RSX,RSY,RSZ> rotate<0,0,ROZ> translate<.01,RYP,0> rotate<0,ROY,0> texture{pigment{color Wheat}}}
#declare C1=C1+1;
#end

#declare C1=1;                 // Wax flow 2
#declare R1=seed(R1S/10);
#while (C1<20)
#declare RSY=rand(R1)*3+.5;
#declare RSZ=rand(R1)*2+.5;
#declare RSX=rand(R1)*2.5+.5;
#declare RYP=rand(R1)*(CH-.015);
#declare ROY=rand(R1)*55;
#declare ROZ=rand(R1)*15;
sphere{<0,0,0> .0025 scale<RSX,RSY,RSZ> rotate<0,0,ROZ> translate<.01,RYP,0> rotate<0,ROY,0> texture{pigment{color Wheat}}}
#declare C1=C1+1;
#end 

sphere{<0,0,0> .016 scale <1,.06,1> texture{pigment{color Wheat}}} // base of candle

#declare BlobCt=int(rand(R1)*5+5); // wax around base of candle
#declare BC=1;
#while (BC<=BlobCt)
#declare RX=rand(R1)*.051-.025;
#declare RZ=rand(R1)*.051-.025; 
#declare RSY=rand(R1)*.06;
#declare RSX=rand(R1)*1;
#declare RSZ=rand(R1)*1;
#declare ROY=rand(R1)*360;
#declare RSD=rand(R1)*.015+.0125; 
sphere{<0,0,0> RSD translate<RSD/2,0,0> scale<RSX,RSY,RSZ> rotate<0,ROY,0> translate<RX-RSD,0,RZ> texture{pigment{color Wheat}}} // wax around base of candle
#declare BC=BC+1;
#end // while 
// sphere{<0,0,0> .025 scale<2,.05,1> rotate<0,-55,0> translate<0,0,.035> texture{pigment{color Wheat}}}
// sphere{<0,0,0> .025 scale<.75,.12,2> rotate<0,-45,0> translate<0,0,0> texture{pigment{color Wheat}}} 

cylinder{<0,CH-.02,0> <0,CH,0> .001 texture{pigment{color Black}}} // candle wick

difference{ // candle flame (NON Media Candle Flame)
sphere{0, 0.025 texture{pigment{rgbt <1.0000, 0.5000,0.0000,.85>} } finish{ambient 2.5}} // orange
sphere{<0, -0.015, 0>, 0.0175 texture{pigment{rgbt <0.7490, 0.8470, 0.8470,.85>} finish{ambient 1.5}}} // lightblue
// sphere{<0, -0.015, 0>, 0.0175 texture{pigment{rgbt <1.0000, 0.9766, 0.8008,.85>} finish{ambient 1.5}}} // lemonchiffon 
hollow
scale<.7, 2.8, .7>
scale .3
translate <0, CH+.01, 0>
} 
#end // end FCandle macro

 

Book Stack Macro - The book-stack macro came about as a result of needing several piles of  "tomes" for the scene.  It will generate a random selection of books stacked and partially rotated for variety.   The entire book macro suite conists of 3 macros... BookTitle to place the titles on the books,  Bookit to create a book, and BookStack to create the stack of books. 

Code:

#macro BookTitle(TY,WX,LZ)
// Global variable is NextTitle Incremented outside this routine and 
//                 used to determine the next title returned
#switch (NextTitle)
#case(1) // a sample title
text{ ttf "timrom.ttf","Pure Magic",.1,0 pigment{color Red} 
    scale .05 rotate<0,-90,0> translate<WX+.002,TY/3,-LZ+(LZ*.5)>}
box{<-WX,0,-LZ+(LZ*.20)><WX+.0023,TY+.0031,-LZ+(LZ*.40)> texture{T_Copper_1A}}
box{<-WX,0,LZ-(LZ*.20)><WX+.0023,TY+.0031,LZ-(LZ*.40)> texture{T_Copper_1A}}
#break 
....   other titles included here
#end // switch 
#declare NextTitle=NextTitle+1;
#if (NextTitle>10)
#declare NextTitle=1;
#end 
#end // macro BookTitle

#macro Bookit(SS,ThickY)
#declare S1=seed(SS);
//#declare ThickY=rand(S1)*.05+.05; // book is a min of .05 thick
#declare WideX=rand(S1)*.2+.15; // min of .15 wide
#declare LengthZ=rand(S1)*.3+.2; // min of .2 long 
#declare CCover=int(rand(SS)*29)+1; // color of cover
union{
box{<-WideX,.003,-LengthZ><WideX-.004,ThickY,LengthZ> texture{pigment{color Wheat}}}
union{ 
box{<-WideX-.005,0,-LengthZ-.005><WideX,.0015,LengthZ+.005> } // covers
box{<-WideX-.005,ThickY,-LengthZ-.005><WideX,ThickY+.003,LengthZ+.005> }

difference{
cylinder{<0,ThickY/2,-LengthZ-.005><0,ThickY/2,LengthZ+.005>WideX+.002}
cylinder{<0,ThickY/2,-LengthZ-.1><0,ThickY/2,LengthZ+.1> WideX-.006}
box{<-WideX-.1,-WideX-.1,-LengthZ-.1><WideX-.009,WideX+.1,LengthZ+.1>}
box{<-WideX,ThickY+.003,-LengthZ-.1><WideX+.2,WideX+.1, LengthZ+.1>} // take off top
box{<-WideX,0,-LengthZ-.1><WideX+.2,-WideX-.1,LengthZ+.1>} //take off bottom
} 

texture{
#switch (CCover)
#case(1) T_Grnt1 scale .1 #break
... include other cover textures here
#end // switch
} 
} // union


#declare PC=5+int(rand(S1)*10);
#declare C1=1;
#while (C1<=PC)
#declare P1=rand(S1)*.01+.005;
#declare P2=rand(S1)*.01+.005;
#declare P3=.003+rand(S1)*(ThickY-.003);
triangle{<-WideX,P3,LengthZ+.0025><-WideX-P1,P3,-LengthZ-.0025-P2><WideX,P3,-LengthZ-.0025> 
   texture{pigment{color Wheat}}}
#declare C1=C1+1;
#end

#declare PC=5+int(rand(S1)*10);
#declare C1=1;
#while (C1<=PC)
#declare P1=rand(S1)*.01+.005;
#declare P2=rand(S1)*.01+.005;
#declare P3=.003+rand(S1)*(ThickY-.003);
triangle{<-WideX,P3,-LengthZ-.0025><-WideX-P1,P3,LengthZ+.0025+P2><WideX,P3,LengthZ+.0025>
     texture{pigment{color Wheat}}}
#declare C1=C1+1;
#end
BookTitle(ThickY,WideX,LengthZ)
}
#end // macro Bookit

#macro BookStack(Howmany,BS,XX,YY,ZZ) 
  // Howmany= number of books in stack
  // BS= book stack rotation.. how much skew
  // XX,YY,ZZ correspond to size of each dimension of books
#declare CC1=1;
#declare S=0; //stack starts at 0
#while (CC1<=Howmany)
#declare ThickY=rand(BS)*.05+.05; // book is a min of .05 thick
#declare ROY=rand(BS)*60-30; 
object{Bookit(rand(BS),ThickY) rotate<0,ROY,0> translate<XX,YY+S,ZZ>}
#declare S=S+ThickY+.003;
#declare CC1=CC1+1;
#end
#end // macro BookStack
books.jpg (41540 bytes)

© 2000, Robert J Becraft, All Rights Reserved.