Ok, not sure to understand, here is my code to create a mesh: my class inherite from AActor. Maybe you can find a method that create automatically a cube geometry, otherwise here is how I draw myself the geometry:
ASofaVisualMesh::ASofaVisualMesh()
{
mesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("GeneratedMesh"));
RootComponent = mesh;
}
void ASofaVisualMesh::BeginPlay()
{
Super::BeginPlay();
TArray<FVector> vertices;
TArray<int32> Triangles;
TArray<FVector> normals;
TArray<FVector2D> UV0;
TArray<FProcMeshTangent> tangents;
TArray<FLinearColor> vertexColors;
// For a cube it should be something like:
for(int i=0; i<8; ++i)
{
vertices.Add(FVector(..., ..., ...));
normals.Add(....
}
for (int i = 0; i < 12; i++)
{
//create here the faces of the cube
}
mesh->CreateMeshSection_LinearColor(0, vertices, Triangles, normals, UV0, vertexColors, tangents, true);
// Enable collision data
mesh->ContainsPhysicsTriMeshData(true);
}