示例#1
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!");
            }
        }
        private void toolStripButtonImport_Click(object sender, EventArgs e)
        {
            try
            {
                int maxLOD = 0;
                if (m_resAnimMesh != null)
                {
                    maxLOD = m_resAnimMesh.GetNumLOD();
                }

                ImportLODDlg dlg = new ImportLODDlg(maxLOD);
                dlg.Text       = "Import Anim Mesh LOD";
                dlg.FileFilter = "All Support Files(*.fak;*.md2)|*.fak;*.md2|F3D Anim Mesh file(*.fak)|*.fak|Quake2 Anim Mesh file(*.md2)|*.md2";
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    if (m_resAnimMesh == null)
                    {
                        CreateResource();
                    }

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

                        m_prop.Name = fileName.FileNameNoExtension;
                    }

                    using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
                    {
                        m_resAnimMesh.ImportLOD(dlg.SelectedLOD, dlg.SelectedFile);
                        m_resAnimMesh.PostEditChange(true);

                        RefreshLOD();
                    }
                }
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Import Static Mesh LOD FAILED!");
            }
        }
示例#3
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int maxLOD = 0;
                if (m_resStaticMesh != null)
                {
                    maxLOD = m_resStaticMesh.GetNumLOD();
                }

                ImportLODDlg dlg = new ImportLODDlg(maxLOD);
                dlg.Text       = "Import Static Mesh LOD";
                dlg.FileFilter = "All Support Files(*.obj;*.fsm;*.fscn)|*.obj;*.fsm;*.fscn|Wavefront OBJ file(*.obj)|*.obj|F3D Static mesh file(*.fsm)|*.fsm|F3D Scene mesh file(*.fscn)|*.fscn";
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    if (m_resStaticMesh == null)
                    {
                        CreateResource();
                    }

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

                        m_prop.Name = fileName.FileNameNoExtension;
                    }

                    using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
                    {
                        m_resStaticMesh.ImportLOD(dlg.SelectedLOD, dlg.SelectedFile);
                        m_resStaticMesh.PostEditChange(true);
                        m_preview.ShowStaticMesh(m_resStaticMesh);
                        RefreshLOD();
                    }
                }
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Import Static Mesh LOD FAILED!");
            }
        }