Envelope.SetDeformerWeights2

導入

v10.5 (2012)

詳細

ウェイトを平均化せずに、指定されたデフォーマに対してデンベロープ ウェイトを設定します。ウェイトを平均化したい場合、Envelope.SetDeformerWeights メソッドを使用します。

}デフォーマのウェイトは、ジオメトリのインデックス順ではなく、クラスタのインデックス順に渡す必要があります。指定されたジオメトリインデックスと一致するクラスタインデックスを取得するには、Envelope.Elementsと同時にClusterElementCollection.FindIndexを使用します。

スクリプト 構文

Envelope.SetDeformerWeights2( Deformer, [Weights] );

パラメータ

パラメータ タイプ 詳細
デフォーマ X3DObjectまたはエクスプレッション デフォーマオブジェクト
ウェイト DoubleArray ウェイトの配列。エンベロープによって影響を受けるポイントごとに1 つのウェイト。

Python の例

# This example shows how to set vertex envelope weights
# on a deformer without normalizing the weights
xsiApp = Application
# Create the scene made of a cube and 3 nulls
xsiApp.NewScene( None, False )
root = xsiApp.ActiveProject.ActiveScene.Root
grid = root.AddGeometry( "cube", "MeshSurface" )
n = root.AddNull()
n1 = root.AddNull()
n2 = root.AddNull()
# Move the nulls
xsiApp.Translate( n, 1, 0, 1 )
xsiApp.Translate( n1, 0, 0, 1 )
xsiApp.Translate( n2, 0, 0, 0 )
# Create a deformer list made of the 3 nulls
deformers = XSIFactory.CreateObject( "XSI.Collection" )
deformers.Add( n )
deformers.Add( n1 )
deformers.Add( n2 )
# Create an Envelope Weight on the grid with the 3 nulls
env = grid.ApplyEnvelope( deformers )
# Output the current values of the Envelope Weight
xsiApp.LogMessage( "Envelope Weights before user edit" )
allWeights = env.GetWeights2( None )
i = 0
for vertexWeights in allWeights:
        sum = 0
        for singleWeight in vertexWeights:
                sum += singleWeight
        xsiApp.LogMessage( "Vertex " + str( i ) + ": " + 
                                           str( "Deformer 0: %4.1f, " % vertexWeights[ 0 ] ) +
                                           str( "Deformer 1: %4.1f, " % vertexWeights[ 1 ] ) +
                                           str( "Deformer 2: %4.1f, " % vertexWeights[ 2 ] ) +
                                           str( "Vertex Weight Sum: %5.1f" % sum ) )
        i += 1
xsiApp.LogMessage( "" )
# Set new vertex envelope weights for the first deformer
env.SetDeformerWeights2( n, [10,10,10,10,10,10,10,10] )
# Output the new values of the Envelope Weight
xsiApp.LogMessage( "Envelope Weights after user edit" )
allWeights = env.GetWeights2( None )
i = 0
for vertexWeights in allWeights:
        sum = 0
        for singleWeight in vertexWeights:
                sum += singleWeight
        xsiApp.LogMessage( "Vertex " + str( i ) + ": " + 
                                           str( "Deformer 0: %4.1f, " % vertexWeights[ 0 ] ) +
                                           str( "Deformer 1: %4.1f, " % vertexWeights[ 1 ] ) +
                                           str( "Deformer 2: %4.1f, " % vertexWeights[ 2 ] ) +
                                           str( "Vertex Weight Sum: %5.1f" % sum ) )
        i += 1
#-----------------------------------------
# Output of this example is the following:
#-----------------------------------------
# INFO : Envelope Weights before user edit
# INFO : Vertex 0: Deformer 0:  0.0, Deformer 1: 41.5, Deformer 2: 58.5, Vertex Weight Sum: 100.0
# INFO : Vertex 1: Deformer 0: 48.0, Deformer 1:  0.0, Deformer 2: 52.0, Vertex Weight Sum: 100.0
# INFO : Vertex 2: Deformer 0:  0.0, Deformer 1: 41.5, Deformer 2: 58.5, Vertex Weight Sum: 100.0
# INFO : Vertex 3: Deformer 0: 48.0, Deformer 1:  0.0, Deformer 2: 52.0, Vertex Weight Sum: 100.0
# INFO : Vertex 4: Deformer 0:  0.0, Deformer 1: 57.8, Deformer 2: 42.2, Vertex Weight Sum: 100.0
# INFO : Vertex 5: Deformer 0: 59.3, Deformer 1: 40.7, Deformer 2:  0.0, Vertex Weight Sum: 100.0
# INFO : Vertex 6: Deformer 0:  0.0, Deformer 1: 57.8, Deformer 2: 42.2, Vertex Weight Sum: 100.0
# INFO : Vertex 7: Deformer 0: 59.3, Deformer 1: 40.7, Deformer 2:  0.0, Vertex Weight Sum: 100.0
# INFO : 
# INFO : Envelope Weights after user edit
# INFO : Vertex 0: Deformer 0: 10.0, Deformer 1: 37.3, Deformer 2: 52.7, Vertex Weight Sum: 100.0
# INFO : Vertex 1: Deformer 0: 10.0, Deformer 1:  0.0, Deformer 2: 52.0, Vertex Weight Sum:  62.0
# INFO : Vertex 2: Deformer 0: 10.0, Deformer 1: 37.3, Deformer 2: 52.7, Vertex Weight Sum: 100.0
# INFO : Vertex 3: Deformer 0: 10.0, Deformer 1:  0.0, Deformer 2: 52.0, Vertex Weight Sum:  62.0
# INFO : Vertex 4: Deformer 0: 10.0, Deformer 1: 52.0, Deformer 2: 38.0, Vertex Weight Sum: 100.0
# INFO : Vertex 5: Deformer 0: 10.0, Deformer 1: 40.7, Deformer 2:  0.0, Vertex Weight Sum:  50.7
# INFO : Vertex 6: Deformer 0: 10.0, Deformer 1: 52.0, Deformer 2: 38.0, Vertex Weight Sum: 100.0
# INFO : Vertex 7: Deformer 0: 10.0, Deformer 1: 40.7, Deformer 2:  0.0, Vertex Weight Sum:  50.7

関連項目

Envelope.SetDeformerWeights Envelope.GetWeights2