################################################## # tetrahedron.slf - a simple polyhedral object # tclinit { toplevel .slfWindow.ui ############################## # Shading UI set shading $SLF_FLAT frame .slfWindow.ui.shading -relief raised -borderwidth 2 label .slfWindow.ui.shading.title -text Shading -relief ridge -borderwidth 2 radiobutton .slfWindow.ui.shading.flat -text Flat -variable shading \ -value $SLF_FLAT -anchor w radiobutton .slfWindow.ui.shading.gouraud -text Gouraud -variable shading \ -value $SLF_GOURAUD -anchor w pack .slfWindow.ui.shading.title .slfWindow.ui.shading.flat \ .slfWindow.ui.shading.gouraud -side top -fill x ############################## # Shared UI set shared 0 frame .slfWindow.ui.shared -relief raised -borderwidth 2 label .slfWindow.ui.shared.title -text Vertices -relief ridge -borderwidth 2 radiobutton .slfWindow.ui.shared.unshared -text Unshared -variable shared \ -value 0 -anchor w radiobutton .slfWindow.ui.shared.shared -text Shared -variable shared \ -value 1 -anchor w pack .slfWindow.ui.shared.title .slfWindow.ui.shared.unshared \ .slfWindow.ui.shared.shared -side top -fill x pack .slfWindow.ui.shading .slfWindow.ui.shared -side left -fill y } surface sBluePlastic color ( 0 0 1 ) reflectivity ( 1 1 1 ) exponent 2 metallic 0 endsurface ################################################## # Cube with unshared vertices # point pTri1 ( 1 -1 1) endpoint point pTri2 (-1 1 1) endpoint point pTri3 ( 1 1 -1) endpoint face fTri (pTri2 pTri1 pTri3) endface object oTri ( fTri ) solid SLF_SOLID endobject group gTetraUnshared instance oTri endinstance instance oTri rotate ( 0 1 0 ) ( 180 ) endinstance instance oTri rotate ( 1 0 0 ) ( 180 ) #rotate ( 0 1 0 ) ( 90 ) endinstance instance oTri rotate ( 0 1 0 ) ( 180 ) rotate ( 1 0 0 ) ( 180 ) #rotate ( 0 1 0 ) ( 90 ) endinstance endgroup ################################################## # Cube with shared vertices # point p1 ( 1 -1 1) endpoint point p2 (-1 1 1) endpoint point p3 ( 1 1 -1) endpoint point p4 (-1 -1 -1) endpoint face f1 (p2 p1 p3) endface face f2 (p4 p3 p1) endface face f3 (p3 p4 p2) endface face f4 (p1 p2 p4) endface object oTetraShared (f1 f2 f3 f4) endobject ################################################## # Set up view # group gCube shading { expr $shading } surface sBluePlastic instance gTetraUnshared lod { if { $shared == 0 } { expr $SLF_FULL } else { expr $SLF_OFF } } endinstance instance oTetraShared lod { if { $shared != 0 } { expr $SLF_FULL } else { expr $SLF_OFF } } endinstance endgroup group gRoot instance gCube rotate ( 0 1 0 ) ( -15 ) rotate ( 1 0 0 ) ( 20 ) scale ( 0.10 0.10 0.10 ) endinstance endgroup group gCam instance cam id iCam translate ( 0 0 1 ) endinstance endgroup camera cam projection SLF_PERSPECTIVE frustum ( -0.5 -0.5 -2 ) ( 0.5 0.5 -0.2 ) endcamera light lAmbient type SLF_AMBIENT color ( 0.2 0.2 0.2 ) endlight light lTop type SLF_POINT color ( 1.0 1.0 1.0 ) endlight group gLight instance lTop id iTop lookat eye ( 0 0 0 ) target ( 0 -1 -1 ) up ( 0 1 0 ) endlookat translate ( 0 1 1 ) endinstance endgroup render Viewport gCam.iCam.cam gRoot light lAmbient light gLight.iTop.lTop endrender viewport Viewport Window endviewport window Window endwindow