このGeometryに対するシェイプキーを保存し、このシェイプを表わす新しいShapeClipオブジェクトをミキサに作成します。シェイプキーは 2 つの部分からなっています。ソース(格納したシェイプ)およびクリップ(アニメーションミキサのトラック上で特定の位置にあるシェイプキー(ソース)のインスタンス)
このメソッドでは 2 つのワークフローを使用できます。1 つはプリミティブの実際のシェイプを変更し、このメソッドを呼び出すため(SaveShapeKeyコマンドと同様の機能)、もう1 つは PositionArray 引数を使用してシェイプを指定するためのワークフローです。以下の例では、これら2 つの方法を説明します。
シェイプに対する実際のデータは、ClusterPropertyとして格納されます。ポイントのサブセットのみの位置を定義するシェイプキーを格納できます。これには IndexArray 引数を使用します。この方法を使用すると、大きなオブジェクトに対するメモリを節約できます。シェイプキーの設定されている、ポイントの各サブセットは、別個のClusterによって表わされます。
ShapeClip Geometry.SaveShapeKey( Double in_time, Double in_clipDuration, siShapeReferenceMode in_refMode, siShapeInstanceMode in_instMode, String in_name, Object in_indexArray, Object in_positionArray, Object in_normalArray ); |
oReturn = Geometry.SaveShapeKey( Time, [ClipDuration], [RefMode], [InstMode], [Name], [IndexArray], [PositionArray], [NormalArray] ); |
| パラメータ | タイプ | 説明 |
|---|---|---|
| Time | Double | 時間(秒)。オブジェクトの形状はこの時間において評価されます。ただし、形状が PositionArray 引数によって明示的に定義されている場合を除きます。Time 引数は、ShapeClip をMixer に追加する際にも使用されます。たとえば、siShapeMixedWeightMode がInstMode 引数に指定されている場合は、新しい形状は指定された時間での形状の 100%からなります。ある特定の時間に指定できるのは、単一のシェイプキーに限られます。 |
| ClipDuration | Double |
クリップの継続時間(秒)。デフォルトの動作を実行させるには-1.0を指定します。デフォルトの動作は InstMode 引数によって決まります。たとえば、siShapeMixedWeightMode を指定した場合、ClipDuration はシーンの全継続時間になりますが、siShapeTransitionMode を指定した場合、クリップは 1秒間継続します。
デフォルト値: -1.0 |
| RefMode | siShapeReferenceMode |
シェイプリファレンスモード。このパラメータは、シェイプがどのように格納されるか、およびベースとなるリファレンスシェイプが変更された場合にシェイプがどのように変更されるかを指定します。このリファレンスモードは、同じクラスタに複数のシェイプが保存された場合には無視され、最初のシェイプキーのリファレンスモードが代わりに使用されます。
デフォルト値: siShapeLocalReferenceMode |
| InstMode | siShapeInstanceMode |
シェイプインスタンス化モード。このパラメータは、新しいShapeClipをミキサに追加する方法を制御します。siShapeMixedWeightMode を使用すると、新しいトラックが作成され、新しいクリップはこのトラックに追加され、ウェイト付けを制御する F カーブは調整されます。siShapeInstanceOnlyMode を使用すると、各クリップは別個のトラックに追加されますが、シェイプ間のウェイト付けに F カーブは使用されません。siShapeTransitionMode を使用すると、すべてのクリップは同じトラックに追加され、トランジションエフェクトがクリップ間に適用されます。
デフォルト値:siShapeMixedWeightMode |
| Name | String |
新しいShapeClipに使用する名前。このシェイプに関連付けられているClusterPropertyには、この引数は影響しません。
デフォルト値:"Point_AUTO_ShapeAction_Clip" |
| IndexArray | Array |
ジオメトリポイントのインデックスの 1D 配列。シェイプ定義には、これらのポイントのみが含まれます。このポイントのサブセットを使用するシェイプが他にない場合は、新しいClusterが作成されます。
デフォルト値:指定しない場合、シェイプキーはジオメトリの各ポイントに保存されます。 |
| PositionArray | Array |
インデックスの配列によって参照されるジオメトリポイントのオフセットを計算するために使用する、キー位置ポイントの 1Dまたは 2D 配列。ポイントは絶対座標で指定する必要があります。1D 配列は、次のように、x,y,z 値のシーケンスの形式をとる必要があります。{Xo,Yo,Zo,...X(n-1),Y(n-1),Z(n-1)}。2D 配列は、x,y,z 値の Nx3配列の形式をとる必要があります。この引数は、IndexArray 引数が指定されている場合に限り考慮されます。また、 IndexArray と同じ数のポイントを指定する必要があります。
デフォルト値:シェイプキーはジオメトリポイントの現在の位置を基準とします |
| NormalArray | Array | 法線ポイントの 1Dまたは 2D 配列。法線は現在のところサポートされていません。 |
' ' This example shows how it is possible to create shape animations from the object model. ' Two techniques are used to create the same animation on two polygons ' dim oGrid1, oGrid2 ' Technique one is similar to the process used when interactively ' saving shape keys - we change the shape of the object and then save a ' shape key ' Create a polygon set oGrid1 = CreatePrim( "Grid", "MeshSurface" ) SetValue oGrid1 & ".polymsh.geom.subdivu", 1 SetValue oGrid1 & ".polymsh.geom.subdivv", 1 Scale oGrid1, 0.25, 0.25, 0.25, siAbsolute, siParent, siObj, siXYZ Translate oGrid1, -2, 0, 0, siRelative, siParent, siObj, siXYZ ' Our animation will start with the initial shape at frame 1 and ' morph to the second shape until frame 30 dim frameRate, frame1Seconds, frame30Seconds frameRate = GetValue( "PlayControl.Rate" ) frame1Seconds = 1 / frameRate frame30Seconds = 30 / frameRate ' Save the current shape as the reference ' This remembers the locations of each vertex. This information will ' be all zeros because we haven't moved any vertices and use siShapeLocalReferenceMode call oGrid1.ActivePrimitive.Geometry.SaveShapeKey( frame1Seconds, -1.0, _ siShapeLocalReferenceMode, siShapeMixedWeightMode ) ' Move some of the points Translate oGrid1 & ".pnt[0]" , 0, 0, -1, siRelative, siGlobal, siObj, siXYZ Translate oGrid1 & ".pnt[2]" , 0, 0, 1, siRelative, siGlobal, siObj, siXYZ Translate oGrid1 & ".pnt[3]" , 0, 0, -1, siRelative, siGlobal, siObj, siXYZ ' Take a second snap shot of the object call oGrid1.ActivePrimitive.Geometry.SaveShapeKey( frame30Seconds, -1.0, _ siShapeLocalReferenceMode, siShapeMixedWeightMode ) ' Technique two is direct. We describe the actual positions ' of the vertices for each shape. set oGrid2 = CreatePrim( "Grid", "MeshSurface" ) SetValue oGrid2 & ".polymsh.geom.subdivu", 1 SetValue oGrid2 & ".polymsh.geom.subdivv", 1 Scale oGrid2, 0.25, 0.25, 0.25, siAbsolute, siParent, siObj, siXYZ Translate oGrid2, +2, 0, 0, siRelative, siParent, siObj, siXYZ ' We only specify the vertices that actually move. In the case of ' a large object this could save a lot of memory call oGrid2.ActivePrimitive.Geometry.SaveShapeKey( frame1Seconds, -1.0, _ siShapeLocalReferenceMode, siShapeMixedWeightMode, ,_ Array( 0,2,3 ), Array( -4,0,-4, 4,0,-4, 4,0,4) ) call oGrid2.ActivePrimitive.Geometry.SaveShapeKey( frame30Seconds, -1.0, _ siShapeLocalReferenceMode, siShapeMixedWeightMode, ,_ Array( 0,2,3 ), Array( -4,0,-8, 4,0,0, 4,0,0) ) |
' ' Three cones are created with identical animation ' although they use different Reference Modes to record the shape ' set root = Application.ActiveProject.ActiveScene.Root set obj = root.AddGeometry( "Cone", "MeshSurface" ) ApplyOp "bend", obj obj.posz.Value = -3 set geometry = obj.ActivePrimitive.Geometry ' Move the point to 1,1,0 in local mode set clip = geometry.SaveShapeKey( 1, 1, siShapeLocalReferenceMode, _ siShapeInstanceOnlyMode, "MyShapeKey", Array(1), Array(1.,1.,0) ) set obj = root.AddGeometry( "Cone", "MeshSurface" ) ApplyOp "bend", obj set geometry = obj.ActivePrimitive.Geometry ' Move the point to 1,1,0 in absolute mode set clip = geometry.SaveShapeKey( 1, 1, siShapeAbsoluteReferenceMode, _ siShapeInstanceOnlyMode, "MyShapeKey", Array(1), Array(1.,1.,0) ) set obj = root.AddGeometry( "Cone", "MeshSurface" ) ApplyOp "bend", obj obj.posz.value = 3 set geometry = obj.ActivePrimitive.Geometry ' Move the point to 1,1,0 in object mode set clip = geometry.SaveShapeKey( 1, 1, siShapeObjectReferenceMode, _ siShapeInstanceOnlyMode, "MyShapeKey", Array(1), Array(1.,1.,0) ) |
'
' This example demonstrates how you access the shape information for a particular shape key by looking
' at the cluster properties which store this data
'
option explicit
' Set up a little scene
dim oCircle
set oCircle = CreatePrim( "Sphere", "MeshSurface" )
' Move the top and bottom point of the sphere outwards
oCircle.ActivePrimitive.Geometry.SaveShapeKey 0.5, 3.0, _
siShapeAbsoluteReferenceMode, siShapeInstanceOnlyMode, ,_
Array( 1, 0 ), Array( 0,6,0, 0,-6,0 )
' Move two different points - this creates a new, independent cluster
' We can use a different reference mode for this, but we still specify the
' point positions in Absolute terms.
oCircle.ActivePrimitive.Geometry.SaveShapeKey 0.8, 1.0, _
siShapeLocalReferenceMode, siShapeInstanceOnlyMode,, _
Array( 5, 33 ), Array( -2,0,0, 2,0,0 )
ShowShapeInformation( oCircle )
sub ShowShapeInformation( in_obj )
dim oClusters, oCluster, oProperties, oProperty, cntFoundShapes
on error resume next
set oClusters = in_obj.ShapeAnimatedClusters
if ( err <> 0 ) then
Application.LogMessage "Please select a 3D Object"
exit sub
end if
on error goto 0
Application.LogMessage "Dump of shape key data on object " & in_obj.Fullname
cntFoundShapes = 0
' Go through the various clusters on the object
' (In practice only the Point clusters will have shape keys)
for each oCluster in oClusters
' Cluster indices are not the same as the indices on the
' geometry, but we can easily determine the relationship with
' this array:
dim oClusterElementsCollection, aElements
set oClusterElementsCollection = oCluster.Elements
aElements = oClusterElementsCollection.Array
' Only search for the shape keys, which have type "clskey"
set oProperties = oCluster.LocalProperties.filter( "clskey" )
for each oProperty in oProperties
' Found a shape key
dim i, XYZArray
cntFoundShapes = cntFoundShapes + 1
if InstrRev( oProperty, ".ResultClusterKey" ) <> 0 then
' There may also be an internal cluster property
' called "ResultClusterKey" which stores the
' result of blending the various shapes at the
' current time
Application.LogMessage "Blended shape at this time: " & oProperty
else
Application.LogMessage "Shape key: " & oProperty
end if
' The reference mode is available from the KeyType parameter
dim ReferenceType
ReferenceType = oProperty.Parameters("KeyType").Value
if ( ReferenceType = 0 ) then
Logmessage " Uses: Absolute Reference Mode"
elseif ( ReferenceType = 1 ) then
Logmessage " Uses: Local Reference Mode"
elseif ( ReferenceType = 2 ) then
Logmessage " Uses: Object Reference Mode"
end if
' The contents of the cluster can be found in this safearray
XYZArray = oProperty.Elements.Array
For i=0 to UBound(oProperty.Elements.Array,2)
' Print out the x,y,z values
LogMessage " pnt["& aElements( i ) & "] has position (" _
& Round(XYZArray(0,i),3) & "," & Round(XYZArray(1,i),3) & ","_
& Round(XYZArray(2,i),3) & ")"
Next
next
next
if ( cntFoundShapes = 0 ) then
LogMessage "There are no shapes on this object"
end if
end sub |