static PaintedCubeSpace loadSpaceFromLoadedSpaces(string path) { LoadedCubeSpaceData data = loadedByteArrays[path]; PaintedCubeSpace space = new PaintedCubeSpace(data.spaceWidth, data.spaceHeight, new Vector3()); space.array = /*new byte[data.spaceWidth, data.spaceHeight, data.spaceWidth];*/ data.array; //data.unmippedArray.CopyTo(maybeSpace.unmippedArray, 0); space.setUnmippedBuffers(data.vertexBuffer, data.indexBuffer); space.setLoadedFrompath(path); return(space); }
static PaintedCubeSpace loadSpaceFromDisk(string path) { byte[, ,] byteArray; string fullPath = ContentDistributor.addNecesaryPathing(path); Stream stream = File.Open(fullPath, FileMode.Open); BinaryFormatter formatter = new BinaryFormatter(); byteArray = (byte[, , ])formatter.Deserialize(stream); FileInfo fileInfo = new FileInfo(fullPath); long fileLength = fileInfo.Length; int spaceWidth = (int)Math.Pow(fileLength, 1.0 / 3.0); int spaceHeight = (int)Math.Pow(fileLength, 1.0 / 3.0); stream.Close(); //loadedByteArrays.Add(path, byteArray); PaintedCubeSpace paintedCubeSpace = new PaintedCubeSpace(1, 1, new Vector3()); paintedCubeSpace.spaceWidth = spaceWidth; paintedCubeSpace.spaceHeight = spaceHeight; paintedCubeSpace.array = byteArray; paintedCubeSpace.createModel(Main.graphics.GraphicsDevice); LoadedCubeSpaceData dataToSave = new LoadedCubeSpaceData(); dataToSave.array = byteArray; dataToSave.spaceHeight = spaceHeight; dataToSave.spaceWidth = spaceWidth; dataToSave.vertexBuffer = paintedCubeSpace.getVertexBuffer(); dataToSave.indexBuffer = paintedCubeSpace.getIndexBuffer(); loadedByteArrays.Add(path, dataToSave); paintedCubeSpace.setLoadedFrompath(path); return(paintedCubeSpace); }