point pTri0 ( 0 0 1 ) endpoint point pTri1 ( 0 1 0 ) endpoint point pTri2 ( 1 0 0 ) endpoint point pJ1 ( -3 6 0 ) endpoint point pJ2 ( -3 4 0 ) endpoint point pJ3 ( -1 4 0 ) endpoint point pJ4 ( -1 -1 0 ) endpoint point pJ5 ( -3 -1 0 ) endpoint point pJ8 ( -3 -3 0 ) endpoint point pJ9 ( 1 -3 0 ) endpoint point pJ10 ( 1 4 0 ) endpoint point pJ11 ( 3 4 0 ) endpoint point pJ12 ( 3 6 0 ) endpoint face fJ1 ( pJ1 pJ2 pJ11 pJ12 ) endface face fJ2 ( pJ3 pJ4 pJ9 pJ10 ) endface face fJ3 ( pJ4 pJ5 pJ8 pJ9 ) endface face fTri ( pTri0 pTri1 pTri2 ) endface object oTri ( fTri ) endobject object ringJ ( fJ1 fJ2 fJ3 ) endobject group oJ instance ringJ surface morphingColor scale ( {expr $triangle_size} {expr $triangle_size} {expr $triangle_size} ) endinstance endgroup surface morphingColor color ( {expr cos($SLF_TIME)} {expr sin($SLF_TIME)} {expr cos(2*$SLF_TIME)} ) endsurface surface selectableColor color ( {expr $triangle_r} {expr $triangle_g} {expr $triangle_b} ) # reflectivity (0.1 0.1 0.9) endsurface group centerJ surface selectableColor instance ringJ scale ( {expr $triangle_higt} {expr $triangle_higt} {expr $triangle_higt} ) endinstance endgroup group gJs instance centerJ endinstance instance oJ surface sRed rotate ( 0 0 1 ) ( -90 ) translate ( 30 0 0 ) rotate ( 0 0 1 ) ( {expr 30.0*$SLF_TIME*$triangle_sped} ) endinstance instance oJ surface sRed rotate ( 0 0 1 ) ( -90 ) translate ( 30 0 0 ) rotate ( 0 0 1 ) ( {expr 30.0*$SLF_TIME*$triangle_sped+45} ) endinstance instance oJ surface sRed rotate ( 0 0 1 ) ( -90 ) translate ( 30 0 0 ) rotate ( 0 0 1 ) ( {expr 30.0*$SLF_TIME*$triangle_sped+90} ) endinstance instance oJ surface sRed rotate ( 0 0 1 ) ( -90 ) translate ( 30 0 0 ) rotate ( 0 0 1 ) ( {expr 30.0*$SLF_TIME*$triangle_sped+135} ) endinstance instance oJ surface sRed rotate ( 0 0 1 ) ( -90 ) translate ( 30 0 0 ) rotate ( 0 0 1 ) ( {expr 30.0*$SLF_TIME*$triangle_sped+180} ) endinstance instance oJ surface sRed rotate ( 0 0 1 ) ( -90 ) translate ( 30 0 0 ) rotate ( 0 0 1 ) ( {expr 30.0*$SLF_TIME*$triangle_sped+225} ) endinstance instance oJ surface sRed rotate ( 0 0 1 ) ( -90 ) translate ( 30 0 0 ) rotate ( 0 0 1 ) ( {expr 30.0*$SLF_TIME*$triangle_sped+270} ) endinstance instance oJ surface sRed rotate ( 0 0 1 ) ( -90 ) translate ( 30 0 0 ) rotate ( 0 0 1 ) ( {expr 30.0*$SLF_TIME*$triangle_sped+315} ) endinstance endgroup # 2c) Finally we need to add the triangles to the World. group World instance gJs scale ( .01 .01 .01 ) endinstance endgroup ############################################################################ # 3) Add Color # # In the Triangle group we specified the surface color of each instance. # Now we need to define these surfaces. surface sBlue color (0.0 0.0 1.0) endsurface surface sRed color (1.0 0.0 0.0) endsurface ############################################################################ # 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 ### This is where the sliders are actually created ! ! ! ### variable name variable name slider text ### | | | ### V V V set higt [CreateScale $name $root higt "Center J Size" 1 0.5 5 0.1 1 horizontal] set size [CreateScale $name $root size "Ring J Size" 1 0.5 5 0.1 1 horizontal] set sped [CreateScale $name $root sped "Speed" 1 1 5 0.1 1 horizontal] set r [CreateScale $name $root r "Red" .5 0 1 0.01 1 horizontal] set g [CreateScale $name $root g "Green" .5 0 1 0.01 1 horizontal] set b [CreateScale $name $root b "Blue" .5 0 1 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 $higt $size $sped $r $g $b -side top -fill x } ### This calls the procedure that creates the sliders CreateSliders $winName triangle } ######################################################################################## # 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