TransferShapeAnimation
 
 
 

TransferShapeAnimation

Introduced

v5.0

Description

Transfers shape animation from the specified source object to the destination object. The animation to be transferred is contained within the Animation Mixer and includes any pre-existing mapping connected on the origin ShapeKeys.

In order for this command to work you need to specify a source object, a destination object and two lists of shape key cluster properties. The lists of shape keys should be of the same length and the order is important as it is specifying the mapping between the source ShapeKeys and the destination ShapeKeys.

If there is no cluster shape combiner operator on the destination object it will be added. If there is already some shape animation corresponding to the destination shape key list, it will be deleted.

Scripting Syntax

TransferShapeAnimation( SourceObject, DestinationObject, SourceShapeKeys, DestinationShapeKeys );

Parameters

Parameter Type Description
SourceObject X3DObject Object from which the shape animation will originate.
DestinationObject X3DObject Object to which the shape animation will be transferred.
SourceShapeKeys XSICollection The collection of shape keys on the source object that contain the animation you want to transfer.
DestinationShapeKeys XSICollection The collection of shape keys on the destination object that will receive the animation you want to transfer.

Examples

JScript Example

/*
        This example demonstrates how to transfer shape animation from one object to the other
*/
NewScene( null, false );
// Create source animation object
CreatePrim("Cone", "MeshSurface", null, null);
SetValue("Context.constructionmode", 1, null);
ActivateVertexSelTool(null);
SelectGeometryComponents("cone.pnt[1,4,7,10,13,16,19,22,LAST]");
Translate(null, -3.98256016551092, 0, 0, siRelative, siGlobal, siObj, siXYZ, null, null, siXYZ, null, null, null, null, null, null, 1);
SaveShapeKey("cone.pnt[1,4,7,10,13,16,19,22,LAST]", null, null, 1, null, null, null, null, siShapeObjectReferenceMode);
SetValue("PlayControl.Key", 30, null);
SetValue("PlayControl.Current", 30, null);
SelectGeometryComponents("cone.pnt[1,4,7,10,13,16,19,22,LAST]");
Translate(null, -3.98256016551092, 0, 0, siRelative, siGlobal, siObj, siXYZ, null, null, siXYZ, null, null, null, null, null, null, 1);
SaveShapeKey("cone.polymsh.cls.Shape", null, null, 30, null, null, null, null, siShapeObjectReferenceMode);
SelectObj("cone.polymsh.cls.Shape.ShapeKey1", null, null);
SelectObj("cone.polymsh.cls.Shape.ShapeKey", null, null);
SetValue("PlayControl.Key", 27, null);
SetValue("PlayControl.Current", 27, null);
// Create destination animation object
CreatePrim("Cylinder", "MeshSurface", null, null);
CreateModel(null, null, null, null);
SelectObj("Model.cylinder", null, true);
ActivateVertexSelTool(null);
SelectGeometryComponents("Model.cylinder.pnt[4-6,10,39,40]");
Translate(null, -2.92834449479742, 0, 0, siRelative, siGlobal, siObj, siXYZ, null, null, siXYZ, null, null, null, null, null, null, 1);
StoreShapeKey("Model.cylinder.pnt[4-6,10,39,40]", null, siShapeObjectReferenceMode, 27, 0, 0, siShapeContentPrimaryShape, false);
SelectFilter("object");
Translate(null, 2.05775559093871, 0, 0, siRelative, siGlobal, siObj, siXYZ, null, null, siXYZ, null, null, null, null, null, null, 1);
Translate(null, 0, 2.8035894047944, 0, siRelative, siGlobal, siObj, siXYZ, null, null, siXYZ, null, null, null, null, null, null, 1);
SaveShapeKey("Model.cylinder.polymsh.cls.Shape", null, null, 27, null, null, null, null, siShapeObjectReferenceMode);
Selection.SetAsText("cone,Model.cylinder");
// Gather data to transfer
var oSource = Selection(0);
var oDestination = Selection(1);
var oSourceList = new ActiveXObject("XSI.Collection") ;
var oSourceClusterProperties = oSource.ActivePrimitive.Geometry.Clusters(0).Properties;
for ( var i=0; i<oSourceClusterProperties.Count; i++ ) {
        if ( oSourceClusterProperties(i).IsClassOf(siShapeKeyID) ) {
                oSourceList.Add(oSourceClusterProperties(i));
        }
}
var oDestList = new ActiveXObject("XSI.Collection");
var oDestClusterProperties = oDestination.ActivePrimitive.Geometry.Clusters(0).Properties;
for ( var i=0; i<oDestClusterProperties.Count; i++ ) {
        if ( oDestClusterProperties(i).IsClassOf(siShapeKeyID) ) {
                oDestList.Add(oDestClusterProperties(i));
        }
}
TransferShapeAnimation(oSource, oDestination, oSourceList, oDestList);

See Also

TransferShapeAnimationAcrossGenOp