我在3DS MAX中制作了一个简单的风扇,并创建了一个GUI来控制该对象。目前,在图形用户界面上,我可以用开/关按钮控制PlayAnimation()和StopAnimation()。但我正在尝试制作一个滑块,它可以控制动画的速度。这将(在这种情况下)增加风扇叶片的转速。
但这就是我被困在这里的地方,我不是100%确定如何做到这一点,并且在谷歌上找不到任何可以帮助我使用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
发布于 2016-04-22 14:44:34
您要查找的是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
发布于 2016-04-25 01:23:40
更改播放速度会更改整个场景的播放速度。场景中的任何动画都将受到影响...
我如何处理这是为了满足您的特定需求:
下面是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
这是一个简单的场景。如果您需要对变化的速度进行动画/记录,则方法会稍有变化。
希望这篇文章能帮你入门。
https://stackoverflow.com/questions/36755688
复制相似问题