|
|
// Gilles Tran
#include "colors.inc"
// ----------------------------------------
camera
{
location <6, 5, -10.0>
direction 1.5*z
right 4/3*x
look_at <0.0, 0.3, 0.0>
}
background{color rgb 1}
light_source{<1000,1000,-1000> color rgb 2}
#declare txtMushroom=texture{pigment{bozo color_map{[0 color Red][0.5
color Red][0.5 color White][1 color White]}} scale 0.3}
// ----------------------------------------
#declare a=0; //initialize the rotation angle
#declare rStem=1; // radius stem big mushroom
#declare rHatmin=0.7; // max radius hat small mushroom
#declare rHatmax=1.3; // max radius hat small mushroom
#declare rd=seed(1); // random seed
#declare apos=0; // initialize the intermushroom angle
// father mushroom
union{
cylinder{0,y*rStem*3.3,rStem texture{pigment{White}}}
cone{0,rStem*3,y*rStem,0 translate y*rStem*3.3}
texture{txtMushroom}
}
#while (a<360) // mushrooms rotate clockwise around the father
mushroom
// for each new mushroom we calculate its "hat" radius, its distance
from the father mushroom
// and then calculate the minimal angle so that it doesn't collide with
the father or the previous one
#declare rtmp=rand(rd); // random value for the new mushroom
#declare rHat=rHatmin*(1-rtmp)+rtmp*rHatmax; // radius of the
current mushroom hat
#declare rpos=(rStem+rHat)*(1+rand(rd)); // radius of the
position of the current mushroom
#if (a=0)
#declare pos=x*rpos; // first mushroom
#declare apos=0;
#declare a=0.0001; // needed to get out from here
#else
#if (rpos_old-rHat_old>rpos+rHat |
rpos-rHat>rpos_old+rHat_old) // new mushroom can't intersect the old one
#declare ra=rpos -
pow((rHat+rHat_old),2)/rpos;
#declare apos=degrees(acos(ra/rpos));
#else
#if (rpos<rpos_old) // new mushroom is closer
to the father mushroom than the previous one
#declare
ra=(pow(rpos,2)-pow((rHat+rHat_old),2)+pow(rpos_old,2))/(2*rpos_old);
#declare apos=degrees(acos(ra/rpos));
#else // new mushroom is farther from the father
mushroom than the previous one
#declare
ra=(pow(rpos,2)-pow((rHat+rHat_old),2)+pow(rpos_old,2))/(2*rpos);
#declare apos=degrees(acos(ra/rpos));
#end
#end
#declare a = a + apos; // rotate this angle
#declare pos=vaxis_rotate(x*rpos,y,a); // new mushroom
position
// now we place the small mushroom
union{
cylinder{0,y*rHat*1.2,rHat*0.3 pigment{White}}
cone{0,rHat,y*rHat*0.3,0 translate y*rHat*1.2 }
translate pos
texture{txtMushroom}
}
#end
#declare pos_old=pos;
#declare rpos_old=rpos;
#declare rHat_old=rHat;
#end
plane{y,0 pigment{Green}}
Post a reply to this message
|
|