Last active
December 16, 2015 11:18
-
-
Save benhardy/5426293 to your computer and use it in GitHub Desktop.
Generate a broccoli using POV-Ray's macros, which can be recursive.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate a broccoli like structure | |
#include "colors.inc" | |
#include "textures.inc" | |
light_source { | |
<-100, 400,-200> | |
color <0.8,0.8,0.8> | |
area_light <50,0,0>, <0,0,50>, 5, 5 | |
adaptive 1 | |
jitter | |
} | |
light_source { | |
<0,0,-100> | |
color <0.7,1.0,0.5> | |
area_light <20,0,0>, <0,20,0>, 5, 5 | |
adaptive 1 | |
jitter | |
} | |
camera { | |
location <-4, 5,-3> | |
look_at <0,1.0,0> | |
} | |
// This is the smallest size object we want to render | |
// The smaller this is, the more complex our resulting rendering will be (using more RAM and CPU too). | |
// use larger values for low quality test renders. | |
#declare CellSizeThreshold = 0.01; | |
#declare Cell = sphere { <0,0,0>,1 } | |
#declare TrunkRatio = 0.50; | |
#declare TrunkTwist = 32; // deg | |
#declare BranchRatio = 0.55; | |
#declare BranchAngle = 42; | |
#declare BranchCount = 5; | |
#declare InterBranchAngle = (360/BranchCount); | |
#macro Arrangement(Size) | |
#if (Size < CellSizeThreshold) | |
object { Cell } // having this outside a union avoids single-element union warning | |
#else | |
union { | |
object { Cell } | |
object { Arrangement(Size*TrunkRatio) | |
scale TrunkRatio | |
rotate y* TrunkTwist | |
translate y | |
} | |
#local branch = 0; | |
#while (branch < BranchCount) | |
object { Arrangement(Size*BranchRatio) | |
scale BranchRatio | |
rotate y* 60 | |
translate y | |
rotate x*BranchAngle | |
rotate y *72*branch | |
} | |
#local branch = branch + 1; | |
#end | |
} | |
#end | |
#end | |
union { | |
Arrangement(1) | |
cylinder { <0,0,0>,<0,-1,0>,1 } | |
pigment { color <0.1, 0.6, 0> } | |
finish { diffuse 0.7 ambient 0.2 } | |
scale 1.5 | |
} | |
plane { | |
y, 0 | |
translate y*-1.5 | |
pigment { | |
checker | |
color <0.10, 0.10, 0.10> | |
color <0.07, 0.07, 0.07> | |
scale 0.5 | |
} | |
finish { | |
ambient 0.2 diffuse 0.6 reflection 0.2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment