トラックバー フィルタ コールバック関数の例
 
 
 

次の例は、トラックバー キー フィルタ関数を実装する方法を示しています。

表示キー フィルタ関数の例

表示キーのみを表示するフィルタを登録するには、

次のように記述します。

fn filterVisibilityKeys theAnim theParent theIndex theGParent theNode =
(
if theParent != undefined then
theParent[theIndex].name == "Visibility"
else
false
)
fn testCallbackAdditionFunction arg1 arg2 = (true)
theInterface = maxOps.trackbar
theIndex = theInterface.registerFilter filterVisibilityKeys callbackAdditionFunction "Visibility" 8 active:true stopTraversal:false

このフィルタ関数は、親が未定義でなく、親の subAnim インデックス付きトラックが「Visibility」と呼ばれる場合に限って true を返します。

表示トラック キー フィルタ関数を定義する、より高速で適切な方法は、次のとおりです。

fn filterVisibilityKeys theAnim theParent theIndex theGParent theNode = ( theIndex == 2 and theParent == theNode )

親がノード自体であり、インデックスが 2 で表示トラックに対応する場合に限って、この関数は true を返します。

名前およびクラスのフィルタ関数の例

走査するノードのクラスか名前でキーをフィルタ処理するフィルタ関数を定義できます。

-- この関数では、Sphere クラス ノードのみのキーが表示されます。
fn filterSphereKeys theAnim theParent theIndex theGParent theNode = ( classof theNode == Sphere )
-- この関数では、名前が「Sphere」で始まるオブジェクトのみのキーが表示されます。
fn filterSphereByNameKeys theAnim theParent theIndex theGParent theNode = ( substring theNode.name 1 6 == "Sphere")

キー カウント フィルタ関数の例

あるケースでは、たとえば reactor を使用してアニメートしたり、MAXScript を使用してフレームごとにアニメーションをキーにベイクしたりする場合、trackBar は、数百や数千のキーを表示しようとするため、非常に遅くなることがあります。

次の関数では、キーが 10 個未満であるコントローラのみのキーが表示されます。

fn filterNonMassiveKeys theAnim theParent theIndex theGParent theNode = (superClassof theAnim == FloatController and theAnim.keys.count < 10 )

ボックスなどのオブジェクトをシーンに作成してアニメーション モードを[キーを設定]に設定し、[キー]ボタンをクリックして位置のアニメートを開始します。次の関数では、キーが 10 個未満であるコントローラのみのキーが表示されます。 グローバル変数を定義すると、同時に表示するキーの数を制御できます。

例:

global maxNumberOfKeysInTrackbar = 50
fn filterNonMassiveKeys theAnim theParent theIndex theGParent theNode = ( superClassof theAnim == FloatController and theAnim.keys.count < maxNumberOfKeysInTrackbar )

グローバル変数 maxNumberOfKeysInTrackbar に保存されている値を変更するだけで、コントローラに含めて trackBar に表示できるキーの数を制御できます。編集ボックスを含む小さいダイアログ ボックスを定義して UI にドッキングし、キー表示を対話的に制御することもできます。

スクリプト:

(
try(cui.UnRegisterDialogBar MassiveKeysFilterCount)catch()
try(destroyDialog MassiveKeysFilterCount)catch()
global maxNumberOfKeysInTrackbar = 20
-- スピナを含むロールアウトを定義します。
rollout MassiveKeysFilterCount "Keys Limit"
(
spinner massive_count "Max.Keys:" range:[10,1000,20] type:#integer fieldwidth:40
on massive_count changed val do
maxNumberOfKeysInTrackbar = val
select selection
)
-- ダイアログ ボックスを作成して DialogBar として登録し、下部にドッキングします。
createDialog MassiveKeysFilterCount 120 25
cui.RegisterDialogBar MassiveKeysFilterCount style:#(#cui_dock_all)
cui.DockDialogBar MassiveKeysFilterCount #cui_dock_bottom 
-- キー フィルタ関数の定義、登録、有効化を行います。
fn callbackAdditionFunction arg1 arg2 = (true)
fn filterNonMassiveKeys theAnim theParent theIndex theGParent theNode =
(
superClassof theAnim == FloatController and theAnim.keys.count < maxNumberOfKeysInTrackbar
)
theIndex = (maxOps.trackBar).registerFilter filterNonMassiveKeys callbackAdditionFunction "Massive Keys Filter" 13 active:true stopTraversal:false
)-- スクリプト終了 
関連事項