我在3DS MAX中制作一个简单的粉丝,并创建一个GUI来控制对象。在GUI上,我可以使用开/关按钮控制PlayAnimation()和StopAnimation()。但我正在尝试制作一个Slider,然后控制动画的速度。这将(在这种情况下)增加风扇叶片的转速。
但这是我坚持的地方,我不是百分之百确定如何做到这一点,并且在Google上找不到任何可以帮助我使用Slider来提高动画速度的东西。
非常感谢任何帮助和指导!
到目前为止MaxScript:
try(DestroyDialog GUI)catch()
Rollout GUI "GUI"
(
Label lbl_name "Power"
button btn_on "ON" across:2
button btn_off "OFF"
Label lbl_speed "Speed Levels"
Slider slider
on btn_on pressed do
(
PlayAnimation()
)
on btn_off pressed do
(
StopAnimation()
)
//Slider Here...
)
CreateDialog GUI
答案 0 :(得分:0)
您正在寻找playbackSpeed:
try destroyDialog ::GUI catch()
rollout GUI "GUI"
(
checkButton chb_switch "Power" width:50
label lbl_speed "Speed Levels" offset:[0,10]
slider sld_speed type:#integer range:[1,5,timeConfiguration.playbackSpeed]
on chb_switch changed playing do
if playing then playAnimation() else stopAnimation()
on sld_speed changed val do timeConfiguration.playbackSpeed = val
)
createDialog GUI
答案 1 :(得分:0)
更改播放速度会改变整个场景。场景中的任何动画都会受到影响...
我如何处理这个问题是为了满足您的特定需求:
这是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
这是一个简单的场景。如果你需要动画/记录变化的速度,方法会有所改变。
希望这能让你开始。