コントローラ値の設定関数

次の関数を使用すると、アニメーション カーブの値を設定した後に値の変更をコミットまたは破棄できるため、絶対値または相対値を使用したコントローラ値の調整、アニメーション キーの設定、またはアニメーション カーブ全体の移動を行うことができます。3ds Max 2017 以降で使用可能です。

関数 :

<value>SetControllerValue <controller>target <value>newValue <boolean>setKey <enum>{mode:#absolute|#relative}

4番目の引数が #absolute の場合は、最初の引数で指定されたコントローラを 2 番目の引数で指定された絶対値に設定します。4 番目の引数が #relative の場合は、2 番目の引数の分だけ既存の値を増分します。

3 番目の引数が True に設定されている場合に、オートキー モードで、またはアニメーションのコンテキスト内でこの関数が呼び出されると、コントローラの現在時刻に新しいアニメーション キーが作成されます。

3 番目の引数が False に設定されていて、現在のスライダ時刻に既存のキーがある場合に、オートキー モードで、またはアニメーションのコンテキスト内でこの関数が呼び出されると、既存のキーが新しい値に設定され、アニメーション カーブがそれに関連して一時的に移動します。現在時刻を変更するか、RestoreControllerValue() を呼び出すと、値の変更が破棄されます。

CommitControllerValue() 関数を呼び出すと、変更が既に破棄されている場合をのぞき、変更がコミットされて、すべての既存キーが新しい値に更新されます。

<void>CommitControllerValue <controller>target

3 番目の引数が False に設定されている場合に SetControllerValue() を使用して適用されたコントローラ値を一時的に変更すると、その変更が永久的なものになります。

この関数が呼び出されていない場合は、現在時刻を変更すると変更がすぐに破棄されます。

RestoreControllerValue() 関数が SetControllerValue() および CommitControllerValue() 呼び出しの後に呼び出された場合、この関数は無効です。

<void>RestoreControllerValue <controller>target

3 番目の引数が False に設定されている場合に SetControllerValue() を使用して適用されたコントローラ値を一時的に変更すると、その変更は破棄されます。

これを使用すると、SetControllerValue() を呼び出した後にタイム スライダを移動するのと同様な結果を得ることができますが、UI が更新されて値がリセットされることはありません。

CommitControllerValue() を使用して変更が既にコミットされている場合や、アニメーション キーを設定するために SetControllerValue() の 3 番目の引数が True に設定されている場合は、無効です。

例:

    b = box()
    --> $Box:Box001 @ [0.000000,0.000000,0.000000]
    c = b.height.controller = newDefaultFloatController()
    --> Controller:Bezier_Float
    setControllerValue c 100 true #absolute
    --> 100
    c.value
    --> 100.0
    setControllerValue c -10 true #relative
    --> -10
    c.value
    --> 90.0

    sliderTime = 0 --make sure the time slider is on frame 0
    --> 0
    select b --select the box
    --> OK
    max modify mode --show the box in the modify panel
    --> OK

    --Try to set an animation key with value 90+50=140 on frame 50 with the third argument set to false
    with animate on at time 100 setControllerValue c 50 false #relative
    --> 50
    c.keys --there are no keys created, and the box is now 140 units tall
    --> #keys()
    c.value
    --> 140

    --Now let's set the third argument to true to create animation keys:
    with animate on at time 100 setControllerValue c -40 true #relative
    --> -40

    --Checking the keys, the first key has the previous controller value 140 on frame 0
    --The second key has the new value of 100 at frame 100:
    for k in c.keys do format "% = %\n" k (k.value)
    --> #Bezier Float key(1 @ 0f) = 140.0
    --> #Bezier Float key(2 @ 100f) = 100.0

    sliderTime = 100    
    --Now let's try to temporarily modify the second key on frame 100 to an absolute value of 200:
    with animate on at time 100 setControllerValue c 200 false #absolute
    --> 200
    --The command panel shows Height: 200.0 on frame 50, however
    --checking the keys, they still show the original values of 140.0 and 100.0:
    for k in c.keys do format "% = %\n" k (k.value)
    --> #Bezier Float key(1 @ 0f) = 140.0
    --> #Bezier Float key(2 @ 100f) = 100.0
    sliderTime -= 1
    --> 49
    sliderTime += 1
    --> 50
    --At this point, the Modify Panel will show 100.0 again, as the uncommited value was reset back.

    --Let's do this again, but this time we will commit after the change:
    with animate on at time 100 setControllerValue c 200 false #absolute
    --> 200
    CommitControllerValue c --commit the change
    --> OK
    --At this point, moving the time slider will not reset the new value anymore, it is committed to 200.0.
    --But in addition, the first key on frame 0 was also shifted to 240.0!
    for k in c.keys do format "% = %\n" k (k.value)
    --> #Bezier Float key(1 @ 0f) = 240.0
    --> #Bezier Float key(2 @ 100f) = 200.0

    with animate on at time 50 setControllerValue c 42 true #absolute
    --> 42
    sliderTime = 50
    --> 50
    with animate on at time 50 setControllerValue c 24 false #absolute
    --> 24
    RestoreControllerValue c --we take back the change internally, but the Modify Panel still shows 42.0
    --> OK
    CommitControllerValue c --try to commit the change of 24.0 to the key and shift the whole animation curve
    --> OK
    sliderTime = 49
    --> 49
    sliderTime = 50
    --> 50
    --Since we restored the controller value before the commit, the value at frame 50 remains 42 and is not shifted to 24.
    --The same is true for all other keys:
    for k in c.keys do format "% = %\n" k (k.value)
    --> #Bezier Float key(1 @ 0f) = 240.0
    --> #Bezier Float key(2 @ 50f) = 42.0
    --> #Bezier Float key(3 @ 100f) = 200.0