Пример #1
0
        private void ResetResource(bool showCheckDlg)
        {
            if (showCheckDlg &&
                DialogResult.OK !=
                MessageBox.Show(this,
                                NexusEditor.Properties.Resources.ResetChecking,
                                "Please Confirm", MessageBoxButtons.OKCancel))
            {
                return;
            }

            previewControl.Reset();

            // 重置当前资源
            if (AnimSetPreview != null)
            {
                AnimSetPreview.Dispose();
                AnimSetPreview = null;
            }
            if (SkeletalMeshPreview != null)
            {
                SkeletalMeshPreview.Dispose();
                SkeletalMeshPreview = null;
            }
            skeletalMeshProperty = null;

            // 重置当前界面
            this.propertyGridMesh.SelectedObject = null;
            this.propertyGridMtl.SelectedObject  = null;
            this.comboBoxLOD.Items.Clear();
            this.comboBoxSection.Items.Clear();
            this.listBoxAnim.Items.Clear();
            this.propertyGridSeq.SelectedObject = null;
        }
Пример #2
0
        private void ImportPSK()
        {
            try
            {
                int maxLOD = 0;
                if (SkeletalMeshPreview != null)
                {
                    maxLOD = SkeletalMeshPreview.GetNumLOD();
                }

                ImportLODDlg dlg = new ImportLODDlg(maxLOD);
                dlg.Text       = "Import Skeletal Mesh LOD";
                dlg.FileFilter = "ActorX Skeletal Mesh file(*.PSK)|*.PSK";
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    if (SkeletalMeshPreview == null)
                    {
                        // 产生一个不重复的名称
                        string resName = "NewSkeletalMesh";
                        resName += DateTime.Now.ToFileTime();

                        // 创建空白资源和内部数据
                        SkeletalMeshPreview = NResourceManager.Instance.NewSkeletalMesh(resName);
                    }

                    //-- 使得Resource的名称与LOD 0的文件名相同
                    if (skeletalMeshProperty != null && dlg.SelectedLOD == 0)
                    {
                        NFileEntity fileName = new NFileEntity();
                        fileName.path = dlg.SelectedFile;
                        fileName.path = fileName.path.Replace('\\', '/');

                        skeletalMeshProperty.Name = fileName.FileNameNoExtension;
                    }

                    using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
                    {
                        try
                        {
                            SkeletalMeshPreview.ImportSkeletalMeshLOD(dlg.SelectedLOD, dlg.SelectedFile);
                            SkeletalMeshPreview.PostEditChange(true);
                            // 必须重置Preview
                            previewControl.ResetSkeletalMeshResource(skeletalMeshPreview);
                        }
                        catch (System.Exception ex)
                        {
                            NexusEditor.Program.ShowException(ex, "Import Skeletal Mesh LOD FAILED!");
                        }

                        // 更新界面
                        RefreshLOD();
                    }
                }
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Import Skeletal Mesh LOD FAILED!");
            }
        }
Пример #3
0
        private void comboBoxLOD_SelectedIndexChanged(object sender, EventArgs e)
        {
            int lod = this.comboBoxLOD.SelectedIndex;

            this.comboBoxSection.Items.Clear();
            int numSec = SkeletalMeshPreview.GetNumSection(lod);

            for (int i = 0; i < numSec; i++)
            {
                this.comboBoxSection.Items.Add(i.ToString());
            }
            this.comboBoxSection.SelectedIndex = 0;
        }
Пример #4
0
        private void RefreshLOD()
        {
            this.propertyGridMesh.SelectedObject = skeletalMeshProperty;

            this.comboBoxLOD.Items.Clear();
            if (SkeletalMeshPreview != null &&
                SkeletalMeshPreview.GetNumLOD() > 0)
            {
                //-- LOD ComboBox
                for (int i = 0; i < SkeletalMeshPreview.GetNumLOD(); i++)
                {
                    this.comboBoxLOD.Items.Add(i.ToString());
                }
                this.comboBoxLOD.SelectedIndex = 0;
            }// end of if
        }
Пример #5
0
        private void SaveCurrentSkeletalMesh()
        {
            //-- 检测资源是否可用
            if (SkeletalMeshPreview == null)
            {
                NexusEditor.Program.ShowError("Skeletal Mesh 资源尚未创建!");
                return;
            }

            using (VirtualFileDialog dlg = new VirtualFileDialog(false, "", "skm"))
            {
                //-- 设置dialogue属性
                dlg.SetResourceLocation(NLevelEditorEngine.Instance.CurrentFolder);
                dlg.Text = "保存Skeletal Mesh ...";
                int i = skeletalMeshProperty.Name.LastIndexOf('\\');
                if (i == -1)
                {
                    i = skeletalMeshProperty.Name.LastIndexOf('/');
                }
                if (i >= 0)
                {
                    dlg.SetFileName(skeletalMeshProperty.Name.Substring(i + 1, skeletalMeshProperty.Name.Length - i - 1));
                }
                else
                {
                    dlg.SetFileName(skeletalMeshProperty.Name);
                }

                //-- 请用户确认
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    NResourceLoc loc = dlg.GetResourceLocation();

                    using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
                        SkeletalMeshPreview.SaveToFile(loc, this.toolBtnXML.Checked);
                }
            }// end of using(dg)
        }
Пример #6
0
        public new void Close()
        {
            if (updateTimer != null)
            {
                // close refresh timer
                updateTimer.Stop();
                updateTimer.Dispose();
                updateTimer = null;
            }

            if (SkeletalMeshPreview != null)
            {
                SkeletalMeshPreview.Dispose();
            }
            if (AnimSetPreview != null)
            {
                AnimSetPreview.Dispose();
            }
            previewControl.Dispose();

            finalClose = true;
            base.Close();
        }