首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >3DS Max - Max脚本滑块

3DS Max - Max脚本滑块
EN

Stack Overflow用户
提问于 2016-04-21 05:38:03
回答 2查看 812关注 0票数 0

我在3DS MAX中制作了一个简单的风扇,并创建了一个GUI来控制该对象。目前,在图形用户界面上,我可以用开/关按钮控制PlayAnimation()和StopAnimation()。但我正在尝试制作一个滑块,它可以控制动画的速度。这将(在这种情况下)增加风扇叶片的转速。

但这就是我被困在这里的地方,我不是100%确定如何做到这一点,并且在谷歌上找不到任何可以帮助我使用Slider来提高动画速度的东西。

任何帮助和指导都将不胜感激!

到目前为止的MaxScript:

代码语言:javascript
运行
复制
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
EN

回答 2

Stack Overflow用户

发布于 2016-04-22 14:44:34

您要查找的是playbackSpeed:

代码语言:javascript
运行
复制
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
票数 0
EN

Stack Overflow用户

发布于 2016-04-25 01:23:40

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

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

  • 将扇形对象/骨骼的旋转控制器更改为线性旋转两个关键点,一个在第0帧处,另一个在第100帧处,这两个关键点的值均设置为0。
  • 将旋转曲线输入/超出范围类型设置为相对重复。
  • 将复选按钮添加到UI以选择风扇。(你可能想在同一场景中操纵不同的风扇)。

下面是ui:

代码语言:javascript
运行
复制
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

这是一个简单的场景。如果您需要对变化的速度进行动画/记录,则方法会稍有变化。

希望这篇文章能帮你入门。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36755688

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档