No announcement yet.

How do I get vertex normals from a static mesh?

  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    Alternatively, I found this:

    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.
    Last edited by Xenial J; 11-22-2019, 01:12 PM.

    I believe this is doing what I want:




    ... 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.

    Click image for larger version  Name:	Image-001--20191123.png Views:	0 Size:	543.5 KB ID:	1690060

    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().