Is there a way I can convert a skeletal mesh to a static mesh at runtime?

Hello everyone,

I’m aware that there’s a way to convert a skeletal mesh to a static mesh by right clicking on it and clicking on the convert option. I was wondering if there’s a way I can do that at runtime. I have some functions that only work with static meshes and I have some cool ideas I can do with my game if I can get this functionality.

My final goal is to be able to get a snapshot of a specific animation frame of the skeletal mesh, and then create a new static mesh based on the pose in this animation frame.

I have looked into the pose snapshot tool, but that seems to only work for applying a certain pose to the animator rather than create a static mesh with the pose.

1 Like

Hi,

I’m not sure about making a static mesh, but you can use the UPoseableMeshComponent component to make a snapshot of a pose from a USkeletalMeshComponent.

Hope that will help:

Hmm…This is really interesting. I didn’t know you could do that. I just tried it and it works. I do have a question though. Can you use poseable mesh component with something like the procedural mesh component to slice it? If I can do that, then my problem is solved.

I didn’t tried it by myself but it should be possible (even without PoseableMesh, directly from the SkeletalMeshCmpoinent): Create procedural mesh from animated skeletal mesh? - C++ - Unreal Engine Forums

Oh thank you very much!! I have been looking for this for a while.

This is what I needed.

Thank you Norlin Games, This is the answer I needed to convert my skeletal mesh into a sliceable mesh: Create procedural mesh from animated skeletal mesh? - C++ - Unreal Engine Forums

Hello hossan.

I too am looking to create a static mesh from a skeletal mesh during runtime. I think that the code could help me to accomplish this. The difference is that I need a static mesh of the skeletal mesh at the reference pose.

Can you explain what you mean from sliceable mesh? Are you able to get the static mesh from it?

There is no way to do what is asked without coding a system from scratch.

Yes you have the pose snapshot, that gives you the bone positions.
Yes you have a skeletal mesh with placed vertex.

Yes you could use a shader to copy the vertex order from the skeletal mesh to the static mesh to pose it.

No. Its not fast.
More vertex = more processing.

Since you already have the skeletal mesh posed and calculated, doing anything else after that is a waste of computation that will just increase the cost of everything else in order to maybe free up some 60byte of data used to keep the skeletal mesh posed…

Its probably not even worth the time to look into how to copy the vertex buffer between meshes in terms of end result.

Yes, you could in theory replace anything and keep it on screen without a skeletal mesh at a much reduced cost (because skeletal meshes have a limit).

The computation power of doing it is however very likely to break the gameplay with stutter for most systems.

So… smoke and mirrors.
Use a pre-made end pose. At the end of which, delete the skeletal mesh, replace it with a static mesh @ the same transform.
Won’t work with ragdolling. Will work with anything else.

Hello, thank you for your reply. At least, I am thinking that you replied to my comment?

So your saying that the sliceable mesh will not work? I just need to get the reference pose of my animation as a static mesh. I could technically create a static mesh copy of all of my skeletal meshes and swap out the two during runtime. But that is plan B right now. Plan A would be to create a BP or C++ code that could convert it during runtime.

Again, its very expensive computationally to get decent results.

The peocedural slicing is very similar to your end goal.

You can look at the engine source, duplicate the files for it.
Change headings of functions, and set it up to read the skeletal mesh instead.

Assuming this isn’t a thing already (wich it may support being its been 6 years almost since .14 when they originally set it up so check it out first).

The procedural mesh component cannot be instance optimized, so you can’t enjoy a reluced load on performance from having 10000 different components on screen. However, you could possibly add multiple meshes to the same procedural component to try and aggregate some drawcalls in those very large unrealistic cases.
If you do have to mess withe the code, run a probe to spot a local component, and if one is hit, add to the existing component instead of creating a new one…

Again, this isn’t a static mesh you create, but a procedural mesh component…

Sorry,did it work?

For those who are still looking for this, just so you don’t waste your day. Here’s how to do both Static and Skeletal mesh. It’s also as simple way of taking a morph target snapshot, or baking the morph target to the skeleton, without expensive plugins.

3 Likes

Hello, how to get these nodes ?plugins or C++

Some of those nodes are Editor only so it you expecting to run this outside the editor it will not behave as expected.