Beispiel #1
0
        private void CheckForComplete(SlicingOptions options, CubeManager manager)
        {
            int expectedResults = options.TextureSliceX * options.TextureSliceY;

            if (StorageUtilities.GetWorkCompletedCount(TableClient, options.CloudResultPath, options.CloudResultContainer) != expectedResults)
            {
                return;
            }

            var workResults = StorageUtilities.GetWorkCompletedMetadata(TableClient, options.CloudResultPath, options.CloudResultContainer);

            // Write metadata

            CubeMetadata metadata = new CubeMetadata(options.CubeGrid)
            {
                WorldBounds        = manager.ObjInstance.Size,
                VirtualWorldBounds = options.ForceCubicalCubes ? manager.ObjInstance.CubicalSize : manager.ObjInstance.Size,
                VertexCount        = manager.ObjInstance.VertexList.Count
            };

            // Configure texture slicing metadata
            if (!string.IsNullOrEmpty(options.Texture) && (options.TextureSliceX + options.TextureSliceY) > 2)
            {
                metadata.TextureSetSize = new Vector2(options.TextureSliceX, options.TextureSliceY);
            }
            else
            {
                metadata.TextureSetSize = new Vector2(1, 1);
            }

            var resultsList = workResults.Select(w =>
                                                 SerializationUtilities.DecodeMetadataFromBase64(
                                                     Texture.GetCubeListFromTextureTile(options.TextureSliceY, options.TextureSliceX, w.TextureTileX, w.TextureTileY, manager.ObjInstance),
                                                     w.MetadataBase64));

            foreach (var result in resultsList)
            {
                foreach (var cube in result.Keys)
                {
                    metadata.CubeExists[cube.X, cube.Y, cube.Z] = result[cube];
                }
            }


            // Write out some json metadata
            string metadataPath = Path.Combine(outputPath, "metadata.json");

            if (File.Exists(metadataPath))
            {
                File.Delete(metadataPath);
            }

            string metadataString = JsonConvert.SerializeObject(metadata);

            File.WriteAllText(metadataPath, metadataString);

            StorageUtilities.UpdateSetCompleted(TableClient, options.SetKey);
        }