次の例は、トラックバー キー フィルタ関数を実装する方法を示しています。
表示キーのみを表示するフィルタを登録するには、
次のように記述します。 |
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 を返します。
走査するノードのクラスか名前でキーをフィルタ処理するフィルタ関数を定義できます。
例 |
--this function will show keys only of Sphere class nodes: fn filterSphereKeys theAnim theParent theIndex theGParent theNode = ( classof theNode == Sphere ) |
--this function will show keys only of objects whose name starts with "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 )
ボックスなどのオブジェクトをシーンに作成してアニメーション モードを[キーを設定](Set Key)に設定し、[キー](Key)ボタンをクリックして位置のアニメートを開始します。次の関数では、キーが 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 --Define a rollout with a spinner 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 ) ) --Create a dialog, register as DialogBar and dock at bottom createDialog MassiveKeysFilterCount 120 25 cui.RegisterDialogBar MassiveKeysFilterCount style:#(#cui_dock_all) cui.DockDialogBar MassiveKeysFilterCount #cui_dock_bottom --Define, register and enable the key filter functions: 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 )--end script |