Skeletal mesh merge
Morph Mesh Merge:#
Morphtarget is very simple.
UMorphTarget -> FMorphTargetLODModel (per LOD) -> FMorphTargetDelta
This delta stores vertex index, and delta of position and normal.
Mesh merge code is
bool FSkeletalMeshMerge::DoMerge(TArray\* RefPoseOverrides / *= nullptr* /) /** Destination merged mesh */ USkeletalMesh* MergeMesh; /** Array of source skeletal meshes */ TArray<USkeletalMesh*> SrcMeshList;
You have SrcMeshList, and at the end,
void FSkeletalMeshMerge::GenerateLODModel( int32 LODIdx )
Will generate the new LODModel.
USkeletalMesh has TArray MorphTargets. You'll have to transfer SrcMeshList to MergedMesh with new vertex Id.
I assume you can save the vertex Id link somewhere in GenerateLODModel, and look for them later.
Later on once you have UMorphtarget for new mesh, make sure to call
void RegisterMorphTarget(UMorphTarget* MorphTarget);
We create Morphtarget with internal object of USkeletalMesh, meaning you'll have to create them with the current skeletalmesh as outer.
MorphTarget = NewObject(BaseSkelMesh, FName(*ShapeName));
bool FLODUtilities::RegenerateLOD(USkeletalMesh* SkeletalMesh, int32 NewLODCount /= 0/, bool bRegenerateEvenIfImported /= false/)
Usually this is utility function for doing so.