-- Blinker -- Dani Rosen - Jul 17, 2006 -- Automatically or manually add blinks to a blink morph-target -- v1.01 - Dec 08, 2007 - changed default morpher-target name macroScript Blinker category:"DaniTools" internalcategory:"DaniTools" tooltip:"Blinker" buttontext:"Blinker" Icon:#("TrackViewTools",43) ( global my_head = undefined global lastKey rollout Blinker "Blinker v1.01" width:278 height:340 ( groupBox BlinkGroup "Blinker" pos:[6,5] width:265 height:325 pickButton bHead "Pick Head" pos:[75,25] width:130 height:25 button bAbout "?" tooltip:"About" height:15 width:15 pos:[260,5] label lBlinkMorph "Blink Morph Name:" pos:[34,63] editText eBlinkMorph "" text:"Blink" pos:[130,60] width:110 height:20 label lbTimeRange "TimeRange:" pos:[100,90] spinner sTimeStart "Start:" range:[0,10000,animationrange.start] type:#integer pos:[60,108] width:60 height:30 spinner sTimeEnd "End:" range:[0,10000,animationrange.end] type:#integer pos:[165,108] width:60 height:30 label lbBlinkIntervals1 "Auto Blink Random Intervals:" pos:[65,135] label lbBlinkIntervals3 "Between" pos:[30,155] label lbBlinkIntervals4 "and" pos:[130,155] label lbBlinkIntervals5 "Seconds" pos:[208,155] spinner BlinkIntervals1 "" range:[0.1,10,2.5] pos:[78,153] width:45 height:30 spinner BlinkIntervals2 "" range:[0.1,10,4] pos:[158,153] width:45 height:30 label lbBlinkSpeed "Blink Speed:" pos:[100,183] label lbFast "Fast" pos:[15,192] label lbSlow "Slow" pos:[240,192] slider BlinkSpeed "" range:[1,12,3] type:#integer ticks:9 pos:[21,205] width:250 height:30 button AddBlinks "Add Auto Blinks" pos:[85,245] width:120 height:30 button ClearBlinks "Clear Blinks" pos:[30,295] width:90 height:24 button SingleBlink "Single Blink Here" pos:[145,295] width:100 height:24 on bHead picked obj do ( try -- test if morpher exists on object ( If IsValidMorpherMod obj.morpher == true then my_head = obj bHead.text=obj.name ) catch ( messagebox "Object does not have a Morpher modifier" my_head=undefined ) ) -- close bHead on AddBlinks pressed do ( if my_head != undefined then ( global foundBlink = false for t = 1 to 100 do ( morpherName = WM3_MC_GetName my_head.Morpher t if (matchPattern morpherName pattern:eBlinkMorph.text) then ( lastKey = sTimeStart.value While lastKey < sTimeEnd.value do ( RandomKey = (random BlinkIntervals1.value BlinkIntervals2.value) * framerate lastKey = lastKey + RandomKey addnewkey my_head.morpher[t] lastKey with animate on ( at time lastKey my_head.morpher[t].value = 0 at time (lastKey + BlinkSpeed.value) my_head.morpher[t].value = 100 at time (lastKey + BlinkSpeed.value + BlinkSpeed.value) my_head.morpher[t].value = 0 ) lastKey = lastKey + BlinkSpeed.value + BlinkSpeed.value ) foundBlink = true ) ) if foundBlink == false then ( messagebox "no valid Blink morpher found" return 0 ) ) else ( messagebox "No Head selected" return 0 ) ) on SingleBlink pressed do ( if my_head != undefined then ( global foundBlink = false for t = 1 to 100 do ( morpherName = WM3_MC_GetName my_head.Morpher t if (matchPattern morpherName pattern:eBlinkMorph.text) then ( with animate on ( at time currenttime my_head.morpher[t].value = 0 at time (currenttime + BlinkSpeed.value) my_head.morpher[t].value = 100 at time (currenttime + BlinkSpeed.value + BlinkSpeed.value) my_head.morpher[t].value = 0 ) foundBlink = true ) ) if foundBlink == false then ( messagebox "no valid Blink morpher found" return 0 ) ) else ( messagebox "No Head selected" return 0 ) ) on ClearBlinks pressed do ( if queryBox "Are you sure you want to delete Blink keys?" then ( if my_head != undefined then ( global foundBlink = false for t = 1 to 100 do ( morpherName = WM3_MC_GetName my_head.Morpher t if (matchPattern morpherName pattern:eBlinkMorph.text) then ( deleteKeys my_head.Morpher[t] #allKeys messagebox "Blink keys cleared!" foundBlink = true ) ) if foundBlink == false then ( messagebox "no valid Blink morpher found" return 0 ) ) else ( messagebox "No Head selected" return 0 ) ) ) on bAbout pressed do ( rollout rolAbout "About" ( label ab1 "Blinker v1.01" label ab2 "Dani Rosen \xa9 2007" progressBar horizLine "ProgressBar" height:3 enabled:true value:100 color:(color 10 10 0) label ab3 "Used to add blinks on the Blink morph target." height:20 label ab4 "The \"Auto Blink Random Intervals\" determines the" label ab5 "spacing from one blink to another. It's a random" label ab6 "number (in seconds) between the two values entered." height:20 label ab7 "Regular blinks should be on either the second or" label ab8 "third notch of the Blink-Speed." height:20 label ab9 "\"Single Blink Here\" adds a single blink at current time." ) createdialog rolAbout width:280 height:200 ) ) createdialog Blinker )