Changing the playback speed changes it for the entire scene. Anything animated in the scene will be affected...
How I'd approach this is for your specific needs:
- Change the fan object/bone's rotation controller to a linear controller.
- Set two keys on rotation, one at frame 0 and another at frame 100, both set with a value of 0.
- Set the rotation curve in/out of range types, to relative repeat.
- Add a check button to select your fan to the UI. (You might want to manipulate different fans in the same scene).
Here's the ui:
try destroyDialog ::GUI catch()
rollout GUI "GUI"
(
-- this local variable stores the two initial keys of your fan
local keys = undefined
pickbutton pkb_fan "Select Fan" message:"Please select animated fan" autoDisplay:true
checkbutton chb_switch "Power"
slider sld_speed "Fan Speed" type:#float range:[0, 100.0, 0]
-- when the fan is selected, assign its linear rotation keys to the keys variable
on pkb_fan picked obj do
(
if (obj != undefined) then
(
keys = obj.rotation.controller.keys
)
else (keys = undefined)
)
-- turning on the fan is setting the second key frame's rotation to a
-- non-zero value.
-- turning it off is setting it to zero.
-- in this scenario the fan is rotating on its Y axis.
on chb_switch changed playing do
(
if (keys != undefined) and (keys.count >= 2) then
(
if (playing) then (keys[2].value = quat 0 1 0 1)
else (keys[2].value = quat 0 0 0 1)
)
)
-- changing the speed of the fan is moving the second keyframe; assuming
-- the key frame value is always the same,
-- the closer it moves to the first key frame, the faster it spins, the
-- more distant, the slower it spins
on sld_speed changed val do
(
if (keys != undefined) and (keys.count >= 2) then
(
local t = 0f
if (val > 0.0) then (t = 1.0 / val * 100.00)
keys[2].time = t
)
)
)
createDialog GUI
This is a simple scenario. If you need to animate/record the varying speed, the approach changes somewhat.
Hopefully this gets you started.