private bool IsMultiConversionEnabled() { return((_isProcessing == false) && !SourceDirectory.IsNullOrEmpty() && !DestinationDirectory.IsNullOrEmpty() && Textures.Any(node => node.IsPicked)); }
/// <summary> /// Combines the textures in this model into one bitmap and modifies all the referenced skins and texture coordinates to use the combined texture. /// This modifies the model object. /// </summary> private void CombineTextures() { if (!Textures.Any()) { return; } // Calculate the dimension of the combined texture var width = 0; var height = 0; var heightList = new Dictionary <int, int>(); foreach (var texture in Textures) { width = Math.Max(texture.Width, width); heightList.Add(texture.Index, height); height += texture.Height; } // Create the combined texture and draw all the textures onto it var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); using (var g = Graphics.FromImage(bmp)) { var y = 0; foreach (var texture in Textures) { g.DrawImage(texture.Image, 0, y); y += texture.Height; } } // Create the texture object and replace the existing textures var tex = new Texture { Flags = Textures[0].Flags, Height = height, Width = width, Image = bmp, Index = 0, Name = "Combined Texture" }; foreach (var texture in Textures) { texture.Image.Dispose(); } Textures.Clear(); Textures.Insert(0, tex); // Update all the meshes with the new texture and alter the texture coordinates as needed foreach (var mesh in GetActiveMeshes()) { if (!heightList.ContainsKey(mesh.SkinRef)) { mesh.SkinRef = -1; continue; } var i = mesh.SkinRef; var yVal = heightList[i]; foreach (var v in mesh.Vertices) { v.TextureV += yVal; } mesh.SkinRef = 0; } // Reset the texture indices for (var i = 0; i < Textures.Count; i++) { Textures[i].Index = i; } }