/*
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); |