### escherflower2 -- work in progress ... ### A basic generator of icosidodecahedral symmetry by C.H. Sequin ### Enhanced by Harlan Hile and Balaji Kannan. ### Modified further by CHS -- remove veins, inside, ### later make curve leaves as self-contained warped tetrahedra. ############################################################################ tclinit{ set winName .slfWINDOW source SLFCONSTS.tcl source SLIDEUI.tcl ###### Geometric Parameters ################# proc CreateZoneUI { parent name } { set subname "slf_[subst $name]" if { $parent == {} } { set root .$subname } elseif { $parent == "." } { set root .$subname } else { set root $parent.$subname } toplevel $root wm geometry $root +10+50 set a5r [CreateScale $name $root a5r "radius at Axis-5" 1.0 0.0 3.0 0.01 1 horizontal ] set a3r [CreateScale $name $root a3r "radius at Axis-3" 1.49 0.0 3.0 0.01 1 horizontal ] set a2r [CreateScale $name $root a2r "radius at Axis-2" 1.0 0.0 3.0 0.01 1 horizontal ] set e35i [CreateScale $name $root e35i "edge interpolation 3-5" 0.5 -1.0 2.0 0.01 1 horizontal ] set e35n [CreateScale $name $root e35n "edge 3-5 normal offset" 0.0 -1.0 1.0 0.01 1 horizontal ] set e35r [CreateScale $name $root e35r "radius at edge-point 3-5" 1.0 0.0 3.0 0.01 1 horizontal ] pack $a5r $a3r $a2r $e35i $e35n $e35r -side top -fill x } proc CreateFlowerUI { parent name } { set subname "slf_[subst $name]" if { $parent == {} } { set root .$subname } elseif { $parent == "." } { set root .$subname } else { set root $parent.$subname } toplevel $root wm geometry $root +130+50 set leafx1 [CreateScale $name $root leafx1 "leafcenter x1 disp" 0.26 -1.0 1.0 0.01 1 horizontal ] set leafy1 [CreateScale $name $root leafy1 "leafcenter y1 disp" 0.05 -1.0 1.0 0.01 1 horizontal ] set leafz1 [CreateScale $name $root leafz1 "leafcenter z1 disp" -0.098 -1.0 1.0 0.001 1 horizontal ] set flowerz [CreateScale $name $root flowerz "flower height" 0.98 0.2 1.0 0.01 1 horizontal ] set flowerx [CreateScale $name $root flowerx "flower spread" 0.20 0.1 1.0 0.01 1 horizontal ] set a23 [CreateScale $name $root a23 "a2-3 interp" -0.120 -2.0 3.0 .001 1 horizontal ] set a23b [CreateScale $name $root a23b "a2-3 interp 2" -0.472 -2.0 3.0 .001 1 horizontal ] set a23m [CreateScale $name $root a23m "a2-3 ra2-3 interp" 0.250 -2.0 3.0 .001 1 horizontal ] set leafrot [CreateScale $name $root leafrot "leaf rot" 93 0.0 360 1 1 horizontal ] set veinrot [CreateScale $name $root veinrot "vein rot" -55 -120 360 1 1 horizontal ] pack $leafx1 $leafy1 $leafz1 $flowerz $flowerx $a23 $a23b $a23m $leafrot $veinrot -side top -fill x } ###### Root Window with Shading Options ################# proc CreateShadingUI { parent name } { set subname "slf_[subst $name]" if { $parent == {} } { set root .$subname } elseif { $parent == "." } { set root .$subname } else { set root $parent.$subname } toplevel $root wm geometry $root +200+230 set shadingFrame [CreateShadingFrame $name $root] pack $shadingFrame -side left -fill y } proc interp {x y t} { return [expr $x * (1 - $t) + $t * $y]; } ###### START EXECUTION ############## #### Initialize Variables -- all angles in radians, unless otherwise noted puts ___________________________________ set to_deg [expr 180.0/$SLF_PI ] set to_rad [expr $SLF_PI/180.0 ] set cos_60 [expr 0.5*sqrt(3.0) ] set cos_36 0.809016994 set sin_36 0.587785252 set sin3_5 0.607061998 set sin2_5 0.525731112 set cos3_5 0.794654472 set cos2_5 0.850650808 CreateZoneUI $winName zone CreateFlowerUI $winName flow CreateShadingUI $winName gRoot } ### end_tclinit ############################################################################ # Surfaces ############################################################################ surface sPetalRing color ( 1 0 1 ) endsurface surface sHilite color ( 1 1 1 ) endsurface surface sFlowerCore color ( 0.9 0.8 0.1 ) endsurface surface sPink color ( 1.0 0.4 0.6 ) endsurface surface sLeafA color ( 0.4 1.0 0.3 ) endsurface surface sLeafB color ( 0.2 0.7 0.2 ) endsurface surface sPetals color ( 1 0.5 0.6 ) endsurface ############################################################################ # Geometry ############################################################################ point A5 ( 0 0 {expr $zone_a5r} ) endpoint point A3 ( 0 {expr $sin3_5 * $zone_a3r} {expr $cos3_5 * $zone_a3r} ) endpoint point A2 ( {expr $sin_36 * $sin2_5 * $zone_a2r} {expr $cos_36 * $sin2_5 * $zone_a2r} {expr $cos2_5 * $zone_a2r} ) endpoint point RA2 ( {expr -$sin_36 * $sin2_5 * $zone_a2r} {expr $cos_36 * $sin2_5 * $zone_a2r} {expr $cos2_5 * $zone_a2r} ) endpoint ### This is a pretty arbitrary way to move this vertex in all 3 dimensions, ### should be more logically tied to neighboring points. point E35 ( {expr $zone_e35n * $zone_e35r} {expr ( $zone_e35i*$cos3_5*$zone_a3r + (1-$zone_e35i)*$cos_36*$sin2_5*$zone_a2r ) * $zone_e35r} {expr $zone_e35r} ) endpoint ### Introduce additional points on the inside or on the edge of the fundamental zone. ### Make sure that points on the edge are repeated with the proper offset on the other side ! #interpolate A2 and A3 point A23 ( {interp [expr $sin_36 * $sin2_5 * $zone_a2r] 0 $flow_a23} {interp [expr $cos_36 * $sin2_5 * $zone_a2r] [expr $sin3_5 * $zone_a3r] $flow_a23} {interp [expr $cos2_5 * $zone_a2r] [expr $cos3_5 * $zone_a3r] $flow_a23} ) endpoint point RA23 ( {interp [expr -$sin_36 * $sin2_5 * $zone_a2r] 0 $flow_a23b} {interp [expr $cos_36 * $sin2_5 * $zone_a2r] [expr $sin3_5 * $zone_a3r] $flow_a23b} {interp [expr $cos2_5 * $zone_a2r] [expr $cos3_5 * $zone_a3r] $flow_a23b} ) endpoint point A23N ( {interp [expr $sin_36 * $sin2_5 * $zone_a2r] 0 $flow_a23b} {interp [expr $cos_36 * $sin2_5 * $zone_a2r] [expr $sin3_5 * $zone_a3r] $flow_a23b} {interp [expr $cos2_5 * $zone_a2r] [expr $cos3_5 * $zone_a3r] $flow_a23b} ) endpoint point RA23N ( {interp [expr -$sin_36 * $sin2_5 * $zone_a2r] 0 $flow_a23} {interp [expr $cos_36 * $sin2_5 * $zone_a2r] [expr $sin3_5 * $zone_a3r] $flow_a23} {interp [expr $cos2_5 * $zone_a2r] [expr $cos3_5 * $zone_a3r] $flow_a23} ) endpoint #a point A5 that's somewhere around A5 rotated about A3 point A5R ( {expr $flow_leafx1} {expr $flow_leafy1} {expr $zone_a5r + $flow_leafz1} ) endpoint #interpolate A23 and RA23 point AM23 ( {interp [interp [expr $sin_36 * $sin2_5 * $zone_a2r] [expr 0] $flow_a23] [interp [expr -$sin_36 * $sin2_5 * $zone_a2r] [expr 0] $flow_a23b] $flow_a23m} {interp [interp [expr $cos_36 * $sin2_5 * $zone_a2r] [expr $sin3_5 * $zone_a3r] $flow_a23] [interp [expr $cos_36 * $sin2_5 * $zone_a2r] [expr $sin3_5 * $zone_a3r] $flow_a23b] $flow_a23m} {interp [interp [expr $cos2_5 * $zone_a2r] [expr $cos3_5 * $zone_a3r] $flow_a23] [interp [expr $cos2_5 * $zone_a2r] [expr $cos3_5 * $zone_a3r] $flow_a23b] $flow_a23m} ) endpoint face lF1 (A23 A3 RA23) surface sLeafA endface face lF2 (A23 A5R A23N) surface sHilite endface face lF3 (A23 AM23 A5R) surface sLeafB endface object oLeaf (lF1 lF2 lF3) endobject group gLeaf # Main Leaf instance oLeaf endinstance endgroup sphere petal surface sPetals zslices 12 thetaslices 12 endsphere group gZone instance gLeaf rotate ( 0 {expr $sin3_5} {expr $cos3_5} ) ( {expr $flow_leafrot} ) endinstance instance petal scale (0.07 0.07 0.15) rotate (0 1 0) (15) translate ({expr $flow_flowerx} 0 {expr $flow_flowerz}) rotate ( 0 0 1) (36) endinstance instance petal scale (0.07 0.07 0.15) rotate (0 1 0) (15) translate ({expr $flow_flowerx} 0 {expr $flow_flowerz}) endinstance endgroup sphere flowercore surface sFlowerCore zslices 24 thetaslices 24 endsphere torus petalring surface sPetalRing thetaslices 16 phislices 12 minorradius 0.4 endtorus group gPenta # 5 copies of gZone instance gZone endinstance instance gZone rotate (0 0 1)(72) endinstance instance gZone rotate (0 0 1)(-72) endinstance instance gZone rotate (0 0 1)(144) endinstance instance gZone rotate (0 0 1)(-144) endinstance instance flowercore scale ( {expr $flow_flowerx * .7} {expr $flow_flowerx * .7} {expr $flow_flowerx * .85}) translate (0 0 {expr $flow_flowerz + 0.03}) endinstance instance petalring scale ( {expr $flow_flowerx * .7} {expr $flow_flowerx * .7} {expr $flow_flowerx * .85}) translate (0 0 {expr $flow_flowerz -0.01}) endinstance endgroup ## Now we have one 5-sided blossom; repeat this 12 times ! group gDodeca # 12 copies of gPenta instance gPenta endinstance instance gPenta rotate (1 0 0)(-63.43494882) rotate (0 0 1)(36) endinstance instance gPenta rotate (1 0 0)(-63.43494882) rotate (0 0 1)(108) endinstance instance gPenta rotate (1 0 0)(-63.43494882) rotate (0 0 1)(180) endinstance instance gPenta rotate (1 0 0)(-63.43494882) rotate (0 0 1)(-108) endinstance instance gPenta rotate (1 0 0)(-63.43494882) rotate (0 0 1)(-36) endinstance instance gPenta rotate (1 0 0)(180) endinstance instance gPenta rotate (1 0 0)(180) rotate (1 0 0)(-63.43494882) rotate (0 0 1)(36) endinstance instance gPenta rotate (1 0 0)(180) rotate (1 0 0)(-63.43494882) rotate (0 0 1)(108) endinstance instance gPenta rotate (1 0 0)(180) rotate (1 0 0)(-63.43494882) rotate (0 0 1)(180) endinstance instance gPenta rotate (1 0 0)(180) rotate (1 0 0)(-63.43494882) rotate (0 0 1)(-108) endinstance instance gPenta rotate (1 0 0)(180) rotate (1 0 0)(-63.43494882) rotate (0 0 1)(-36) endinstance endgroup group gAssembly shading {expr $gRoot_shading} instance gDodeca endinstance endgroup ############## LIGHTS ####################################### light lite type SLF_DIRECTIONAL endlight group gLight instance lite id instLite lookat eye ( 0.5 1.0 1.0 ) target ( 0.0 0.0 0.0 ) up ( 0.0 1.0 0.0 ) endlookat endinstance endgroup light lite2 type SLF_AMBIENT color (0.4 0.4 0.4) endlight group gLight2 instance lite2 id instLite2 endinstance endgroup ############# RENDERING #################################### camera cam projection SLF_PARALLEL frustum ( -2 -2 -10 ) ( 2 2 5 ) endcamera group gCam instance cam id iCam translate ( 0 0 1 ) endinstance endgroup window WINDOW background (0.3 0.6 0.9) endwindow viewport vp WINDOW endviewport render vp gCam.iCam.cam gAssembly light gLight.instLite.lite light gLight2.instLite2.lite2 endrender ##############################################################