Re: changing deformer weights via scripting

Date : Tue, 02 Oct 2007 09:24:39 +0200
To : XSI(at)Softimage.COM
From : André Adam <a_adam(at)49games.de>
Subject : Re: changing deformer weights via scripting
Directly edit the weights table:

//Setup:
var oTorus = ActiveSceneRoot.AddGeometry("Torus", "MeshSurface");
var oNull = ActiveSceneRoot.AddNull();
oNull.PosX = 2.5;
var oNull1 = ActiveSceneRoot.AddNull();
oNull1.PosX = -2.5;
ApplyFlexEnv("torus;null,null1", null, 2);
SelectObj(oTorus);

//Edit Weights:
var oObj = Selection(0);
var oEnvelope = oObj.Envelopes(0);
var cDeformers = oEnvelope.Deformers;
var aWeights = oEnvelope.Weights.Array.toArray();
//Find the index of a specific deformer
for(var i=0; i<cDeformers.Count; i++){
 if(cDeformers(i).Name == "null1"){
   var oDefIndex = i;
 }
}
//Cycle all Weights with a step size that equals the deformers count
for(i=0; i<aWeights.length; i+=cDeformers.Count){
 //Manipulate the weight of the specific deformer found beforehand
 aWeights[i+oDefIndex] = 0;
}
//Write back the manipulated weights table
oEnvelope.Weights.Array = aWeights;

Hope that helps, cheers!

   -André


emihde03(at)comcast.net wrote:
is there a way to change deformer weights via scripting without the weight normalization being on?
when use SetDeformerWeights, i can set a deformer's weights to, for example, 100 for all points in the envelope_weights cluster, but once there, i can't subtract from that, or set it to a lower value, as there's nowhere for the weights to go. while i know normalizing weights is good, sometimes you want to have full control (as you have in the weights editor).
thanks in advance,
enoch


---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.