Download

Accessing Vertex Positions of animated skeletal mesh

Hi!

I’m trying to track the vertex position of a skeletal mesh during an animation but the doc about skeletal mesh api is very poor.

using SkMeshComponent->SkeletalMesh->GetResourceForRendering()->LODModels[0].GetVertices() I can access to the mesh pose vertices but I not sure how to access to the transformed vertices if the skeletal mesh is playing an animation.

any tip??

THanks!

I believe you would have to calculate the all the bone transforms and skin weights of the selected vertex and multiply manually.
This is because that multiplication happens in the shader (with GPU Skinning) when rendering so there is no way to access on CPU.

(If you turn off GPU Skinning, you may be able to access directly, but would incur the additional performance cost)

In Psuedo code,
Calculate which bones affect the desired vertex using the skin weights. (These are in the asset)
Get the ComponentSpace bone transforms from the RefSkeleton (these are cached every frame and reflect the animation)
Calculate the vertex postion.

Luckily, it looks like there might be a convenience function in MeshUtilities.cpp: CalcBoneVertInfos
(found in in Engine/Source/Developer/MeshUtilities)

It looks like this calculates all verts, so not sure if you want to run this every single frame…
but you could use this as a guide to roll your own “single vertex position calculater”.

If you do figure it out please post back - would be useful to have.

Good luck

Hi!

Thanks for your reply OptimisticMonkey. I have found the vertex position every frame with Skeletal->ComputeSkinnedPositions. It’s in component space but transform to world space is not hard. The problem is that this function returns just an Array of vectors. If I find the way to match its positions with the mesh vertices it will resolved. I want to create in runtime a static mesh from a specific frame of the mesh animation. Is each vertex in ComputeSkinnedPositions return in the same position than LODModels[0].GetVertices() returned array?? I don’t know, I will check it.

Bye!!

FYI - If All you want is to create a runtime static mesh - then there is the new PoseSnapshot capabilities in 4.15.

From Unreal Engine 4.15 Released! - Unreal Engine

NEW: POSE SNAPSHOTTING
We’ve added the ability to capture a runtime Skeletal Mesh pose in Blueprints for use in the Anim Blueprint!

Cool!

FYI - If All you want is to create a runtime static mesh - then there is the new PoseSnapshot capabilities in 4.15.

From Unreal Engine 4.15 Released! - Unreal Engine

“NEW: POSE SNAPSHOTTING
We’ve added the ability to capture a runtime Skeletal Mesh pose in Blueprints for use in the Anim Blueprint!”

Not sure if that is what you are looking for…

Hi!!

I didn’t know about this new feature!! thanks! I have been testing it but “save snapshoot” node from skeletalmesh has not a return so I dont know how to use this pose… I hope Epic give us more information about this feature soon.

Regard!