/*
This example creates a generator operator and then moves
its read positions across various construction modes.
*/
NewScene(null, null);
Sphere = CreatePrim("Sphere", "MeshSurface", null, null);
//Create a twist operator in modeling construction mode
TwistOp = ApplyOp("Twist", Sphere, 3, siPersistentOperation, null, 0);
//Envelope the shere with a Null (animation construction mode),
//and move the Null so we can see the difference:
NullObject = GetPrim("Null", null, null, null);
EnvOp = ApplyFlexEnv(Sphere + ";" + NullObject, false, 2);
Translate(NullObject, 4, 0, 0, siRelative, siView, siObj, siXYZ, null, null, null, null,
null, null, null, null, null, 0);
//Generate a subdivided sphere from this one
MeshSubdivideWithCenter(null, "sphere", null, siPersistentOperation, siKeepGenOpInputs);
GeneratorOp = GetValue("polymsh.polymsh.MeshSubdivideWithCenter");
logmessage( "Construction region after generator creation: " +
GetGeneratorInputReadPosition( GeneratorOp ) );
//Currently, the generated sphere inherits from the animated (result)
//position, since by default it connects in secondary shape construction mode.
//We will now move the read point over the modeling marker so it has
//has twisted but not enveloped positions:
ChangeGeneratorInputReadPosition( GeneratorOp, siConstructionModeModeling, 0 );
logmessage( "Construction region after moving in modeling: " +
GetGeneratorInputReadPosition( GeneratorOp ) );
//Transfer the envelope operator onto the generated sphere:
TransferClusterPropertiesAcrossGenOp("polymsh.polymsh.MeshSubdivideWithCenter", "polymsh",
"sphere.polymsh.cls.EnvelopWeightCls.Envelope_Weights", "Envelope_Weights", true);
//Move the read position to animation mode, but specify to untransfer
//the envelope in order to avoid the double deformation:
ChangeGeneratorInputReadPosition( GeneratorOp, siConstructionModeSecondaryShape, 0 );
logmessage( "Construction region after moving back in secondary shape: " +
GetGeneratorInputReadPosition( GeneratorOp ) );
//Output:
// INFO : Construction region after generator creation: 3
// INFO : Construction region after moving in modeling: 0
// INFO : Construction region after moving back in secondary shape: 3
|