macroScript NoiseControls category:"Grants" ( -- Based on neils blevins random noise seed script. Extended by grant adam -- ghra@optushome.com.au try (DestroyDialog Noises_change) catch() global Noises_change rollout Noises_change "NoiseControl0.6" ( local randomlow_value = 1, randomhigh_value = 100000 fn changeseed onwhat = ( if onwhat.numsubs != 0 then ( for i = 1 to onwhat.numsubs do ( if onwhat[i] != undefined then ( if classof onwhat[i].controller == Noise_position or classof onwhat[i].controller == noise_float or classof onwhat[i].controller == noise_point3 or classof onwhat[i].controller == noise_rotation or classof onwhat[i].controller == noise_scale then onwhat[i].seed = random randomlow_value randomhigh_value ) changeseed onwhat[i] ) ) ) fn changefreq onwhat = ( if onwhat.numsubs != 0 then ( for i = 1 to onwhat.numsubs do ( if onwhat[i] != undefined then ( if classof onwhat[i].controller == Noise_position or classof onwhat[i].controller == noise_float or classof onwhat[i].controller == noise_point3 or classof onwhat[i].controller == noise_rotation or classof onwhat[i].controller == noise_scale then onwhat[i].frequency = random Noises_change.freqLo.value Noises_change.freqHi.value ) changefreq onwhat[i] ) ) ) fn changeStren onwhat = ( if onwhat.numsubs != 0 then ( for i = 1 to onwhat.numsubs do ( if onwhat[i] != undefined then ( if classof onwhat[i].controller == noise_float then ( onwhat[i].noise_strength = random Noises_change.StrengthLo.value Noises_change.StrengthHi.value ) if classof onwhat[i].controller == Noise_position or classof onwhat[i].controller == noise_point3 or classof onwhat[i].controller == noise_rotation or classof onwhat[i].controller == noise_scale then ( if Noises_change.strenlink.checked then ( local tmpRnd tmpRnd = (random Noises_change.StrengthLo.value Noises_change.StrengthHi.value) onwhat[i].noise_strength = [tmpRnd , tmpRnd , tmpRnd ] ) else (onwhat[i].noise_strength = [(random Noises_change.StrengthLo.value Noises_change.StrengthHi.value), (random Noises_change.StrengthLo.value Noises_change.StrengthHi.value), (random Noises_change.StrengthLo.value Noises_change.StrengthHi.value)]) ) ) changeStren onwhat[i] ) ) ) fn changeRough onwhat = ( if onwhat.numsubs != 0 then ( for i = 1 to onwhat.numsubs do ( if onwhat[i] != undefined then ( if classof onwhat[i].controller == Noise_position or classof onwhat[i].controller == noise_float or classof onwhat[i].controller == noise_point3 or classof onwhat[i].controller == noise_rotation or classof onwhat[i].controller == noise_scale then onwhat[i].Roughness = random Noises_change.rufLo.value Noises_change.rufHi.value ) changeRough onwhat[i] ) ) ) fn changePos onwhat state= ( if onwhat.numsubs != 0 then ( for i = 1 to onwhat.numsubs do ( if onwhat[i] != undefined then ( if classof onwhat[i].controller == noise_float then onwhat[i].positive = state if classof onwhat[i].controller == Noise_position or classof onwhat[i].controller == noise_point3 or classof onwhat[i].controller == noise_rotation or classof onwhat[i].controller == noise_scale then ( if Noises_change.x1.checked do onwhat[i].x_positive = state if Noises_change.y1.checked do onwhat[i].y_positive = state if Noises_change.z1.checked do onwhat[i].z_positive = state ) ) changePos onwhat[i] state ) ) ) fn changeFrac onwhat state= ( if onwhat.numsubs != 0 then ( for i = 1 to onwhat.numsubs do ( if onwhat[i] != undefined then ( if classof onwhat[i].controller == Noise_position or classof onwhat[i].controller == noise_float or classof onwhat[i].controller == noise_point3 or classof onwhat[i].controller == noise_rotation or classof onwhat[i].controller == noise_scale then onwhat[i].fractal = state ) changeFrac onwhat[i] state ) ) ) fn changeRange onwhat = ( if onwhat.numsubs != 0 then ( for i = 1 to onwhat.numsubs do ( if onwhat[i] != undefined then ( if findstring ((classof onwhat[i].controller) as string) "noise" != undefined then setTimeRange onwhat[i].controller animationrange ) changeRange onwhat[i] ) ) ) label lb1 "Operates on Selected Objects:" pos:[16,8] button setRandomSeed "setRandomSeed" pos:[16,40] width:158 height:24 button setRandomFreq "setRandomFrequency" pos:[16,96] width:160 height:21 offset:[0,20] spinner freqHi "Frequency High" fieldwidth:60 height:16 height:16 range:[-1000,1000,1] align:#right spinner freqLo "Frequency Low" fieldwidth:60 height:16 height:16 range:[-1000,1000,0] align:#right button setRandomStrength "setRandomStrength" pos:[16,195] width:160 height:21 spinner StrengthHi "Strength High" fieldwidth:60 height:16 range:[-1000,1000,80] align:#right spinner StrengthLo "Strength Low" fieldwidth:60 height:16 range:[-1000,1000,20] align:#right checkbox strenLink "Link XYZ Strengths" offset:[5,0] button setRandomRough "setRandomRoughness" pos:[16,308] width:160 height:21 spinner rufHi "Rough High" fieldwidth:60 height:16 range:[0,1,0.5] align:#right spinner rufLo "Rough Low" fieldwidth:60 height:16 range:[0,1,0] align:#right button setFractalOn "Fractal On" pos:[8,388] width:80 height:21 across:2 button setFractalOff "Fractal OFF" pos:[96,388] width:87 height:21 button setRandomPosOn "Positive On" pos:[8,415] width:80 height:21 across:2 button setRandomPosOff "Positive OFF" pos:[96,415] width:88 height:21 label lb2 "Point3 Pos:" across:4 offset:[5,0] checkbox x1 "X" offset:[20,0] checked:true checkbox y1 "Y" offset:[20,0] checked:true checkbox z1 "Z" offset:[20,0] checked:true button setRanges "setRangesToAnimation" width:176 height:21 GroupBox grp1 "Seed" pos:[6,24] width:178 height:48 GroupBox grp2 "Frequency" pos:[6,80] width:178 height:90 GroupBox grp5 "Strength" pos:[8,178] width:176 height:105 GroupBox grp6 "Roughness" pos:[8,290] width:176 height:90 -- Script -- on setRandomSeed pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerRandomSeed") else ( undo "NoiseControllerRandomSeed" on ( if (queryBox "Apply a random seed to all noise controllers in selection?" title:"NoiseControllerRandomSeed") == true then ( for i in selection do changeseed i ) ) ) ) on setRandomFreq pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerRandomFreq") else ( undo "NoiseControllerRandomFreq" on ( if (queryBox "Apply a random frequency to all noise controllers in selection?" title:"NoiseControllerRandomFreq") == true then ( for i in selection do changeFreq i ) ) ) ) on setRandomStrength pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerRandomStrength") else ( undo "NoiseControllerRandomStrength" on ( if (queryBox "Apply a random strength to all noise controllers in selection?" title:"NoiseControllerRandomSeed") == true then ( for i in selection do changeStren i ) ) ) ) on setRandomRough pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerRandomStrength") else ( undo "NoiseControllerRandomStrength" on ( if (queryBox "Apply a random strength to all noise controllers in selection?" title:"NoiseControllerRandomSeed") == true then ( for i in selection do changeRough i ) ) ) ) on setFractalOn pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerPositive") else ( undo "NoiseControllerPosState" on ( if (queryBox "Set all noise controllers in selection so 'Fractal' is on?" title:"NoiseControllerPositive") == true then ( for i in selection do changeFrac i true ) ) ) ) on setFractalOff pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerPositive") else ( undo "NoiseControllerPosState" on ( if (queryBox "Set all noise controllers in selection so 'Fractal' is off?" title:"NoiseControllerPositive") == true then ( for i in selection do changeFrac i false ) ) ) ) on setRandomPosOn pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerPositive") else ( undo "NoiseControllerPosState" on ( if (queryBox "Set all noise controllers in selection so 'Positive' is on?" title:"NoiseControllerPositive") == true then ( for i in selection do changePos i true ) ) ) ) on setRandomPosOff pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerPositive") else ( undo "NoiseControllerPosState" on ( if (queryBox "Set all noise controllers in selection so 'Positive' is off?" title:"NoiseControllerPositive") == true then ( for i in selection do changePos i false ) ) ) ) on setRanges pressed do ( if selection.count == 0 then (MessageBox "Please select at least one object" title:"NoiseControllerRandomSeed") else ( undo "NoiseControllerRandomSeed" on ( if (queryBox "Set all noise controller ranges in selection to animation length?" title:"NoiseControllerRandomSeed") == true then ( for i in selection do changeRange i ) ) ) ) ) CreateDialog Noises_change width:191 height:482 --pos:[1100,650] )