[Closed] Issue while setting skin weights
Hey,
so i’m writing an xml importer.
I have an issue when i apply the skinweights with skinOps.replaceVertexWeights
Some verts get funky weight, tho my inputs are correct.
I read somewhere here, that there is some conflict with weight beeing auto applied when you add bones the skin.
Anyway, the workaround i did is to UnNormalizeVertex , then replaceVertexWeights with 0 weight on all bones for every vert, then perform the replaceVertexWeights again with the correct values.
it doesnt take much time but still it feels dirty.
Why replaceVertexWeights doesn’t simply replace the weight ? If i don’t set the weight to 0 after unNormalize, verts get weighted with 1 on 2 bones for instance, resulting in deformed mesh.
Thanks
I am giving you this response from memory because since last I touched my skin utilities library was years ago
I am fairly certain that if you gather all the bones and weights for a vert an then pass it all with one replaceVertexWeights call then max should not be trying to normalize the weights, but if you call replaceVertexWeights and only set the weight of one of the bones for one vertex then things will get normalized.
Hope this helps.
Oh i see. On a vert, i set the weight only for bones having an influence (all at once, with arrays tho), where i probably should explicitly set 0 weight for every other bones too.
There it probably still consider “old” weights and normalize with them.
Eventhough, the doc says “Any influence weights for the bone(s) that are not specified are erased.”
Looks like it doesn’t do it ?
edit : tested on a box with 3 bones, skinOps.ReplaceVertexWeights doesn’t erase weight of unspecified bones in Max 2016.
I have to test with explicit weight for every bone but i’m confident it will fix the issue.
Thanks !
Sample scene
(
obj = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:30 height:20 pos:[0,0,0]
b1 = Point pos:[-30,0,0]
b2 = Point pos:[0,30,0]
b3 = Point pos:[30,0,0]
allBones = #(b1,b2,b3)
mySkin = skin()
select obj
max modify mode
addModifier obj mySkin
modPanel.setCurrentObject mySkin
for i = 1 to 3 do skinOps.addBone mySkin allBones[i] 1
--should work considering doc
for v = 1 to obj.numverts do skinOps.ReplaceVertexWeights mySkin v #(2,3) #(0.5,0.5)
--what i want
--for v = 1 to obj.numverts do skinOps.ReplaceVertexWeights mySkin v #(1,2,3) #(0,0.5,0.5)
)
Here, considering the doc, the 1st bone (point001) should have no longer any influence, right ?
Am i doing something wrong or is it a bug ?