public SetVersionResultContract GetSetVersion(string setId, string versionId)
        {
            SetVersionResultContract result = new SetVersionResultContract();

            LoaderResults setData = this.loadedSetData.Get();

            if (setData == null)
            {
                throw new NotFoundException("setData");
            }

            SetVersion setVersion = setData.FindSetVersion(setId, versionId);

            result.Set          = setVersion.Name;
            result.Version      = setVersion.Version;
            result.DetailLevels =
                setVersion.DetailLevels.Values.Select(
                    l =>
                    new LevelOfDetailContract
            {
                Name             = l.Name,
                SetSize          = new Vector3Contract(l.SetSize),
                ModelBounds      = new BoundingBoxContract(l.ModelBounds),
                WorldBounds      = new BoundingBoxContract(l.WorldBounds),
                TextureSetSize   = new Vector2Contract(l.TextureSetSize),
                WorldCubeScaling = new Vector3Contract(l.WorldToCubeRatio),
                VertexCount      = l.VertexCount
            }).ToArray();

            return(result);
        }
        public Task <StorageStream> GetModelStream(string setId, string versionId, string detail, string xpos, string ypos, string zpos, string format)
        {
            LoaderResults setData = this.loadedSetData.Get();

            if (setData == null)
            {
                throw new NotFoundException("setData");
            }

            SetVersion setVersion = setData.FindSetVersion(setId, versionId);
            SetVersionLevelOfDetail lod;

            if (!setVersion.DetailLevels.TryGetValue(detail, out lod))
            {
                throw new NotFoundException("detailLevel");
            }

            ModelFormats modelFormat;

            if (format == null)
            {
                modelFormat = ModelFormats.Ebo;
            }
            else if (!ModelFormats.TryParse(format, true, out modelFormat))
            {
                throw new NotFoundException("format");
            }

            string modelPath = lod.ModelTemplate.ToString();

            modelPath = ExpandCoordinatePlaceholders(modelPath, xpos, ypos, zpos, modelFormat);

            return(this.GetStorageStreamForPath(modelPath));
        }
        public Task <StorageStream> GetTextureStream(string setId, string versionId, string detail, string xpos, string ypos)
        {
            LoaderResults setData = this.loadedSetData.Get();

            if (setData == null)
            {
                throw new NotFoundException("setData");
            }

            SetVersion setVersion = setData.FindSetVersion(setId, versionId);
            SetVersionLevelOfDetail lod;

            if (!setVersion.DetailLevels.TryGetValue(detail, out lod))
            {
                throw new NotFoundException("detailLevel");
            }

            string texturePath = lod.TextureTemplate.ToString();

            texturePath = texturePath.Replace(X_PLACEHOLDER, xpos);
            texturePath = texturePath.Replace(Y_PLACEHOLDER, ypos);
            return(this.GetStorageStreamForPath(texturePath));
        }