-- RandomVizGen
-- By Nik Clark http://www.nikclark.com zzubnik@hotmail.com
--
-- This script is for creating random visibility animations
--
--
-- to do
-- help, multiple slections only warning, try and catch, color of bar
-- add "blink in" from spookylights fluorescent light
--
--macroScript RandomVizGen category:"nikclark.com"
(
global startFrame = animationRange.start
global endFrame = animationRange.end
-- type 1
min = 5
max = 5
-- type 2
minOnDuration = 1
maxOnDuration = 8
minAppearanceNum = 1
maxAppearanceNum = 2
(
rollout Controls "Controls"
(
group "Type 1 - many visible"
(
spinner s_min1 "minimum duration" range:[1,1000,5] scale:1 width:80 align:#right
spinner s_max1 "maximum duration" range:[1,1000,5] scale:1 width:80 align:#right
button p_type1 "Go" across:2
checkbox c_autoPlay1 "autoplay" checked:true height:20
)
group "Type 2 - few visible"
(
spinner s_min2 "minimum visible duration" range:[1,1000,1] scale:1 width:80 align:#right
spinner s_max2 "maximum visible duration" range:[1,1000,8] scale:1 width:80 align:#right
spinner s_minApp2 "minimum appearences in animation" range:[1,10,1] scale:1 width:110 align:#right
spinner s_maxApp2 "maximum appearences in animation" range:[1,10,2] scale:1 width:110 align:#right
button p_type2 "Go" across:2
checkbox c_autoPlay2 "autoplay" checked:true height:20
)
group "Playback"
(
button c_play "Play" across:5
button c_stop "Stop" width:37
button c_rew "Rew" align:#right
button c_fr "<" align:#right width:37
button c_ff ">" align:#right width:37
progressBar p_bar value:100 color:green --.value
label t_1 "Ready" align:#center
)
------------ program functions
-- Pre-op functions
fn preop =
(
setWaitCursor()
disableSceneRedraw()
set animate on
)
-- Post-op functions
fn postop = (
enableSceneRedraw()
redrawViews()
set animate off
)
-- sets all visibility keys to off
fn clearout = (
t_1.text = "Preparing keys"
set animate on
disableSceneRedraw()
p_perc=100/(endFrame-startFrame)
p_bar.value = 0
for t = startFrame to endFrame do
(
p_bar.value += p_perc
slidertime = t
for I = 1 to selection.count do
(
$[i].Visibility = false
$[i].Visibility.controller = tcb_float ()
$[i].visibility = off
)
)
enableSceneRedraw()
redrawViews()
set animate off
)
fn clearout2 =
(
for dc = 1 to selection.count do
(
deleteKeys $[dc] #allkeys
)
)
-- creates type 1 random visibility
fn vizzer1 = (
t_1.text = "Processing"
clearout2()
if selection.count > 1 then
(
p_perc=100/selection.count
p_bar.value = 0
for d = 1 to selection.count do
(
p_bar.value += p_perc
$[d].Visibility = false
$[d].Visibility.controller = On_Off ()
f=0
while f < endFrame do
(
sliderTime = f
c = random 0 1
if c > 0.5 then $[d].visibility = on
else $[d].visibility = off
f = f + random min max
)
)
enableSceneRedraw()
redrawViews()
set animate off
slidertime = 0
t_1.text = "Ready"
if c_autoplay1.checked do (playanimation())
)
else
(
for f = startFrame to endFrame do
(
sliderTime = f
c = random 0 1
if c > 0.5 then $.visibility = on
else $.visibility = off
)
)
)
-- creates type 2 random visibility
fn vizzer = (
t_1.text = "Processing"
disableSceneRedraw()
set animate on
p_perc=100/selection.count
p_bar.value = 0
for a = 1 to selection.count do
(
p_bar.value += p_perc
for b = 1 to (random minAppearanceNum maxAppearanceNum) do
(
slidertime = random startFrame endFrame --as integer
for c = 1 to (random minOnDuration maxOnDuration) do
(
slidertime +=1
$[a].visibility = on
)
)
)
enableSceneRedraw()
redrawViews()
set animate off
slidertime = 0
t_1.text = "Ready"
if c_autoplay2.checked do (playanimation())
)
------------ actions
-- type 1 min spinner
on s_min1 changed value do
(
min = s_min1.value
)
-- type 1 max spinner
on s_max1 changed value do
(
max = s_max1.value
)
-- type 2 min spinner
on s_min2 changed value do
(
minOnDuration = s_min2.value
)
-- type 2 max spinner
on s_max2 changed value do
(
maxOnDuration = s_max2.value
)
-- type 2 min appearance spinner
on s_minApp2 changed value do
(
minAppearanceNum = s_minApp2.value
)
-- type 2 max appearance spinner
on s_maxApp2 changed value do
(
maxAppearanceNum = s_maxApp2.value
)
-- type 2 button
on p_type2 pressed do (
clearout()
vizzer()
)
-- type 1 button button
on p_type1 pressed do (
preop()
clearout2()
vizzer1()
postop()
)
-- stop button
on c_stop pressed do (
stopanimation()
--postop()
)
--play button
on c_play pressed do playanimation()
-- rewind button
on c_rew pressed do (
stopanimation()
sliderTime = 0
)
-- frame forward button
on c_ff pressed do (sliderTime = sliderTime +1)
-- frame back button
on c_fr pressed do (sliderTime = sliderTime + (-1))
------------ floater
)
if RandomVizGen != undefined do
(
closeRolloutFloater RandomVizGen
)
RandomVizGen = newRolloutFloater "RandomVizGen" 260 383
addRollout Controls RandomVizGen
)
)