home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / vrml / cp2b2x.exe / DATA.Z / sphere.tcl < prev    next >
Text File  |  1996-06-26  |  1KB  |  54 lines

  1. # Initialize
  2. set bColor 0
  3. proc vs_H_InitMove { obj event userdata } {
  4.     vsNewVariable $obj flg 0    ;# move direction
  5.     vsNewVariable $obj count 0    ;# counter
  6. }
  7.  
  8. # move 
  9. proc vs_H_PeriodicMove { obj event userdata } {
  10.     global vsCSLocal vsRelative vsSuccess vsCSWorld vsAbsolute
  11.     global vsContinue vsStop
  12.  
  13.     set local_count [ vsGetVariable $obj count ]
  14.     set local_flg [ vsGetVariable $obj flg ]
  15.  
  16.     if { $local_flg } {
  17.         set ret [ vsTranslate $obj 0.0 0.8 0.0 $vsCSWorld $vsRelative ]
  18.     } else {
  19.         set ret [ vsTranslate $obj 0.0 -0.8 0.0 $vsCSWorld $vsRelative ]
  20.     }
  21.     if { $ret != $vsSuccess } {
  22.         vsWarning "vsTranslate failed"
  23.     }
  24.  
  25.     # increment count
  26.     set local_count [ expr $local_count + 1 ]
  27.  
  28.     if { $local_count >= 40 } {
  29.         set local_flg [ expr ~$local_flg ]
  30.         set local_count 0
  31.     } 
  32.  
  33.     # store variables
  34.     vsSetVariable $obj count $local_count
  35.     vsSetVariable $obj flg $local_flg
  36.  
  37.     return $vsContinue
  38. }    
  39.  
  40.  
  41. proc myClickColor { obj event userData } {
  42.    global bColor
  43.    global vsDiffuse
  44.  
  45.   if {$bColor == 0} {
  46.     set bColor 1
  47.     vsSetObjAllMaterial $obj $vsDiffuse 1 0 0
  48.   } elseif {$bColor == 1} {
  49.     set bColor 0
  50.     vsSetObjAllMaterial $obj $vsDiffuse 0 0.8 0.8
  51.   }
  52. }
  53.  
  54.