/// <summary> /// Creates a rectangular VoxelGrid, with or without a slab GameObject /// </summary> /// <param name="size">The vector representing the size of the grid</param> /// <param name="voxelSize">The size of the voxel in metres</param> /// <param name="origin">The origin of the grid to be created</param> public VoxelGrid(Vector3Int size, float voxelSize, Vector3 origin, bool createGO = false, bool GOvisibility = false) { Size = size; VoxelSize = voxelSize; Origin = origin; Faces = new Face[3][, , ]; ExistingParts = new List <Part>(); Spaces = new List <PPSpace>(); Boundaries = new List <Voxel>(); _showVoxels = !GOvisibility; if (Size == new Vector3Int(30, 1, 24)) { _pix2pix = new PP_pix2pix("30x24"); } else { _pix2pix = new PP_pix2pix("original"); } SetupVoxels(); if (createGO) { InstantiateGenericGO(); } StoresCurrentRenderTexture64(); }
void Start() { _cam = Camera.main; CreateGridFromFile(); //Load tenants and requests data _tenants = JSONReader.ReadTenantsWithPreferences("Input Data/U_TenantPreferences", _grid); _spaceRequests = JSONReader.ReadSpaceRequests("Input Data/U_SpaceRequests", _tenants); _cameraPivot.position = new Vector3(_gridSize.x / 2, 0, _gridSize.z / 2) * _voxelSize; //Create the pix2pix object _pix2pix = new PP_pix2pix("original"); }
/// <summary> /// Constructor for a VoxelGrid instance from a file with its configurations /// </summary> /// <param name="gridName">The name of the grid file</param> /// <param name="gridType">The name of the grid type</param> public VoxelGrid(string gridName, string gridType, float voxelSize, Vector3 origin) { VoxelSize = voxelSize; Origin = origin; Faces = new Face[3][, , ]; ExistingParts = new List <Part>(); Spaces = new List <PPSpace>(); Boundaries = new List <Voxel>(); _pix2pix = new PP_pix2pix("original"); _gridName = gridName; _gridType = gridType; //Read one state from folder DirectoryInfo folder = new DirectoryInfo(Application.dataPath + $"/Resources/Input Data/TrainingData/{_gridName}"); string[] dimensions = folder.Name.Split('_'); int xSize = int.Parse(dimensions[0]); int zSize = int.Parse(dimensions[1]); Size = new Vector3Int(xSize, 1, zSize); SetupVoxels(); //_grid = new VoxelGrid(_gridSize, _voxelSize, Vector3.zero); //set the states of the voxel grid string statesFile = "Input Data/TrainingData/" + _gridName + "/" + _gridType + "_SlabStates"; CSVReader.SetGridState(this, statesFile); //move camera pivot to grid center //_cameraPivot.position = new Vector3(Size.x / 2, 0, Size.z / 2) * VoxelSize; //populate structure string structureFile = "Input Data/TrainingData/" + _gridName + "/" + _gridType + "_Structure"; ReadStructure(structureFile); InstantiateGridGO(); }
/// <summary> /// Constructor for a copy grid that holds only the states /// </summary> /// <param name="original"></param> public VoxelGrid(VoxelGrid original) { Size = original.Size; Origin = original.Origin; Voxels = new Voxel[Size.x, Size.y, Size.z]; for (int x = 0; x < Size.x; x++) { for (int y = 0; y < Size.y; y++) { for (int z = 0; z < Size.z; z++) { Voxels[x, y, z] = original.Voxels[x, y, z].DeepCopyToGrid(this); } } } // make faces (from https://github.com/ADRC4/Voxel) Faces = new Face[3][, , ]; Faces[0] = new Face[Size.x + 1, Size.y, Size.z]; for (int x = 0; x < Size.x + 1; x++) { for (int y = 0; y < Size.y; y++) { for (int z = 0; z < Size.z; z++) { Faces[0][x, y, z] = new Face(x, y, z, Axis.X, this); } } } Faces[1] = new Face[Size.x, Size.y + 1, Size.z]; for (int x = 0; x < Size.x; x++) { for (int y = 0; y < Size.y + 1; y++) { for (int z = 0; z < Size.z; z++) { Faces[1][x, y, z] = new Face(x, y, z, Axis.Y, this); } } } Faces[2] = new Face[Size.x, Size.y, Size.z + 1]; for (int x = 0; x < Size.x; x++) { for (int y = 0; y < Size.y; y++) { for (int z = 0; z < Size.z + 1; z++) { Faces[2][x, y, z] = new Face(x, y, z, Axis.Z, this); } } } ExistingParts = new List <Part>(); Spaces = new List <PPSpace>(); Boundaries = new List <Voxel>(); _pix2pix = original._pix2pix; }