include "t1-lib.slf" include "s1-lib2.slf" group World instance Statue translate(0.0 0.0 0.0) scale (0.3 0.3 0.3) endinstance endgroup # 3) Add Color # colors taken from t1-lab.slf or enumerated above ############################################################################ # 4) Create Sliders with Tcl/Tk # # The following Tcl/Tk code shows how to create the sliders and variables # that we referenced above. # Make a Tcl initialization block tclinit { set winName .slfWINDOW ### include some tcl libraries source SLIDEUI.tcl source MATH.tcl ### This defines a procedure called CreateSliders proc CreateSliders { parent name } { ### Don't worry about this stuff ... set subname "slf_[subst $name]" if { $parent == {} } { set root .$subname } elseif { $parent == "." } { set root .$subname } else { set root $parent.$subname } toplevel $root ############### change all "var" to correct variable and "file" to file name. ### This is where the sliders are actually created ! ! ! ### variable name variable name slider text ### | | | ### V V V set size [CreateScale $name $root size "Size" 1.0 0.01 3.0 0.01 1 horizontal] set ptch [CreateScale $name $root ptch "Pitch" 0.0 -24.0 24.0 1.0 1 horizontal] set ang [CreateScale $name $root ang "Sweep Angle" 0 0 358 2 1 horizontal] set red1 [CreateScale $name $root red1 "Primary Red" 0.0 0.0 1.0 0.01 1 horizontal] set green1 [CreateScale $name $root green1 "Primary Green" 1.0 0.0 1.0 0.01 1 horizontal] set blue1 [CreateScale $name $root blue1 "Primary Blue" 0.0 0.0 1.0 0.01 1 horizontal] ### ^ ^ ^ ^ ### | | | | ### initial slider value---' | | | ### minimum slider value------' | | ### maximum slider value----------' `- slider step value ### This line is important too. This tells the window to display the sliders. pack $size $ptch $ang $red1 $green1 $blue1 -side top -fill x } ### This defines a procedure called CreateSliders2 proc CreateSliders2 { parent name } { ### Don't worry about this stuff ... set subname "slf_[subst $name]" if { $parent == {} } { set root .$subname } elseif { $parent == "." } { set root .$subname } else { set root $parent.$subname } toplevel $root ############### change all "var" to correct variable and "file" to file name. ### This is where the sliders are actually created ! ! ! ### variable name variable name slider text ### | | | ### V V V set type [CreateScale $name $root type "Fade: 0)No 1) Simple 2) Periodic" 0 0 2 1 1 horizontal] set ang [CreateScale $name $root ang "Fade Angle" 180.0 2.0 358.0 2.0 1 horizontal] set red2 [CreateScale $name $root red2 "Secondary Red" 0.0 0.0 1.0 0.01 1 horizontal] set green2 [CreateScale $name $root green2 "Secondary Green" 0.0 0.0 1.0 0.01 1 horizontal] set blue2 [CreateScale $name $root blue2 "Secondary Blue" 0.0 0.0 1.0 0.01 1 horizontal] ### ^ ^ ^ ^ ### | | | | ### initial slider value---' | | | ### minimum slider value------' | | ### maximum slider value----------' `- slider step value ### This line is important too. This tells the window to display the sliders. pack $type $ang $red2 $green2 $blue2 -side top -fill x } ### This calls the procedure that creates the sliders CreateSliders $winName stat CreateSliders2 $winName fade ### a procedure that resizes each TETRA and allows sweeping proc ScaleProc { angle } { global stat_size global stat_ang if { $angle > $stat_ang } { return 0.0000001 } else { return [expr $stat_size] } } proc Interp { a b t} { return [expr $a*(1.0 - $t) + $b*$t] } proc FadeToAndBack {color1 color2 angle halfway} { if {$angle < $halfway} { return [Interp $color1 $color2 [expr ( 2.0 * $angle / $halfway) / 2.0 ]] } else { return [Interp $color2 $color1 [expr (2.0 * $angle / $halfway) / 2.0 - 1.0]] } } proc SimpleFade { color1 color2 angle maxAngle } { if {$angle < $maxAngle} { return [Interp $color1 $color2 [expr ( 2.0 * $angle / $maxAngle) / 2.0 ]] } else { return [expr $color2] } } proc Fade { color1 color2 angle } { global fade_type global fade_ang if {$fade_type == 0 } { return [expr $color1] } elseif {$fade_type == 1} { return [SimpleFade $color1 $color2 $angle $fade_ang] } else { return [FadeToAndBack $color1 $color2 [expr $angle % (2 * $fade_ang)] $fade_ang] } } proc RedProc { angle} { global stat_red1 global fade_red2 return [Fade $stat_red1 $fade_red2 $angle] } proc GreenProc { angle} { global stat_green1 global fade_green2 return [Fade $stat_green1 $fade_green2 $angle] } proc BlueProc { angle} { global stat_blue1 global fade_blue2 return [Fade $stat_blue1 $fade_blue2 $angle] } } ######################################################################################## # The code below this line specifies the camera, lighting, and rendering. # Don't worry too much about this for now. #################### # CAMERA #################### camera cam projection SLF_PERSPECTIVE frustum ( -0.5 -0.5 -2 ) ( 0.5 0.5 -0.2 ) endcamera group gCamera instance cam id instCam translate ( 0.0 0.0 1.0 ) endinstance endgroup #################### # LIGHTS #################### light lAmbient type SLF_AMBIENT color ( 0.2 0.2 0.2 ) 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 #################### window WINDOW # background ( 0.25 0.60 1.0 ) endwindow viewport VIEWPORT WINDOW endviewport render VIEWPORT gCamera.instCam.cam World light lAmbient light gLight.iTop.lTop endrender