1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#declare treeTrunkTexture = texture
{
finish
{
roughness 1.0
}
pigment
{
wrinkles
turbulence 1
octaves 8
omega 0.7
lambda 2
color_map
{
[0.0 color Tan ]
[0.4 color DarkBrown]
[0.8 color Copper]
[1.001 color Brass]
}
}
}
#declare treeBranchTexture = texture
{
finish
{
roughness 1.0
}
pigment
{
wrinkles
turbulence 2
octaves 8
omega 0.7
lambda 2
frequency 2
color_map
{
[0.0 color ForestGreen ]
[0.4 transmit 1]
[0.8 color DarkBrown]
[1.001 transmit 1]
}
}
}
#declare GreenTree = union
{
#declare greenTreeCount = 0;
#declare treeHeight = 10;
#declare branchIntervalCount = 50;
#declare branchProb = 0.85;
#declare trunkThickness = treeHeight/30;
#declare branchSeed = seed(2725);
#declare branchDroop = 5; // in degrees
#declare counter = 1 + treeHeight/branchIntervalCount;
#declare maxLen = treeHeight/1.1;
cone
{
<0,0,0>, trunkThickness, <0,treeHeight,0>, 0.1
texture {treeTrunkTexture}
}
#while (counter < treeHeight)
#declare cb=0;
#declare nb=3;
#while (cb < nb)
#if (rand(branchSeed) < branchProb)
#declare greenTreeCount = greenTreeCount + 1;
#declare branchAngle = rand(branchSeed) * 3.14159 * 2;
#declare workingLen = maxLen / max(counter,1);
cone
{
<0,counter,0>, trunkThickness/max(counter,1)
<workingLen*sin(branchAngle)*1.5,
counter-workingLen*sin(radians(branchDroop)),
workingLen*cos(branchAngle)*1.5 >,
trunkThickness
texture { treeBranchTexture }
}
#end //if
#declare cb = cb + 1;
#end // while
#declare counter = counter + treeHeight/branchIntervalCount;
#end // while
#debug concat("green tree 1: ", str(greenTreeCount,5,0)," branches\n")
}
#macro tree_3 ()
object { GreenTree scale <0.1, 0.1, 0.1> }
#end
|