I have a MeshPatch Actor class which is responsible for generating a patch of terrain procedurally. I am utilizing six vector directions to generate a cube where each face generated by my MeshPatch class.
If I do the following in BeginPlay() of TerrainPatch.cpp:
TArray<FVector3f> Directions = {
FVector3f::UpVector,
FVector3f::DownVector,
FVector3f::LeftVector,
FVector3f::RightVector,
FVector3f::ForwardVector,
FVector3f::BackwardVector
};
for (int i = 0; i < 6; i++) {
InitializeMesh(200, 10000, Directions[i]);
CreateMesh();
}
There are no issues and my mesh renders correctly as a cube. The issue lies when I attempt to create an object of the MeshPatch class from another Actor class called Cube.
Within my Cube Actor (Cube.cpp) I’m attempting to create six objects of MeshPatch as follows:
TArray<FVector3f> Directions = {
FVector3f::UpVector,
FVector3f::DownVector,
FVector3f::LeftVector,
FVector3f::RightVector,
FVector3f::ForwardVector,
FVector3f::BackwardVector
};
for (int i = 0; i < 6; i++) {
AMeshPatch* TerrainFace = GetWorld()->SpawnActor<AMeshPatch>(AMeshPatch::StaticClass(), FVector::ZeroVector, FRotator::ZeroRotator);
if (TerrainFace != nullptr) {
TerrainFace->InitializeMesh(Resolution, Scale, Directions[i]);
TerrainFace->CreateMesh();
}
}
Now, all six TerrainFace actors are spawning on BeginPlay() when I check the outliner, but I do not see them being rendered at all (no cube this time around).
I am not sure what I am doing wrong, any help would be appreciated.