Notifications
Clear all

[Closed] Calculating skinning from a deforming mesh

Hey all. I’ve got a custom deformer modifier I have made, which deforms a mesh based off skeletal movement. I’m trying to write a script which will convert this down into a skin modifier.

At present, what I do is take the number of skinned bones (lets say for example I have 10) then I make an 11 frame anim. At frame 0 all my bones etc are in the bind pose. At frame one i rotate joint 1 45 degrees. At frame 2 i set all joints back to the bind pose and rotate joint 2 45 degrees and so on for each joint.

Now what I do is query all of the vert positions on my deformer mesh at frame 0 (rest pose) relative to each bone. Then at frame 1 i query all the vert positions relative to joint 1. This should show me which verts have been moved by this joint.

Once I have done this for each vert and frame (ie bone) I can then see if joint 2 moved vert 60 2 units and joint 3 moved it 1 unit i can then convert this back into a normalised skin weighting for joint 2 and 3.

However, I think I have a problem with my logic.

Does the following sound valid?

  1. Get vert position for each vert at rest pose relative to each bone (restVertPose). I will end up with a per joint array containing positions of each vert
  2. Get vrt position for each vert at the ‘posed’ pose relative to each bone (posed == each bone moves on a different frame) (posedVertPose). I will end up with a per joint array containing positions of each vert per pose
  3. For a specific bone (ie ‘posed’) for each vert see if restVertPose for specific bone (from step 1) is different to posedVertPose version (from step 2)
  4. If it is different then do the following:
    a. If restVertPose for child of specific bone is different to posedVertPose for child
    If it’s the same then do the following:
    i. if restVertPose for parent bone is different to the posedVertPose for parent bone then we know this is the thing we need to use as an influence so go ahead and record the differences
7 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

if you made this deform modifier you probably have to know what vertices are affected by every bone and how much influence every vertex gets. why do want to do a reverse engineering? am i missing anything?

Can you flatten the hierarchy without losing your deformations?
That is, setting each bone’s .parent=undefined

That way you could simply translate the bones one at a time along one axis without moving the children, which avoids testing if the verts are actually deformed by the bone’s parent / child.

As a benefit, translating a bone like this say 100 units in X
will move each weighted vert in X by a percentage of its weighting,
revealing the exact weight amount.

Logan that is a genius idea – why didn’t I think of that!

Denis, unfortunately the deformer I am trying to transpose back into a skin modifier essentially smooths my weighting which is why I can’t just find what it was previously skinned to.

skin can only transform mesh vertices – translate, rotate, and scale. if your deform modifier does do anything extra (smooth for example) it’s very unlikely you can convert it to skin with no loss.

I’m not adding any vertices, maybe I shouldn’t have used the word smooth. I’m essentially performing a delta mush. I’m relaxing the verts on a hard skinned mesh.

which means you cannot convert it back to skin. there is no place in skin algorithm to support (or simulate) mesh relax deformation.

Thanks for the help guys. I’ve got this all working brilliantly now cheers!