private void ExecuteReplaceAlphaMapCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string name     = texture.Name + "_alpha";
                string fileName = FileDialogService.GetOpenTextureFileName(name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    this.OptModel.File.Textures[texture.Name].SetAlphaMap(fileName);

                    dispatcher(() => this.OptModel.File = this.OptModel.File);
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(name, ex));
                }
            });
        }
        private void ExecuteReplaceMapCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenTextureFileName(texture.Name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    var newTexture  = Texture.FromFile(fileName);
                    newTexture.Name = texture.Name;

                    this.OptModel.File.Textures[newTexture.Name] = newTexture;

                    dispatcher(() => this.OptModel.File = this.OptModel.File);
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(texture.Name, ex));
                }
            });
        }
示例#3
0
        private void ExecuteAddTextureNameCommand()
        {
            if (this.CurrentFaceGroups.SelectedItem == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenTextureFileName();

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    var texture = Texture.FromFile(fileName);

                    int bpp = texture.BitsPerPixel;

                    texture.GenerateMipmaps();

                    if (bpp == 8)
                    {
                        texture.Convert32To8();
                    }

                    var mesh             = this.CurrentMeshes.SelectedItem;
                    var lod              = this.CurrentLods.SelectedItem;
                    var selectedTextures = this.CurrentFaceGroups.SelectedItem.Textures.ToList();
                    var faceGroups       = this.CurrentFaceGroups.SelectedItems.ToList();

                    this.OptModel.File.Textures[texture.Name] = texture;

                    foreach (var faceGroup in faceGroups.Where(t => selectedTextures.SequenceEqual(t.Textures)))
                    {
                        faceGroup.Textures.Add(texture.Name);
                    }

                    dispatcher(() => this.UpdateModel());
                    dispatcher(() => this.CurrentMeshes.SetSelection(mesh));
                    dispatcher(() => this.CurrentLods.SetSelection(lod));
                    dispatcher(() => this.CurrentFaceGroups.SetSelection(faceGroups));
                    dispatcher(() => this.OptModel.UndoStackPush("add texture name " + texture.Name));
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(fileName, ex));
                }
            });
        }
示例#4
0
        private void ExecuteReplaceAlphaMapCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string name = texture.Name + "_alpha";
                string fileName = FileDialogService.GetOpenTextureFileName(name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    int bpp = texture.BitsPerPixel;
                    int mipmapsCount = texture.MipmapsCount;

                    texture.RemoveMipmaps();
                    texture.SetAlphaMap(fileName);

                    if (mipmapsCount > 1)
                    {
                        texture.GenerateMipmaps();

                        if (bpp == 8)
                        {
                            texture.Convert32To8();
                        }
                    }

                    dispatcher(() => this.OptModel.File = this.OptModel.File);
                    dispatcher(() => this.OptModel.UndoStackPush("replace " + texture.Name));
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(name, ex));
                }
            });
        }
示例#5
0
        private void ExecuteReplaceMapCommand(Texture texture)
        {
            if (texture == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenTextureFileName(texture.Name);

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    var newTexture = Texture.FromFile(fileName);
                    newTexture.Name = texture.Name;

                    int bpp = newTexture.BitsPerPixel;

                    newTexture.GenerateMipmaps();

                    if (bpp == 8)
                    {
                        newTexture.Convert32To8();
                    }

                    this.OptModel.File.Textures[newTexture.Name] = newTexture;

                    dispatcher(() => this.OptModel.File = this.OptModel.File);
                    dispatcher(() => this.OptModel.UndoStackPush("replace " + texture.Name));
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(texture.Name, ex));
                }
            });
        }
示例#6
0
        private void ExecuteAddTextureNameCommand()
        {
            if (this.CurrentFaceGroups.SelectedItem == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                string fileName = FileDialogService.GetOpenTextureFileName();

                if (fileName == null)
                {
                    return;
                }

                try
                {
                    var texture = Texture.FromFile(fileName);

                    var mesh      = this.CurrentMeshes.SelectedItem;
                    var lod       = this.CurrentLods.SelectedItem;
                    var faceGroup = this.CurrentFaceGroups.SelectedItem;

                    this.OptModel.File.Textures[texture.Name] = texture;
                    faceGroup.Textures.Add(texture.Name);

                    dispatcher(() => this.UpdateModel());
                    dispatcher(() => this.CurrentMeshes.SetSelection(mesh));
                    dispatcher(() => this.CurrentLods.SetSelection(lod));
                    dispatcher(() => this.CurrentFaceGroups.SetSelection(faceGroup));
                }
                catch (Exception ex)
                {
                    Messenger.Instance.Notify(new MessageBoxMessage(fileName, ex));
                }
            });
        }