#___________________________________________________
proc transformation { } {
set transform "1 0 0 0 0 1 0 0 0 0 1 0 "
set t $transform
append t [format "%1.3f " [expr rand()]]
append t [format "%1.3f " [expr rand()]]
append t [format "%1.3f 1\n" [expr rand()]]
return $t
}
#___________________________________________________
#___________________________________________________
proc blobby { num } {
set ellipsoid_ID "1001 "
set index 0
set out "TransformBegin\n"
append out "Blobby $num \n"
# begin the "code" block
append out "\[\n"
for { set n 0 } { $n < $num } { incr n 1 } {
append out $ellipsoid_ID
append out $index
incr index 16
append out "\n"
}
# define the blobby operator and indices of
# the blobs forming a "set" ie. group
set add_ID 0
set blob_count $num
append out "$add_ID $blob_count "
for { set n 0 } { $n < $num } { incr n 1 } {
append out "$n "
}
append out "\]\n"
# end of the code block
# begin the transforms block
append out "\[\n"
for { set n 0 } { $n < $num } { incr n 1 } {
append out [transformation]
}
append out "\]\n"
# end of the transforms block
# begin the depth map block
append out "\[ \"\" \]\n"
# end of depth map block
append out "TransformEnd\n"
return $out
}
#___________________________________________________
#___________________________________________________
# OUTPUT
#___________________________________________________
# Here are two ways to obtain the output from the
# blobby procedure. Either use the puts to print
# the text to the console or write it to a file.
# CONSOLE
set rib [blobby 6]
puts $rib
# FILE
set path "/Users/mk/Documents/tutorials"
set fid [open "$path/tcl/examples/blobby.rib" w]
puts $fid $rib
close $fid
|