Copying SkinnedMeshRenderer posed mesh to a static mesh

Basically, I’m curious about how, if at all possible, I could copy the mesh from a skinned mesh renderer, apply the pose information for the current frame, and then make that into a mesh that I can use in a meshfilter for a static meshrenderer object.

I’m assuming it’d be something involving the matrix transformations from the bindposes and boneweights, applied to the position of each vertex. However, this doesn’t seem to work, and also takes FOREVER to do the calcs, which makes absolutely no sense cause I figure unity is doing something similar in the background for each frame!

something like this?:

static function SkinnedCopy(inMesh : Mesh, inRend : SkinnedMeshRenderer) : Mesh{
    var nMesh : Mesh = inMesh;
    var sMesh : Mesh = inRend.sharedMesh;
    
    for (i=0;i<nMesh.vertices.length;i++){
        nMesh.vertices[i] = (inRend.bones[sMesh.boneWeights[i].boneIndex0].worldToLocalMatrix * sMesh.bindposes[sMesh.boneWeights[i].boneIndex0]).MultiplyPoint3x4(sMesh.vertices[i]);
    }
    
    return nMesh;
}

Except all this currently does is be a forever long mesh copy of the default pose. Which I could do just by saying nMesh = sMesh

You’re right, we definitely both have the same problem. How to get the locations of the vertices of a skinned mesh deformed by bones at a given time.

What you are working on could indeed be a nice tool to have! Once we find the key piece of information, we will be able to rock and roll.

It seems that the skinned mesh renderer function (Unity - Scripting API: SkinnedMeshRenderer) should work here.

That, along with using MeshFilter.sharedMesh instead of MeshFilter.mesh. Or SkinnedMeshRenderer.sharedMesh.

I’ve been experimenting for several hours now, to no avail…

This is sadly a subject I too need help with. Wonder if any of you found any solution or any additional lead.

I just posted a script which does (a close approximation of) the SkinnedMeshRenderer display using a regular MeshRenderer, giving you access to all of the posed vertex positions in this thread. There were a couple of nasty tricks involved, so I hope this helps.

2 Likes