Download

How to get vertices of static mesh?

I want to copy the vertices of a static mesh into my procedural mesh component. (This will be its initial state, but will be modified later)

Does anyone know how to grab the vertices, faces, and UV coordinates? (Normals too) I’ve been digging around a bit but haven’t found where I need to go to grab this data from.

Ok, I can get the vertices now, but I need the faces, which would be lists or vertex entries, I think?


     if (InMesh->RenderData->LODResources.Num() > 0)
	{
		FPositionVertexBuffer* VertexBuffer = &InMesh->RenderData->LODResources[0].PositionVertexBuffer;
		if (VertexBuffer)
		{
			const int32 VertexCount = VertexBuffer->GetNumVertices();
			for (int32 Index = 0; Index < VertexCount; Index++)
			{
				//This is in the Static Mesh Actor Class, so it is location and tranform of the SMActor
				const FVector Vertex = VertexBuffer->VertexPosition(Index);
				//add to output FVector array
				MeshVerts.Add(Vertex);
			}
		}

		int32 NumSections = InMesh->RenderData->LODResources[0].Sections.Num();

		for (int32 i = 0; i < NumSections; i++)
		{
			//something here to get the faces?!?!?!
		}


	}