################################################## # G6QSD.slf # Genus-6, Tetra Frame with Star to center. # symmetrical -- all quadrilaterals. # for Catmull-Clark or mixed subdivision # parameters optimized for pleasing look # CHS 2004-1-11 ################################################### tclinit { package require slideui } tclinit { toplevel .slfWindow.ui CreateSLIDESubdivisionObject oSubdivision set widget [CreateSLIDESubdivisionUI .slfWindow.ui oSubdivision] pack $widget } tclinit { proc CreateParamObject { name } { set this $name global $this # v0 -- VARIABLE -- tip-outer set [subst $this](v0) 1.81 set [subst $this](v0_min) 0.8 set [subst $this](v0_max) 2.0 set [subst $this](v0_resolution) 0.01 # v1 -- VARIABLE -- tip-shoulder set [subst $this](v1) 0.90 set [subst $this](v1_min) 0.0 set [subst $this](v1_max) 1.0 set [subst $this](v1_resolution) 0.01 # v2 -- VARIABLE -- joint-inner set [subst $this](v2) 0.84 set [subst $this](v2_min) 0.0 set [subst $this](v2_max) 0.9 set [subst $this](v2_resolution) 0.01 # v3 -- VARIABLE -- arm-pit set [subst $this](v3) 0.50 set [subst $this](v3_min) 0.0 set [subst $this](v3_max) 0.6 set [subst $this](v3_resolution) 0.01 # v4 -- VARIABLE -- shoulder set [subst $this](v4) 0.78 set [subst $this](v4_min) 0.0 set [subst $this](v4_max) 1.0 set [subst $this](v4_resolution) 0.01 # v5 -- VARIABLE -- arm rad set [subst $this](v5) 0.50 set [subst $this](v5_min) 0 set [subst $this](v5_max) 1.0 set [subst $this](v5_resolution) 0.01 # v6 -- VARIABLE -- arm bend set [subst $this](v6) 1.28 set [subst $this](v6_min) -1 set [subst $this](v6_max) 1.5 set [subst $this](v6_resolution) 0.01 # v7 -- VARIABLE -- strut rad set [subst $this](v7) 0.40 set [subst $this](v7_min) 0.0 set [subst $this](v7_max) 0.8 set [subst $this](v7_resolution) 0.01 # v8 -- VARIABLE -- inner saddle set [subst $this](v8) 0.60 set [subst $this](v8_min) 0.0 set [subst $this](v8_max) 0.9 set [subst $this](v8_resolution) 0.01 # v9 -- VARIABLE -- inner joint set [subst $this](v9) 0.40 set [subst $this](v9_min) 0.0 set [subst $this](v9_max) 0.5 set [subst $this](v9_resolution) 0.01 } proc CreateParamUI { parent name } { set root $parent.f$name set this $name global $this frame $root ## SLIDER Frame frame $root.fScales ## v0 -- SLIDER set widget [CreateScale $root.fScales s_v0 \ [subst $this](v0) "v0: tip-outer" \ [subst $[subst $this](v0_min)] \ [subst $[subst $this](v0_max)] \ [subst $[subst $this](v0_resolution)]] pack $widget -side top -fill x ## v1 -- SLIDER set widget [CreateScale $root.fScales s_v1 \ [subst $this](v1) "v1: tip-shoulder" \ [subst $[subst $this](v1_min)] \ [subst $[subst $this](v1_max)] \ [subst $[subst $this](v1_resolution)]] pack $widget -side top -fill x ## v2 -- SLIDER set widget [CreateScale $root.fScales s_v2 \ [subst $this](v2) "v2: joint inner" \ [subst $[subst $this](v2_min)] \ [subst $[subst $this](v2_max)] \ [subst $[subst $this](v2_resolution)]] pack $widget -side top -fill x ## v3 -- SLIDER set widget [CreateScale $root.fScales s_v3 \ [subst $this](v3) "v3: arm-pit" \ [subst $[subst $this](v3_min)] \ [subst $[subst $this](v3_max)] \ [subst $[subst $this](v3_resolution)]] pack $widget -side top -fill x ## v4 -- SLIDER set widget [CreateScale $root.fScales s_v4 \ [subst $this](v4) "v4: shoulder" \ [subst $[subst $this](v4_min)] \ [subst $[subst $this](v4_max)] \ [subst $[subst $this](v4_resolution)]] pack $widget -side top -fill x ## v5 -- SLIDER set widget [CreateScale $root.fScales s_v5 \ [subst $this](v5) "v5: arm radius" \ [subst $[subst $this](v5_min)] \ [subst $[subst $this](v5_max)] \ [subst $[subst $this](v5_resolution)]] pack $widget -side top -fill x ## v6 -- SLIDER set widget [CreateScale $root.fScales s_v6 \ [subst $this](v6) "v6: arm bend" \ [subst $[subst $this](v6_min)] \ [subst $[subst $this](v6_max)] \ [subst $[subst $this](v6_resolution)]] pack $widget -side top -fill x ## v7 -- SLIDER set widget [CreateScale $root.fScales s_v7 \ [subst $this](v7) "v7: strut radius" \ [subst $[subst $this](v7_min)] \ [subst $[subst $this](v7_max)] \ [subst $[subst $this](v7_resolution)]] pack $widget -side top -fill x ## v8 -- SLIDER set widget [CreateScale $root.fScales s_v8 \ [subst $this](v8) "v8: inner saddle" \ [subst $[subst $this](v8_min)] \ [subst $[subst $this](v8_max)] \ [subst $[subst $this](v8_resolution)]] pack $widget -side top -fill x ## v9 -- SLIDER set widget [CreateScale $root.fScales s_v9 \ [subst $this](v9) "v9: inner joint" \ [subst $[subst $this](v9_min)] \ [subst $[subst $this](v9_max)] \ [subst $[subst $this](v9_resolution)]] pack $widget -side top -fill x pack $root.fScales -side top -fill x return $root } toplevel .slfWindow.param CreateParamObject param set widget [CreateParamUI .slfWindow.param param] pack $widget puts "created paramUI" } ################################################################################ surface sRed color (1 0.1 0.1) endsurface surface sGrn color (0.1 1 0.1) endsurface surface sBlu color (0.1 0.3 1) endsurface surface sYel color (1 0.9 0) endsurface surface sCyn color (0 1 1) endsurface surface sMag color (1 0 1) endsurface surface sBlack color ( 0 0 0 )endsurface ## ARMS ############################ #outer and inner tips point XYT ( {expr $param(v0)} {expr $param(v0)} {expr -$param(v0)} ) endpoint point XY1T ( {expr $param(v2)} {expr $param(v2)} {expr -$param(v2)} ) endpoint #tip shoulder points point XYTs ( {expr $param(v0) + $param(v1)} {expr $param(v0) - $param(v1)} {expr $param(v1) - $param(v0)}) endpoint point ZTs ( {expr $param(v0) - $param(v1)} {expr -$param(v1)+ $param(v0)} {expr -$param(v0) - $param(v1)}) endpoint #shoulder points #point XYyT ( {expr 1 + $param(v4)} 1 {expr -1 - $param(v4)} ) endpoint #point XYzT ( {expr 1 + $param(v4)} {expr 1 + $param(v4)} -1 ) endpoint point XYyT ( {expr 1 + $param(v4)} {expr 1 - $param(v4)} {expr -1 - $param(v4)} ) endpoint point XYzT ( {expr 1 + $param(v4)} {expr 1 + $param(v4)} {expr -1 + $param(v4)} ) endpoint #arm pit points point XYP ( {expr $param(v2) + $param(v3)} {expr $param(v2) - $param(v3)} {expr $param(v3) - $param(v2)}) endpoint #mid-arm joint point XT1 ( {expr 1 + $param(v6) + $param(v5)} 0 0) endpoint point XT2 ( {expr 1 + $param(v6)} {expr $param(v5) / sqrt(2)} {expr $param(v5) / sqrt(2)}) endpoint point XT3 ( {expr 1 + $param(v6) - $param(v5)} 0 0) endpoint point XT4 ( {expr 1 + $param(v6)} {expr -$param(v5) / sqrt(2)} {expr -$param(v5) / sqrt(2)}) endpoint face q1 (XYyT XYTs XT1 XT4) endface face q3 (XYTs XYzT XT2 XT1) endface face q5 (XYzT XYP XT3 XT2) endface face q7 (XYyT XT4 XT3 XYP) endface face qts (XYTs XYyT ZTs XYT ) endface object halfArm (q1 q3 q5 q7 qts) endobject ## STRUTS ####################### #central points point XYZ ( {expr $param(v9)} {expr $param(v9)} {expr $param(v9)} ) endpoint point ABZ ( {expr -$param(v9)} {expr -$param(v9)} {expr $param(v9)} ) endpoint point Z ( 0 0 {expr $param(v8)}) endpoint #mid strut points point mZ ( {expr 0.4082*$param(v7)-0.5} {expr -0.4082*$param(v7)+0.5} {expr 0.8165*$param(v7)+0.5}) endpoint point mF ( {expr 0.8165*$param(v7)-0.5} {expr 0.4082*$param(v7)+0.5} {expr 0.4082*$param(v7)+0.5}) endpoint point mB ( {expr -0.4082*$param(v7)-0.5} {expr -0.8165*$param(v7)+0.5} {expr 0.4082*$param(v7)+0.5}) endpoint #tetra joint point tZ ( {expr $param(v3) - $param(v2)} {expr $param(v2) - $param(v3)} {expr $param(v2) + $param(v3)}) endpoint point tB ( {expr -1 - $param(v4)} {expr 1 - $param(v4)} {expr 1 + $param(v4)}) endpoint point tF ( {expr -1 + $param(v4)} {expr 1 + $param(v4)} {expr 1 + $param(v4)} ) endpoint face s1 (mF mZ Z XYZ) endface face s2 (ABZ Z mZ mB) endface face s3 (mZ mF tF tZ) endface face s4 (mB mZ tZ tB) endface object halfStrut (s1 s2 s3 s4 ) endobject ################################################### group tetraStrut instance halfStrut surface sRed endinstance instance halfStrut rotate (-1 1 1) (120) surface sBlu endinstance instance halfStrut rotate (-1 1 1) (-120) surface sGrn endinstance endgroup group allStruts instance tetraStrut endinstance instance tetraStrut rotate (1 0 0) (180) endinstance instance tetraStrut rotate (0 1 0) (180) endinstance instance tetraStrut rotate (0 0 1) (180) endinstance endgroup group tetraCorner instance halfArm surface sRed endinstance instance halfArm rotate (1 1 -1) (120) surface sBlu endinstance instance halfArm rotate (1 1 -1) (-120) surface sGrn endinstance endgroup group allArms instance tetraCorner endinstance instance tetraCorner rotate (1 0 0) (180) endinstance instance tetraCorner rotate (0 1 0) (180) endinstance instance tetraCorner rotate (0 0 1) (180) endinstance endgroup ################################################### subdivision oSubdivision lod {expr $oSubdivision(lod)} shading {expr $oSubdivision(shading)} type {expr $oSubdivision(type)} subdivisions {expr $oSubdivision(subdivisions)} drawcontrols {expr $oSubdivision(drawcontrols)} drawvertices {expr $oSubdivision(drawvertices)} # Hack to get non-uniform knot spacing on some of the edges uknots {expr $oSubdivision(weightededges)} uorder {expr $oSubdivision(weight)} # Hack to assign a tolerance value for the selective subdivision tolerance {expr $oSubdivision(tolerance)} facetsmax {expr $oSubdivision(facetsmax)} instance allStruts endinstance instance allArms endinstance endsubdivision ################### Build the World ############################## group gRoot instance oSubdivision scale(0.1 0.1 0.1) endinstance endgroup ################### Set up view ################################## group gCam instance cam id iCam translate ( 0 0 1 ) endinstance endgroup camera cam projection SLF_PERSPECTIVE frustum ( -0.2 -0.2 -2 ) ( 0.2 0.2 -0.01 ) endcamera light lAmbient type SLF_AMBIENT color ( 0.4 0.4 0.4 ) endlight light lTop type SLF_DIRECTIONAL color ( 1.0 1.0 1.0 ) endlight group gLight instance lTop id iTop lookat eye ( 0 0 0 ) target ( -1 -1 -1 ) up ( 0 1 0 ) endlookat translate ( 1 1 1 ) endinstance endgroup render Viewport gCam.iCam.cam gRoot light lAmbient light gLight.iTop.lTop endrender viewport Viewport Window endviewport window Window background ( 0.7 0.8 1 ) endwindow