How can I get polygon normals of a static mesh?

I’m trying to access normals of a static mesh via C++. I managed to find verteces and triangles in LODResources, but I didn’t find anything related to triangle normals. Is there a way to get access to it or do I need to calculate them manually?

Cheers

Along the line of what you where already looking at:

FVector Normal = StaticMesh->RenderData->LODResources[LOD_Idx].VertexBuffer.VertexTangentZ(VertIdx);

If you want face/triangle normals rather than vertex normals, you have to calculate them yourself.

  • VertIdx goes from 0 to VertexBuffer.GetNumVertices()

When I try this in 4.13 I get a linking error

error LNK2001: unresolved external symbol "__declspec(dllimport) union __m128 const GVectorPackingConstants" (__imp_?GVectorPackingConstants@@3T__m128@@B)

I found that you need to include “RenderCore” into your dependencies for this to link properly.

I love you! I had the same problem, and you saved me!

yes yes :slight_smile:
you need to include “RenderCore” into your dependencies for this to link properly.

… meaning that you should add PublicDependencyModuleNames.AddRange(new string[] { "RenderCore" }); to the constructor of your Build.cs file. Or, if a PublicDependencyModuleNames.AddRange statement already exists, then you should add "RenderCore" to that existing array literal.