void ABasicProceduralMesh::creerTriangle()
{
TArray<FVector> vertices;
int triangleWidth = 100;
int triangleHeight = 100;
int curWidth = 0;
int curHeight = 0;
int numberOfTriangle = 10;
int numberOfVertex = 0;
for (int i = 0; i < numberOfTriangle; i++)
{
// Bottom Triangle
vertices.Add(FVector(0, curWidth, 0));
vertices.Add(FVector(0, (triangleWidth * i) + triangleWidth, 0));
vertices.Add(FVector(0, (triangleWidth * i), triangleHeight));
// Top triangle
vertices.Add(FVector(0, curWidth, triangleHeight));
vertices.Add(FVector(0, (triangleWidth * i) + triangleWidth, 0));
vertices.Add(FVector(0, (triangleWidth * i) + triangleHeight, triangleHeight));
for (int j = 0; j < 3;j++)
{
/*A*/ vertices.Add(FVector(0, curWidth, (j*triangleHeight) + triangleHeight));
/*B*/ vertices.Add(FVector(0, curWidth + triangleWidth, (triangleHeight *j) + triangleHeight));
/*C*/ vertices.Add(FVector(0, curWidth, (triangleHeight * (j + 1)) + triangleHeight ));
curHeight += triangleHeight;
numberOfVertex += 3;
}
curWidth += triangleWidth;
numberOfVertex += 6;
}
TArray<int32> Triangles;
for (size_t i = 0; i < numberOfTriangle * numberOfVertex; i++)
{
Triangles.Add(i);
}
TArray<FVector> normals;
normals.Add(FVector(1, 0, 0));
normals.Add(FVector(1, 0, 0));
normals.Add(FVector(1, 0, 0));
TArray<FVector2D> UV0;
UV0.Add(FVector2D(0, 0));
UV0.Add(FVector2D(10, 0));
UV0.Add(FVector2D(0, 10));
TArray<FProcMeshTangent> tangents;
tangents.Add(FProcMeshTangent(0, 1, 0));
tangents.Add(FProcMeshTangent(0, 1, 0));
tangents.Add(FProcMeshTangent(0, 1, 0));
TArray<FLinearColor> vertexColors;
vertexColors.Add(FLinearColor(0, 0, 0, 1.0));
vertexColors.Add(FLinearColor(0.5, 0.5, 0.75, 1.0));
vertexColors.Add(FLinearColor(0, 0, 0, 1.0));
myProceduralMesh->CreateMeshSection_LinearColor(0, vertices, Triangles, normals, UV0, vertexColors, tangents, true);
// Enable collision data
myProceduralMesh->ContainsPhysicsTriMeshData(true);
}