How do I get vertex normals from a static mesh?

Using the Runtime Mesh Component plugin, creating a runtime mesh requires the set of vertex normals (among other things) to be passed in. I was intending to do this by getting all needed data from a static mesh already in the level.

With a static mesh, I am able to get:

  • vertex positions from mesh->RenderData->LODResources[0].VertexBuffers.PositionVertexBuffer;
  • vertex indexes from mesh->RenderData->LODResources[0].IndexBuffer.GetArrayView();

I am guessing I can also get UVs and tangents from:

  • VertexBuffers.StaticMeshVertexBuffer.GetVertexUV(), and
  • VertexBuffers.StaticMeshVertexBuffer.GetTangentData()

But how do I get the mesh’s vertex normals? [HR][/HR]
Alternatively, I found this: How can I get polygon normals of a static mesh? - Rendering - Unreal Engine Forums

This appears to be just what I was looking for, however I don’t find that it works. In particular:

  • LODResources[0], which is a FStaticMeshLODResources, has no “VertexBuffer” member, and
  • VertexBuffers, which is a FStaticMeshVertexBuffers, has no GetTangentZ() function.

Perhaps I am missing something simple with that answer though.

I believe this is doing what I want:

myMesh->RenderData->LODResources[0].VertexBuffers.StaticMeshVertexBuffer.VertexTangentZ(vertIndex);

Similarly,

myMesh->RenderData->LODResources[0].VertexBuffers.StaticMeshVertexBuffer.VertexTangentX(vertIndex);

… can be used to get vertex tangents.

I’m not 100% sure that this is the right thing to do for getting a Static Mesh’s vertex normals & tangents. I really only stumbled upon the public variables and did a quick test with an 8-vertex cube.

Seems to be what I want, but would be great if someone could confirm.

Those look like the normals. What are they needed for? Isn’t there a view mode or something in the dropdowns of the engine UI to show vertex normals of meshes? is it possible to reference that in a get / call operation that’d work with the plugin?

They were indeed what I needed (to confirm for you and any future readers); I’ve been using it since.
Hooking into something available in the UI might be possible but wouldn’t be as direct as using VertexTangentZ().