AddMappingRule

導入

v1.0

詳細

既存の接続マッピング テンプレートまたはバリュー マッピング テンプレートにルールを追加します。

スクリプト構文

AddMappingRule( MappingTemplate, From, [To], Index );

パラメータ

パラメータ タイプ 説明
MappingTemplate 文字列 ルールを追加するマッピング テンプレート
From 文字列 接続マッピング ルールの[マップ元:]、バリュー マッピング ルールのパラメータ、またはクリップのバリュー マッピング ルールの[項目] 部分。
To 文字列 接続マッピング ルールの[マップ先:]、バリュー マッピング ルールのエクスプレッション、またはクリップのバリュー マッピング ルールの[Expr] 部分。
Index Integer マッピング テンプレート内のルールの挿入場所を指定します。 ルールは 1 から順に番号が割り当てられますが、0 または 1 のインデックスは最初のルールを参照します。 インデックスがマッピング テンプレートのサイズを超えた場合は、末尾にルールが追加されます。

デフォルト値: 0

VBScript の例

' This example illustrates several mapping template commands.

' It creates an Action on a sphere, then uses a value mapping

' template to create an offset effect when this Action is instanced.

' Then it creates a connection mapping template so the sphere

' animation can be applied to a number of different objects (using a

' wildcard to do this).  Finally, the second clip (driving the cones)

' is accessed as a value map itself, and clip effects on it are

' created using SetMappingRule.

NewScene , False

' Create some objects for our example.

set oSphere = CreatePrim( "Sphere", "MeshSurface" )

set oCone = CreatePrim( "Cone", "MeshSurface" )

Duplicate oCone, 4

posParams = "/kine.local.posx,kine.local.posy,kine.local.posz"

' Make an Action with the sphere moving diagonally.

SetPositionKey oSphere, 1, -5, -3, 0

SetPositionKey oSphere, 50, 5, 3, 0

set oSource = StoreAction( , oSphere & posParams, 2, "Diagonal", True, 1, 50 )

' Create a value map and add some rules to it to map the

' sphere animation to be negated in X position and offset

' in Y.  We use a big index to indicate the rule should

' be added at the end.

CreateEmptyValueMap "Scene_Root", oValMap

AddMappingRule oValMap, oSphere & ".kine.local.posx", "(this)*-1", 10000

AddMappingRule oValMap, oSphere & ".kine.local.posy", "(this)-5", 10000

' Instantiate a clip which uses this value map to modify

' the sphere animation.

set oClip = AddClip( "Scene_Root", oSource, , , 1, "Sphere", , oValMap )

' Create a connection map, and add a single rule to it

' that will map the sphere animation to all cones, using

' a wildcard.

CreateEmptyConnectionMap "Scene_Root", oCnxMap

AddMappingRule oCnxMap, oSphere, "cone*"

' Instantiate a clip which uses this connection map to

' connect the sphere source to all the cones.

set oClip = AddClip( "Scene_Root", oSource, , , 1, "Cones", oCnxMap )

' Bonus part...  For fun we'll modify the value mapping of each

' item in the cone clip, treating it like it's a fixed-size value

' map (can't add new items to it).

clip = oClip & ".actionclip"

offsetAmt = 0

n = GetNumMappingRules( clip )

for i = 1 to n

	GetMappingRule clip, i, param, expr, active

	if right( param, 4 ) = "posy" then

		SetMappingRule clip, param, "(this)+time*" & offsetAmt, i, active

		offsetAmt = offsetAmt + 1

	end if

next

'==================================================

' 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

関連項目

CreateConnectionMap CreateValueMap DeleteMappingRule GetMappingRule GetNumMappingRules SetMappingRule