3DS Max - Max Script Slider

时间:2016-04-20 21:38:03

标签: 3dsmax maxscript

我在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

2 个答案:

答案 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)

更改播放速度会改变整个场景。场景中的任何动画都会受到影响...

我如何处理这个问题是为了满足您的特定需求:

  • 将风扇对象/骨骼的旋转控制器更改为线性控制器。
  • 在旋转时设置两个键,一个在第0帧,另一个在第100帧,两者都设置为0。
  • 将旋转曲线设置为范围类型中的/相对重复。
  • 添加一个复选按钮,为UI选择粉丝。 (您可能希望在同一场景中操纵不同的粉丝。)

这是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

这是一个简单的场景。如果你需要动画/记录变化的速度,方法会有所改变。

希望这能让你开始。