Floating point representations are inherently imprecise for many numbers. Which caused you values to go beyond 1.0 or set below 1.0. The way I approached it was to get the sum of the weights for the given component and used it to normalize the weights.
finalVertWeight = vertWeight / totalWeightForThatVertOfAllJoints
Dividing the weights by the totalWeights will normalize the weights to 1.0 rathen then something like 1.000006 or 0.999995..its more like 1.0000000000000000477 now. Normalization should fix that
-brian
www.meljunky.com
---------- Original Message --------
Subject: [Maya-Python] Re: Adding Influence Object
From: Brandon Harris <[email protected]>
Date: Wed, December 16, 2009 5:56 pm
To: python_inside_maya <[email protected]>
MelJunky, Was hoping that you would respond.
Are you normalizing your weights when using the setWeight()? When I
turn Normalization to False it works fine, but then my weights aren't
normalized and I don't want weights over a value of 1.
Brandon L. Harris
On Dec 16, 3:27 pm, <[email protected]> wrote:
> I used MFnSkinCluster not that long ago and I retrieved the fullPathName of two different skinClusters and stored them in a list.
>
>
>
> Then, I had to compare the list to see if I need to add any influence objects:
>
> list( set( first.influenceObjectsStr ).difference( second.influenceObjectsStr) )
>
>
>
> If, the results wasn't None then I executed the MEL command to add them as an influence using "OpenMaya.MDGModifier()", with the two methods commandToExecute and doIt.
>
>
>
> So, I recommend to go with your first instinct and use MEL. Don't remember where but someone mentioned that MEL is easier to add influences then trying to use the API.
>
>
>
>
>
> As for the setWeights() issue...I had no problem changing the weight from zero. Are you using the dataBlock for help setting the weights by chance to retrieve values for setting the final weights?
>
>
>
> Try printing out the values from the OpenMaya.MDoubleArray() that you are using to set the values are correct. Could also double check arguments for the setWeights is correct... I had a problem before with setWeights and I tracked it down to a previous issue.
>
>
>
> -brian
>
> www.meljunky.com
>
>
>
>
>
>
>
>
>
> -------- Original Message --------
> Subject: [Maya-Python] Re: Adding Influence Object
> From: Brandon Harris <[email protected]>
> Date: Wed, December 16, 2009 4:00 pm
> To: python_inside_maya <[email protected]>
> And this has actually raised another issue. If a joints influence is
> entirely at 0 on a skinCluster and I use the setWeights() it won't set
> the weights. It just leaves the joint influence at 0. This a known
> issue?
> On Dec 16, 10:34 am, Brandon Harris <[email protected]> wrote:
> > Alright, so I have a system where you can grab components on multiple
> > meshes and apply weights to specified joints. Everything works fine
> > unless you run into a joint that doesn't effect one of the meshes. The
> > easiest way to do this would be just to check if the object influences
> > the skin cluster and if it doesn't add it. This would be simple with
> > Mel, but is there a way to accomplish this with API? In MFnSkinCluster
> > there isn't a method for this and I haven't been able to locate one.
> > There's got to be something there for it though.
> --http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya
http://groups.google.com/group/python_inside_maya
