point pCenter(0.0 0.0 0.0) endpoint point pTop(0.0 1.0 0.0) endpoint point pFront(0.0 -0.3338068592 0.9426414911) endpoint point pRight(0.8163514779 -0.3338068592 -0.4713207455) endpoint point pLeft (-0.8163514779 -0.3338068592 -0.4713207455) endpoint face fBottom(pFront pLeft pRight) endface face fBack(pTop pRight pLeft) endface face fLeft(pTop pLeft pFront) endface face fRight(pTop pFront pRight) endface object BasicTetra (fBottom fBack fLeft fRight) endobject group Spike instance BasicTetra scale ({Tail} {Tip} {Tail}) rotate (0.0 1.0 0.0) ({RotateSpike}) translate (0.0 {MoveSpike} 0.0) rotate (1.0 0.0 0.0) (109.5) endinstance endgroup group Tetra instance BasicTetra endinstance instance Spike endinstance instance Spike rotate (0.0 1.0 0.0) (120) endinstance instance Spike rotate (0.0 1.0 0.0) (240) endinstance endgroup # 2c) Finally we need to add the triangles to the World. group World instance Tetra scale( {ScaleTetra } {ScaleTetra } {ScaleTetra }) surface sGreen 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 sGreen color (0.0 1.0 0.0) endsurface surface sRed color (1.0 0.0 0.0) endsurface surface sWhite color (1.0 1.0 1.0) endsurface surface sCyan color (0.0 1.0 1.0) endsurface surface sPurple color (1.0 0.0 1.0) endsurface surface s4 color (0.5 0.5 0.0) endsurface surface s5 color (0.5 1.0 0.0) endsurface surface s6 color (1.0 0.5 0.0) endsurface surface sYellow color (1.0 1.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 size [CreateScale $name $root size "Size" 1 0.1 2.0 0.1 1 horizontal] set tip [CreateScale $name $root tip "Tip" 0.3 0.01 2.0 0.01 1 horizontal] set tail [CreateScale $name $root tail "Tail" 0.3 0.01 2.0 0.01 1 horizontal] set start [CreateScale $name $root start "Spike Position" 0.7 0.01 1.0 0.01 1 horizontal] set rot [CreateScale $name $root rot "Spike Rotation" 60 0 120 1 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 $tip $tail $start $rot -side top -fill x } ### This calls the procedure that creates the sliders CreateSliders $winName stat proc ScaleTetra {} { global stat_size return [expr $stat_size*0.25] } proc Tip {} { global stat_tip return $stat_tip } proc Tail {} { global stat_tail return $stat_tail } proc MoveSpike {} { global stat_start return $stat_start } proc RotateSpike {} { global stat_rot return $stat_rot } } ######################################################################################## # 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