void World::FillBox(const Point3i &lowerBound, const Point3i &upperBound, unsigned char id) { for(int x = lowerBound.x; x < upperBound.x; x++) for(int y = lowerBound.y; y < upperBound.y; y++) for(int z = lowerBound.z; z < upperBound.z; z++) SetVoxel(x, y, z, id); }
VoxelModel::VoxelModel(const uint32_t sizeX, const uint32_t sizeY, const uint32_t sizeZ) : Model(), _sizeX(sizeX), _sizeY(sizeY), _sizeZ(sizeZ), _maxPoint(Position.x + VOXEL_SIZE_X * sizeX, Position.y + VOXEL_SIZE_Y * sizeY, Position.z + VOXEL_SIZE_Z * sizeZ) { _data = (uint8_t*)calloc(sizeX * sizeY * sizeZ, sizeof(uint8_t)); SetVoxel(0, 0, 0, 1); SetVoxel(9, 9, 9, 1); for (int x = 0; x < _sizeX; ++x) { for (int y = 0; y < _sizeY; ++y) { for (int z = 0; z < _sizeZ; ++z) { if (rand() % 2 == 0) SetVoxel(x, y, z, 1); } } } }
void UVoxelComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) { static const FName NAME_HideUnbeheld = FName(TEXT("bHideUnbeheld")); static const FName NAME_Mesh = FName(TEXT("Mesh")); static const FName NAME_Voxel = FName(TEXT("Voxel")); if (PropertyChangedEvent.Property) { if (PropertyChangedEvent.Property->GetFName() == NAME_HideUnbeheld) { ClearVoxel(); AddVoxel(); } else if (PropertyChangedEvent.Property->GetFName() == NAME_Mesh) { FBoxSphereBounds Bounds(ForceInit); for (int32 i = 0; i < Mesh.Num(); ++i) { InstancedStaticMeshComponents[i]->SetStaticMesh(Mesh[i]); if (Mesh[i]) { Bounds = Bounds + Mesh[i]->GetBounds(); } } CellBounds = Bounds; } else if (PropertyChangedEvent.Property->GetFName() == NAME_Voxel) { SetVoxel(Voxel, true); } } }
void Chunk::SetVoxel(const int x, const int y, const int z, byte type) { SetVoxel(glm::vec3(x, y, z), type); }