/// <summary> /// Creates a texture cube with the given TexImage. /// </summary> /// <param name="textureList">The texture list.</param> /// <returns>An instance of <see cref="TexImage"/> containing the texture cube.</returns> /// <exception cref="TextureToolsException"> /// No available library could create the cube. /// or /// The number of texture in the texture list must be a multiple of 6. /// or /// The textures must all have the same size and format to be in a texture cube. /// </exception> public TexImage CreateTextureCube(List<TexImage> textureList) { var cube = new TexImage(); var request = new CubeCreationRequest(textureList); if (textureList.Count % 6 != 0) { Log.Error("The number of texture in the texture list must be a multiple of 6."); throw new TextureToolsException("The number of texture in the texture list must be a multiple of 6."); } ITexLibrary library = FindLibrary(cube, request); if (library == null) { Log.Error("No available library could create the cube."); throw new TextureToolsException("No available library could create the cube."); } int width = textureList[0].Width; int height = textureList[0].Height; int depth = textureList[0].Depth; cube.Format = textureList[0].Format; foreach (var texture in textureList) { texture.Update(); if (texture.Width != width || texture.Height != height || texture.Depth != depth || texture.Format != cube.Format) { Log.Error("The textures must all have the same size and format to be in a texture cube."); throw new TextureToolsException("The textures must all have the same size and format to be in a texture cube."); } } ExecuteRequest(cube, request); return cube; }
/// <summary> /// Creates a texture cube. /// </summary> /// <param name="image">The future cube texture.</param> /// <param name="request">The request.</param> private void CreateCube(TexImage image, CubeCreationRequest request) { Log.Info("Creating texture cube ..."); Create(image, new ArrayCreationRequest(request.TextureList)); image.Dimension = TexImage.TextureDimension.TextureCube; }