Search code examples
3dmeshareaunreal-engine5unreal-blueprint

How to calculate the surface area of a 3d mesh


I am making a project in unreal engine 5, and need to find out the surface area of a mesh. example in this example, I got a basic plane I set up, and, I need to calculate the surface area of the wings, as well as the surface area of the entire plane.

it's my first time dealing with a problem like this, so, I tried to search the internet, couldn't find anything useful, so I decided to ask this question


Solution

  • This is fairly straightforward by using the UProceduralMeshComponent. In Blueprints (or C++), you can copy the Static Mesh to the Procedural Mesh using the following node:

    Copy Procedural Mesh from Static Mesh Component

    You can then write a function that takes a pointer to UProceduralMeshComponent and use the following API: https://docs.unrealengine.com/4.27/en-US/BlueprintAPI/Components/ProceduralMesh/

    The function of interest is Get Section from Procedural Mesh which is also exposed to Blueprint scripting if that's what you prefer:

    Get Section from Procedural Mesh

    Now it's just a matter of looping over all the triangles and calculating the vector product (size of the cross product of the triangle's vectors) and summing them up.