Hi, folks!
I have this simple code to draw procedural cube:
void AProcActor::AddTriangle(int32 V1, int32 V2, int32 V3)
{
Triangles.Add(V1);
Triangles.Add(V2);
Triangles.Add(V3);
}
void AProcActor::CreateMesh()
{
//6 sides on cube, 4 verts each (corners)
//These are relative locations to the placed Actor in the world
Vertices.Add(FVector(0, -100, 0)); //lower left - 0
Vertices.Add(FVector(0, -100, 100)); //upper left - 1
Vertices.Add(FVector(0, 100, 0)); //lower right - 2
Vertices.Add(FVector(0, 100, 100)); //upper right - 3
Vertices.Add(FVector(100, -100, 0)); //lower front left - 4
Vertices.Add(FVector(100, -100, 100)); //upper front left - 5
Vertices.Add(FVector(100, 100, 100)); //upper front right - 6
Vertices.Add(FVector(100, 100, 0)); //lower front right - 7
//Back face of cube
AddTriangle(0, 2, 3);
AddTriangle(3, 1, 0);
//Left face of cube
AddTriangle(0, 1, 4);
AddTriangle(4, 1, 5);
//Front face of cube
AddTriangle(4, 5, 7);
AddTriangle(7, 5, 6);
//Right face of cube
AddTriangle(7, 6, 3);
AddTriangle(3, 2, 7);
//Top face
AddTriangle(1, 3, 5);
AddTriangle(6, 5, 3);
//bottom face
AddTriangle(2, 0, 4);
AddTriangle(4, 7, 2);
TArray<FColor> vertexColors;
ProcMesh->CreateMeshSection(0, Vertices, Triangles, TArray<FVector>(), UVs, vertexColors, TArray<FProcMeshTangent>(), true);
if (Material)
{
ProcMesh->SetMaterial(0, Material);
}
}
Everything works, but in the game my cube quality is too low. What’s wrong?
Material is pretty simple: