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