v1.0
animmixer
2 つの階層の接続マッピング テンプレートを作成します。
ソースの階層とターゲットの階層のオブジェクト名を自動的にマップする、接続マッピング テンプレートを作成できます。 接続マッピング
テンプレートは、アクション ソースのオブジェクト名とパラメータ名をモデル内で使用されているものに変換するための規則のセットです。
たとえば、LEFTARM という名前のオブジェクトを持つモデルをアニメートするアクションがあるとします。接続マッピング
テンプレートを使用すると、このアクションを left_arm
という名前のオブジェクトを持つ他のモデルに適用することができます。
各モデルは、複数の接続マッピング テンプレートを持つことができ、各テンプレートに対して有効/無効を設定できます。 アクション
クリップをインスタンス化する際に、接続が作成されます。 リスト内の、1 番目に有効なテンプレートの規則が使用されます。
重要: 2
つの階層は正確に同じトポロジでなくてはなりません。すなわち、同じ数の子と同じサブツリー構造である必要があります。
注: このコマンドは、出力引数を使用します。 C#
および一部のスクリプト言語(JScript、PerlScript、Python
など)は、リファレンスによって渡される引数をサポートしていません。このため、状況に応じた適切な回避策を実行する必要があります。
スクリプト言語の場合、このコマンドは出力引数を取得するために使用できる ISIVTCollection を戻します。
C# の場合は、XSIApplication.ExecuteCommand
メソッドを使用してこのコマンドを呼び出すことができます。 ExecuteCommand は、出力引数を C# の
System.Object (出力引数の配列
を含む)にパック化します(詳細については、「C#
からのコマンドの呼び出し」を参照)。
CreateConnectionMap( Obj1, Obj2, [MappingTemplate] ); |
| パラメータ | タイプ | 詳細 |
|---|---|---|
| Obj1 | 文字列 | 接続マップを作成するターゲット階層のルート。 注: このオブジェクトのモデルの下にあるミキサが、新しく作成した接続マップの所有者になります。 デフォルト値:ユーザが指定します。 |
| Obj2 | 文字列 | リファレンス ポーズとして使用する階層のルート。
デフォルト値:ユーザが指定します。 |
| 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 connection map. ' MyCone1 is the target of the map, which will contain mappings ' from the reference hierarchy (MyCone) to the corresonding ' objects in the target (MyCone1) hierarchy. CreateConnectionMap "MyCone1", "MyCone" ' Although it appears that nothing has happened, ' a connection-mapping template was indeed created ' for MyCone1 and its child (since the two hierarchies have ' the same structure). ' You can check for it in the ' Mixer > Templates > Connection Mapping folder in the explorer. ' If you open the property page for the Connection map you will ' see that the rule maps parameters on the objects named MyCone ' and MyCylinder to the corresponding parameters on the objects ' named MyCone1 and MyCylinder1. |