2016-04-20 58 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 

這是一個簡單的場景。如果您需要動畫/記錄變化的速度,則方法會有所變化。

希望這會讓你開始。