2016-04-20 103 views
0

我在3DS MAX中制作一个简单的风扇,并创建一个GUI来控制对象。目前在GUI上,我可以用On/Off按钮控制PlayAnimation()和StopAnimation()。但我试图制作一个滑块,然后控制动画的速度。这将(在这种情况下)增加风扇叶片的转速。3DS Max - 最大脚本滑块

但是,这是我坚持的地方,我不是100%确定如何做到这一点,并且在Google上找不到任何可以帮助我使用滑块来提高动画速度的任何内容。

任何帮助和指导将非常感激!

的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

您正在寻找的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 
0

改变播放速度来改变它为整个场景。任何场景中的动画将受到影响......

我如何想办法这是您的特定需求:

  • 改变风机的对象/骨骼的旋转控制器,线性控制器。
  • 设置两个旋转键,一个在第0帧,另一个在第100帧,都设置为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 

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

希望这会让你开始。