LimitEnvelopeDeformers

Introduced

v1.0

Description

Applies an operator that limits the number of envelope deformers that can affect a given vertex. For a given integer limit, the operator ensures the limit is met by removing the deformers with the minimum number of weights. The remaining weights are then normalized. The limit respects locked weights, meaning that if the minimum weight is actually a locked weight, it is not removed. Similarly, if the only remaining weights after applying the limit are locked, normalization will not be performed.

Scripting Syntax

oReturn = LimitEnvelopeDeformers( PropObj, [SubComp], Limit );

Return Value

Returns the newly created LimitEnvelopeDeformersOp operator.

Parameters

Parameter Type Description
PropObj String Envelope weights property to be modified.
SubComp String List of points/objects/clusters to be smoothed.

Default Value: Current selection

Limit Integer The maximum number of deformers permitted to affect a given vertex contained in SubComp

Examples

JScript Example

NewScene(null, null);

// Create a cylinder to be deformed

CreatePrim("Cylinder", "MeshSurface", null, null);

SetValue("cylinder.polymsh.geom.subdivu", 20, null);

SetValue("cylinder.polymsh.geom.subdivv", 20, null);

SetValue("cylinder.cylinder.height", 12.264, null);

Create2DSkeleton(0, -6, 0.6, 0, -5.25, 0.525, -5.7, 0, 0, 4, null, null);

// Create a chain of bones to deform the cylinder with

AppendBone("eff", -0.16, -2.5, 0.25, null);

AppendBone("eff", -0.12, 0.6, 0, null);

AppendBone("eff", -0.12, 3.4, -0.34, null);

AppendBone("eff", -0.12, 5.7, -0.57, null);

AppendBone("eff", -0.12, 6.5, -0.65, null);

// Deform the cylinder

SelectObj("cylinder", null, true);

ApplyFlexEnv("cylinder;root,bone,bone1,bone2,bone3,bone4,bone5,bone6,bone7,bone8,bone9,eff", null, 2);

SelectObj("eff", null, true);

Translate(null, -4.8, -8.4, 0.84, siRelative, siView, siObj, siXYZ, null, null, null, null, null, null, null, null, null, 0, null);

SelectObj("cylinder", null, true);

SetValue("cylinder.polymsh.cls.EnvelopWeightCls.Envelope_Weights.autoenvassign.defnbskelobj", 4, null);

// Open the weight editor to look at how the bones are assigned

OpenView("Weight Editor", null);

LockEnvelopeWeights("cylinder.polymsh.cls.EnvelopWeightCls.Envelope_Weights", Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), Array(4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), null);

XSIUIToolkit.MsgBox("Note that in the Weight Editor each bone is affected by four deformers, and some of the weights of bone3 are locked.  A limit of 2 deformers will now be applied.");

// Limit to two the number of deformers that apply to a given vertex

LimitEnvelopeDeformers("cylinder.polymsh.cls.EnvelopWeightCls.Envelope_Weights", null, 2);

XSIUIToolkit.MsgBox("Only two deformers are permitted to affect a given vertex, and the weights have been normalized.  Note that the locked weights were not modified.");