1// Fill out your copyright notice in the Description page of Project Settings.
2#pragma once
3#include "CoreMinimal.h"
4#include "Kismet/BlueprintFunctionLibrary.h"
5#include "UObject/NoExportTypes.h"
6#include "MeshMergeFunctionLibrary.generated.h"
7/**
8* Blueprint equivalent of FSkeleMeshMergeSectionMapping
9* Info to map all the sections from a single source skeletal mesh to
10* a final section entry in the merged skeletal mesh.
11*/
12USTRUCT(BlueprintType)
13struct PROJECTNAME_API FSkelMeshMergeSectionMapping_BP
14{
15 GENERATED_BODY()
16 /** Indices to final section entries of the merged skeletal mesh */
17 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mesh Merge Params")
18 TArray<type> SectionIDs;
19};
20/**
21* Used to wrap a set of UV Transforms for one mesh.
22*/
23USTRUCT(BlueprintType)
24struct PROJECTNAME_API FSkelMeshMergeUVTransform
25{
26 GENERATED_BODY()
27 /** A list of how UVs should be transformed on a given mesh, where index represents a specific UV channel. */
28 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mesh Merge Params")
29 TArray UVTransforms;
30};
31/**
32* Blueprint equivalent of FSkelMeshMergeUVTransforms
33* Info to map all the sections about how to transform their UVs
34*/
35USTRUCT(BlueprintType)
36struct PROJECTNAME_API FSkelMeshMergeUVTransformMapping
37{
38 GENERATED_BODY()
39 /** For each UV channel on each mesh, how the UVS should be transformed. */
40 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mesh Merge Params")
41 TArray UVTransformsPerMesh;
42};
43/**
44* Struct containing all parameters used to perform a Skeletal Mesh merge.
45*/
46USTRUCT(BlueprintType)
47struct PROJECTNAME_API FSkeletalMeshMergeParams
48{
49 GENERATED_BODY()
50 FSkeletalMeshMergeParams()
51 {
52 MeshSectionMappings = TArray();
53 UVTransformsPerMesh = TArray();
54 StripTopLODS = 0;
55 bNeedsCpuAccess = false;
56 bSkeletonBefore = false;
57 Skeleton = nullptr;
58 }
59 // An optional array to map sections from the source meshes to merged section entries
60 UPROPERTY(EditAnywhere, BlueprintReadWrite)
61 TArray MeshSectionMappings;
62 // An optional array to transform the UVs in each mesh
63 UPROPERTY(EditAnywhere, BlueprintReadWrite)
64 TArray UVTransformsPerMesh;
65 // The list of skeletal meshes to merge.
66 UPROPERTY(EditAnywhere, BlueprintReadWrite)
67 TArray MeshesToMerge;
68 // The number of high LODs to remove from input meshes
69 UPROPERTY(EditAnywhere, BlueprintReadWrite)
70 int32 StripTopLODS;
71 // Whether or not the resulting mesh needs to be accessed by the CPU for any reason (e.g. for spawning particle effects).
72 UPROPERTY(EditAnywhere, BlueprintReadWrite)
73 uint32 bNeedsCpuAccess : 1;
74 // Update skeleton before merge. Otherwise, update after.
75 // Skeleton must also be provided.
76 UPROPERTY(EditAnywhere, BlueprintReadWrite)
77 uint32 bSkeletonBefore : 1;
78 // Skeleton that will be used for the merged mesh.
79 // Leave empty if the generated skeleton is OK.
80 UPROPERTY(EditAnywhere, BlueprintReadOnly)
81 class USkeleton* Skeleton;
82};
83/**
84*
85*/
86UCLASS()
87class PROJECTNAME_API UMeshMergeFunctionLibrary : public UBlueprintFunctionLibrary
88{
89 GENERATED_BODY()
90public:
91 /**
92 * Merges the given meshes into a single mesh.
93 * @return The merged mesh (will be invalid if the merge failed).
94 */
95 UFUNCTION(BlueprintCallable, Category = "Mesh Merge", meta = (UnsafeDuringActorConstruction = "true"))
96 static class USkeletalMesh* MergeMeshes(const FSkeletalMeshMergeParams& Params);
97};
98~~~