Here’s what I’m trying to accomplish:
I need to be able to deform a static mesh, but because a static mesh is a static mesh by definition it can’t be deformed. So my plan is to use a procedural mesh component, and somehow convert my static mesh into a procedural mesh so I can then play with the vertex positions. Can someone tell me if this plan is impossible/crazy? I found a function in ProceduralMeshComponent.h that might help me out (line 127):
/** * Create/replace a section for this procedural mesh component. * @param SectionIndex Index of the section to create or replace. * @param Vertices Vertex buffer of all vertex positions to use for this mesh section. * @param Triangles Index buffer indicating which vertices make up each triangle. Length must be a multiple of 3. * @param Normals Optional array of normal vectors for each vertex. If supplied, must be same length as Vertices array. * @param UV0 Optional array of texture co-ordinates for each vertex. If supplied, must be same length as Vertices array. * @param VertexColors Optional array of colors for each vertex. If supplied, must be same length as Vertices array. * @param Tangents Optional array of tangent vector for each vertex. If supplied, must be same length as Vertices array. * @param bCreateCollision Indicates whether collision should be created for this section. This adds significant cost. */ UFUNCTION(BlueprintCallable, Category = "Components|ProceduralMesh", meta = (AutoCreateRefTerm = "Normals,UV0,VertexColors,Tangents")) void CreateMeshSection(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals, const TArray<FVector2D>& UV0, const TArray<FColor>& VertexColors, const TArray<FProcMeshTangent>& Tangents, bool bCreateCollision);
The issue is, there is some information I can’t find how to get from a static mesh component, such as: triangles. Does anyone have an easier way to deform a static mesh? Or, can anyone help me use this method? Thanks to anyone who read this whole thing, I really appreciate it.
FYI: I am an ex-Unity user and I just got into Unreal C++ about a month ago.