################### # Dynamic polyline # --needs slideSequin to run ! ################### tclinit { set winName .slfWINDOW source SLIDEUI.tcl source MATH.tcl proc CreatePointUI { parent name } { set subname "slf_[subst $name]" if { $parent == {} } { set root .$subname } elseif { $parent == "." } { set root .$subname } else { set root $parent.$subname } toplevel $root set rad [CreateScaleCmd $name $root rad "Radius" 2 1 10 0.1 1 horizontal CreateCircle] set slices [CreateScaleCmd $name $root slices "Slices" 7 5 30 1 1 horizontal CreateCircle] set azim [CreateScaleCmd $name $root azim "Azimuth" 0 -180 180 0.1 1 horizontal CreateCircle] set twist [CreateScaleCmd $name $root twist "Twist" 0 -180 180 0.1 1 horizontal CreateCircle] pack $rad $slices $azim $twist -side top -fill x } CreatePointUI $winName pt global circlePoints set circlePoints "" proc DeleteCircle { } { global circlePoints puts "Called DeleteCircle: $circlePoints" foreach pt $circlePoints { slide delete point $pt } } proc CreateCircle { slices } { global pt_rad pt_slices circlePoints SLF_PI ok if { $pt_slices < 3 } { return } DeleteCircle puts "Called CreateCircle: $slices" set theta 0 set thetaDelta [expr 2*$SLF_PI/$pt_slices] set circlePoints "" for {set i 1} {$i <= $pt_slices} {incr i} { set name p[subst $i] set circlePoints [concat $circlePoints "$name"] set x [expr cos($theta)*$pt_rad ] set y [expr -sin($theta)*$pt_rad ] eval "slide create point $name {$x $y 0}" set theta [expr $theta+$thetaDelta] } slide modify polyline pCircle -pointlist $circlePoints } } #################### # SURFACES #################### surface sGrey color (0.25 0.25 0.25) reflectivity (1 1 1) metallic 1 endsurface surface sRed color (1 0 0) endsurface surface sYel color (1 1 0) endsurface #################### # Objects #################### point a1 (-2 0 0) endpoint point a2 ( 0 1 0) endpoint point a3 ( 2 0 0) endpoint polyline pPath pointlist (a1 a2 a3) #pointlist (a1 a3) endpolyline point pp1 ( 1 1 0) endpoint point pp2 (-1 1 0) endpoint point pp3 (-1 -1 0) endpoint point pp4 ( 1 -1 0) endpoint polyline pCircle pointlist (pp1 pp2 pp3 pp4) endpolyline crosssection wedge type polyline pPath endcrosssection sweep sw path pCircle azimuth {expr $pt_azim} twist {expr $pt_twist} endpath crosssection wedge endcrosssection solid SLF_HOLLOW endsweep group gWorld instance pCircle surface sRed endinstance instance sw endinstance instance pPath surface sYel endinstance endgroup group gScene instance gWorld endinstance endgroup #################### # CAMERA #################### camera cam projection SLF_PARALLEL frustum (-2 -2 -100) (2 2 100) endcamera group gCamera instance cam id instCam translate ( 0.0 0.0 1.0 ) endinstance endgroup #################### # LIGHT #################### light lite type SLF_DIRECTIONAL endlight group gLight instance lite id instLite # translate ( 0.0 1.0 1.0 ) lookat eye ( 1.0 1.0 1.0 ) target ( 0.0 0.0 0.0 ) up ( 0.0 1.0 0.0 ) endlookat endinstance endgroup light lite2 type SLF_AMBIENT color (0.5 0.5 0.5) endlight group gLight2 instance lite2 id instLite2 endinstance endgroup #################### # RENDER #################### window WINDOW background (1 1 1) endwindow viewport VIEWPORT WINDOW origin ( 0.0 0.0 ) size ( 1.0 1.0 ) endviewport render VIEWPORT gCamera.instCam.cam gScene light gLight.instLite.lite light gLight2.instLite2.lite2 endrender