v1.0
animmixer
2 つの階層を移動し、階層の変換の差を計算し、最初の階層のグローバル バリュー マッピング テンプレートに差を出力します。
バリュー マッピング テンプレートを使用すると、クリップを作成した際、アクションのアニメーションの値を自動的に変更することができます。
たとえば、オフセットを追加して、2 つのキャラクタが同じタイミングで同じ場所を歩かないようにできます。 接続マッピング
テンプレートと同様に、バリュー マッピング テンプレートでは、アクションを実行する前に情報をマップできます。
各モデルには複数のバリュー マッピング テンプレートを設定でき、個々のテンプレートはアクティブまたは非アクティブにできます。
テンプレートの順番は作成順で、Explorer にリストされている順です。 2
つのオブジェクト間の現行変換値のオフセットを含んだテンプレートを自動的に作成できます。または、空のバリュー マッピング
テンプレートを作成して、規則を手動で追加することもできます。
重要: 2
つの階層は正確に同じトポロジでなくてはなりません。すなわち、同じ数の子と同じサブツリー構造である必要があります。
注: このコマンドは、出力引数を使用します。 C#
および一部のスクリプト言語(JScript、PerlScript、Python
など)は、リファレンスによって渡される引数をサポートしていません。このため、状況に応じた適切な回避策を実行する必要があります。
スクリプト言語の場合、このコマンドは出力引数を取得するために使用できる ISIVTCollection を戻します。
C# の場合は、XSIApplication.ExecuteCommand
メソッドを使用してこのコマンドを呼び出すことができます。 ExecuteCommand は、出力引数を C# の
System.Object (出力引数の配列を含む)にパック化します(詳細については、「C#
からのコマンドの呼び出し」を参照)。
CreateValueMap( [Obj1], [Obj2], [Mode], [Scope], [UseNames], [MappingTemplate] ); |
| パラメータ | タイプ | 詳細 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Obj1 | 文字列 | バリューマップを作成するターゲット階層のルート。 注: このオブジェクトのモデルの下にあるミキサが、新しく作成した値マップの所有者になります。 デフォルト値:ユーザが指定します。 |
||||||||||||
| Obj2 | 文字列 | リファレンス ポーズとして使用する階層のルート
デフォルト値:ユーザが指定します。 |
||||||||||||
| Mode | Integer | バリュー マップの相違を評価する際に考慮する、ポーズの部分を指定します。
デフォルト値:4(すべての差分)
|
||||||||||||
| Scope | Integer | ローカル変換またはグローバル変換で差分を計算するかを指定します。
デフォルト値: 1 (ローカル)
|
||||||||||||
| UseNames | ブール | 階層の比較方法を指定します。
デフォルト値: False
|
||||||||||||
| MappingTemplate | Property | 新しいマッピング テンプレートを戻します。 |
' This example illustrates various mapping template commands,
' for both connection and value mapping templates -- in particular
' how to create them and look at the data contained in them.
NewScene , False
' Create some objects for our example.
set oParent = CreatePrim( "Sphere", "MeshSurface", "Parent" )
set oChild = CreatePrim( "Cone", "MeshSurface", "Child", oParent )
posParams = "/kine.local.posx,kine.local.posy,kine.local.posz"
' Animate the sphere moving horizontally and the
' cone (child) moving down.
SetPositionKey oParent, 1, -5, 0, 0
SetPositionKey oParent, 50, 5, 0, 0
SetPositionKey oChild, 1, 0, 0, 0
SetPositionKey oChild, 50, 0, -2, 0
' Store an Action of this animation (on both objects).
set oSource = StoreAction( , oParent & "," & oChild & posParams, 2, _
"Fun", True, 1, 50 )
' We want to map the animation to another "character", so we will
' use a connection mapping template. CreateConnectionMap can look
' at identical hierarchies and automatically build an appropriate
' map. (or you could build it yourself manually or using scripting)
' Here we'll build a hierarchy and use the auto-matching capability...
set oParent2 = CreatePrim( "Cube", "MeshSurface", "Top" )
set oChild2 = CreatePrim( "Cylinder", "MeshSurface", "Bottom", oParent2 )
' Translate it so we can demonstrate value mapping templates.
Translate oParent2, 2, 5, 0, siAbsolute, siView, siObj, siXYZ
Translate oChild2, 2, -5, 0, siAbsolute, siView, siObj, siXYZ
' Instantiate a clip driving the objects on which the animation was
' originally authored, for comparison.
set oClip = AddClip( "Scene_Root", oSource, , , 1, "Original" )
' Now create the connection map so we can apply the original animation
' on the other hierarchy. Also, create a value map which will build
' offset expressions using the pose differences between the objects.
CreateConnectionMap oParent2, oParent, oCnxMap
CreateValueMap oParent2, oParent, 3, 1, False, oValMap
' Instantiate a clip which uses the connection map to remap to the
' second set of objects. Also use the value map to create a clip
' effect with the appropriate offset for the second hierarchy.
set oClip = AddClip( "Scene_Root", oSource, , , 1, "Remapped", oCnxMap, oValMap )
' Let's take a look at the connection and value mapping templates
' that were created and used.
DumpTemplateInfo oCnxMap
DumpTemplateInfo oValMap
' Finally, a clip itself can be treated as a (value) mapping template.
' Let's look at one...
DumpTemplateInfo oClip & ".actionclip"
'==================================================
' Helper method to key an object somewhere at a given frame.
'==================================================
sub SetPositionKey( in_oObj, in_frame, in_posX, in_posY, in_posZ )
Translate in_oObj, in_posX, in_posY, in_posZ, siAbsolute, siParent, siObj, siXYZ
SaveKey in_oObj & posParams, in_frame
end sub
'==================================================
' Helper method to dump some mapping template info.
'==================================================
sub DumpTemplateInfo( in_Templ )
' Get the actual object referenced by name in the argument.
set oTempl = GetValue( in_Templ )
msg = "Template: " & oTempl.fullname & Chr(10)
numRules = GetNumMappingRules( in_Templ )
if oTempl.type = "actionclip" then
msg = msg & "(Clip acting as value map)" & Chr(10)
bSupportsActive = true
else
bSupportsActive = false
end if
for i = 1 to numRules
GetMappingRule in_Templ, i, param, expr, active
msg = msg & Chr(9) & "Rule " & i & ": "
if bSupportsActive then
if active then
msg = msg & "( active ) "
else
msg = msg & "(inactive) "
end if
end if
msg = msg & param & " -> " & expr & Chr(10)
next
LogMessage msg
end sub
' Running this script should log the following:
' ---------------------------------------------
'INFO : "Template: Mixer.MappingTemplate
' Rule 1: Parent -> Top
' Rule 2: Child -> Bottom
'"
'INFO : "Template: Mixer.ValueMappingTemplate
' Rule 1: Top.kine.local.posx -> this + -3.000000
' Rule 2: Top.kine.local.posy -> this + 5.000000
' Rule 3: Top.kine.local.posz ->
' Rule 4: Bottom.kine.local.posx ->
' Rule 5: Bottom.kine.local.posy -> this + -8.000000
' Rule 6: Bottom.kine.local.posz ->
'"
'INFO : "Template: Mixer.Mixer_Anim_Track1.Remapped.actionclip
'(Clip acting as value map)
' Rule 1: ( active ) Top.kine.local.posx -> this+-3.000000
' Rule 2: ( active ) Top.kine.local.posy -> this+5.000000
' Rule 3: ( active ) Top.kine.local.posz ->
' Rule 4: ( active ) Bottom.kine.local.posx ->
' Rule 5: ( active ) Bottom.kine.local.posy -> this+-8.000000
' Rule 6: ( active ) Bottom.kine.local.posz ->
'"
|
' Create first hierarchy CreatePrim "Cone", "NurbsSurface", "MyCone" CreatePrim "Cylinder", "NurbsSurface", "MyCylinder", "MyCone" SetValue "MyCylinder.cylinder.height", 2 ' Create second hierarchy translated from the first one CreatePrim "Cone", "NurbsSurface", "MyCone1" Translate , 5, 0, 0, siAbsolute, siParent, SiObj, siX CreatePrim "Cylinder", "NurbsSurface", "MyCylinder1", "MyCone1" Translate , , , , siAbsolute, siParent ' Create a value map. ' Put local translation differences into the template, ' and use topology based hierarchy matching, starting ' with MyCone1 as the reference. CreateValueMap "MyCone", "MyCone1", 3, 1, False ' Although it appears that nothing has happened, ' a value-mapping template was indeed created for MyCone. ' You can check for it in the ' Mixer > Templates > Value Mapping folder in the explorer. ' If you open the Value Mapping Template, you will see a translation ' of -5 along the X axis for MyCone relative to MyCone1 |