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