Created
May 29, 2018 01:02
-
-
Save ruohki/584d1f40a398876e31113a70f401f2b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ATestActor::CreateMesh() { | |
Mesh->ClearAllMeshSections(); | |
int x = 0; | |
int y = 0; | |
int z = 0; | |
FVector p0 = FVector(x * (BLOCK_RENDER_SIZE * 2) + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); | |
FVector p1 = FVector(x * (BLOCK_RENDER_SIZE * 2) + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); | |
FVector p2 = FVector(x * (BLOCK_RENDER_SIZE * 2) + BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); | |
FVector p3 = FVector(x * (BLOCK_RENDER_SIZE * 2) + BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); | |
FVector p4 = FVector(x * (BLOCK_RENDER_SIZE * 2) - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); | |
FVector p5 = FVector(x * (BLOCK_RENDER_SIZE * 2) - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z - BLOCK_RENDER_SIZE); | |
FVector p6 = FVector(x * (BLOCK_RENDER_SIZE * 2) - BLOCK_RENDER_SIZE, y - BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); | |
FVector p7 = FVector(x * (BLOCK_RENDER_SIZE * 2) - BLOCK_RENDER_SIZE, y + BLOCK_RENDER_SIZE, z + BLOCK_RENDER_SIZE); | |
// Normals | |
FVector n0 = FVector(1.0f, 0.0f, 0.0f); //Front | |
FVector n1 = FVector(-1.0f, 0.0f, 0.0f); //Back | |
FVector n2 = FVector(0.0f, -1.0f, 0.0f); //Left | |
FVector n3 = FVector(0.0f, 1.0f, 0.0f); //Right | |
FVector n4 = FVector(0.0f, 0.0f, 1.0f); //Top | |
FVector n5 = FVector(0.0f, 0.0f, -1.0f); //Bottom | |
// UVs | |
FVector2D u0 = FVector2D(0.f, 1.f); | |
FVector2D u1 = FVector2D(1.f, 1.f); | |
FVector2D u2 = FVector2D(1.f, 0.f); | |
FVector2D u3 = FVector2D(0.f, 0.f); | |
// Color | |
FColor c0 = FColor::Magenta; | |
// Tangents | |
FProcMeshTangent t0 = FProcMeshTangent(0.0f, 1.0f, 0.0f); | |
FProcMeshTangent t1 = FProcMeshTangent(0.0f, -1.0f, 0.0f); | |
FProcMeshTangent t2 = FProcMeshTangent(1.0f, 0.0f, 0.0f); | |
FProcMeshTangent t3 = FProcMeshTangent(-1.0f, 0.0f, 0.0f); | |
FProcMeshTangent t4 = FProcMeshTangent(0.0f, 1.0f, 0.0f); | |
FProcMeshTangent t5 = FProcMeshTangent(0.0f, -1.0f, 0.0f); | |
TArray<int> m_Triangles = { | |
0, 1, 2, 2, 3, 0, // Front | |
5, 4, 7, 7, 6, 5, // Back | |
1, 5, 6, 6, 2, 1, // Left | |
4, 0, 3, 3, 7, 4, // Right | |
6, 7, 3, 3, 2, 6, // Top | |
1, 0, 4, 4, 5, 1 // Bottom | |
}; | |
TArray<FVector> m_Verticies = { p0, p1, p2, p3, p4, p5, p6, p7 }; | |
TArray<FVector> m_Normals = { | |
n0, n0, n0, n0, | |
n1, n1, n1, n1, | |
n2, n2, n2, n2, | |
n3, n3, n3, n3, | |
n4, n4, n4, n4, | |
n5, n5, n5, n5 | |
}; | |
TArray<FVector2D> m_UVs = { | |
u0, u1, u2, u3, | |
u0, u1, u2, u3, | |
u0, u1, u2, u3, | |
u0, u1, u2, u3, | |
u0, u1, u2, u3, | |
u0, u1, u2, u3 | |
}; | |
TArray<FColor> m_Colors = { c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0, c0 }; | |
TArray<FProcMeshTangent> m_Tangents = { | |
t0, t0, t0, t0, | |
t1, t1, t1, t1, | |
t2, t2, t2, t2, | |
t3, t3, t3, t3, | |
t4, t4, t4, t4, | |
t5, t5, t5, t5 | |
}; | |
if (Material) { | |
Mesh->SetMaterial(0, Material); | |
} | |
Mesh->CreateMeshSection(0, m_Verticies, m_Triangles, m_Normals, m_UVs, m_Colors, m_Tangents, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment