Esempio n. 1
0
        private void ExecuteDeleteTextureNamesCommand(IList <string> textureNames)
        {
            if (this.CurrentFaceGroups.SelectedItem == null)
            {
                return;
            }

            BusyIndicatorService.Run(dispatcher =>
            {
                var mesh      = this.CurrentMeshes.SelectedItem;
                var lod       = this.CurrentLods.SelectedItem;
                var faceGroup = this.CurrentFaceGroups.SelectedItem;

                foreach (var textureName in textureNames)
                {
                    faceGroup.Textures.Remove(textureName);
                }

                dispatcher(() => this.UpdateModel());
                dispatcher(() => this.CurrentMeshes.SetSelection(mesh));
                dispatcher(() => this.CurrentLods.SetSelection(lod));
                dispatcher(() => this.CurrentFaceGroups.SetSelection(faceGroup));
            });
        }
Esempio n. 2
0
        private void ExecuteMergeMeshesCommand(IList <Mesh> meshes)
        {
            BusyIndicatorService.Run(dispatcher =>
            {
                bool doMerge = true;

                if (meshes.Sum(t => t.Vertices.Count - 2) > 510)
                {
                    var result = Messenger.Instance.Notify(new MessageBoxMessage(
                                                               "The merged mesh may contain more than 512 vertices.\nDo you want to continue?",
                                                               "Merge Meshes",
                                                               MessageBoxButton.YesNo,
                                                               MessageBoxImage.Warning));

                    doMerge = result.Result == MessageBoxResult.Yes;
                }

                if (doMerge)
                {
                    dispatcher(() => this.CurrentMeshes.ClearSelection());

                    var merge = this.OptModel.File.MergeMeshes(meshes);

                    if (merge != null)
                    {
                        merge.MergeLods(merge.Lods
                                        .OrderBy(t => t.Distance)
                                        .TakeWhile(t => t.Distance == merge.Lods[0].Distance)
                                        .ToList());
                    }

                    dispatcher(() => this.UpdateModel());
                    dispatcher(() => this.CurrentMeshes.SetSelection(merge));
                }
            });
        }
Esempio n. 3
0
        private void ExecuteDownMeshesCommand(IList <Mesh> meshes)
        {
            BusyIndicatorService.Run(dispatcher =>
            {
                var opt = this.OptModel.File;

                dispatcher(() => this.CurrentMeshes.ClearSelection());

                var orderedMeshes = meshes
                                    .Select(mesh => new
                {
                    Mesh  = mesh,
                    Index = opt.Meshes.IndexOf(mesh)
                })
                                    .OrderByDescending(t => t.Index)
                                    .Select(t => t.Mesh)
                                    .ToList();

                foreach (var mesh in orderedMeshes)
                {
                    int index = opt.Meshes.IndexOf(mesh);

                    if (index == opt.Meshes.Count - 1)
                    {
                        continue;
                    }

                    opt.Meshes.RemoveAt(index);
                    opt.Meshes.Insert(index + 1, mesh);
                }

                dispatcher(() => this.UpdateModel());
                dispatcher(() => this.CurrentMeshes.SetSelection(meshes));
                dispatcher(() => this.OptModel.UndoStackPush("move down mesh"));
            });
        }