Exemplo n.º 1
0
        public static void LoadMeshGenerationData(string filePath, MeshGenerationData output)
        {
            output.Clear();

            var size   = new FileInfo(filePath).Length;
            var stride = sizeof(int) + 3 * sizeof(float);
            var count  = (size - 3 * sizeof(int)) / stride;

            using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (var mmf = MemoryMappedFile.CreateFromFile(fs, null, size, MemoryMappedFileAccess.Read, HandleInheritability.None, false))
                {
                    using (var accessor = mmf.CreateViewAccessor(0, size, MemoryMappedFileAccess.Read))
                    {
                        long pos = 0;

                        for (var i = 0; i < 3; ++i)
                        {
                            accessor.Read(pos, out int tmp);
                            output.gridSize[i] = tmp;
                            pos += sizeof(int);
                        }

                        for (var i = 0; i < count; ++i)
                        {
                            accessor.Read(pos, out int key);
                            pos += sizeof(int);
                            var val = TreeUtility.MmvaReadVector3(accessor, ref pos);
                            output.cells.Add(key, val);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public MeshBuilder(string dataPath, TreeImportSettings settings, TreeImportData importData)
        {
            this.dataPath   = dataPath;
            this.importData = importData;
            this.settings   = settings;
            tmpDataPath     = Path.Combine(dataPath, "tmp");

            voxelData = new MeshGenerationData();

            for (var i = 1; i < LutOffsets.Length; ++i)
            {
                neighborData.Add(LutOffsets[i], new MeshGenerationData());
            }
        }
Exemplo n.º 3
0
 public static void SaveMeshGenerationData(string filePath, MeshGenerationData data)
 {
     SaveMeshGenerationData(filePath, data.gridSize, data.cells);
 }