//加载静态模型并将当前材质赋给模型 public void LoadStaticMesh(string pkg, string file) { try { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { NResourceLoc resLoc = new NResourceLoc(pkg, file); m_resStaticMesh = NResourceManager.Instance.LoadStaticMesh( resLoc, EResourceIOMode.Block, EResourceIOPriority.Normal ); for (int i = 0; i < m_resStaticMesh.GetNumLOD(); ++i) { for (int j = 0; j < m_resStaticMesh.GetNumSection(i); ++j) { m_resStaticMesh.ImportSetMaterial(i, j, m_Material); } } m_preview.ShowStaticMesh(m_resStaticMesh); m_Sphere = null; } } catch (System.Exception ex) { NexusEditor.Program.ShowException(ex, "Load Static Mesh FAILED"); } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (m_resStaticMesh != null) { using (VirtualFileDialog dlg = new VirtualFileDialog(false, "", "nmdl")) { dlg.SetResourceLocation(NLevelEditorEngine.Instance.CurrentFolder); dlg.Text = "保存模型 ..."; int i = m_resStaticMesh.Name.LastIndexOf('\\'); if (i == -1) { i = m_resStaticMesh.Name.LastIndexOf('/'); } if (i >= 0) { dlg.SetFileName(m_resStaticMesh.Name.Substring(i + 1, m_resStaticMesh.Name.Length - i - 1)); } else { dlg.SetFileName(m_resStaticMesh.Name); } if (dlg.ShowDialog(this) == DialogResult.OK) { NResourceLoc loc = dlg.GetResourceLocation(); using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) m_resStaticMesh.SaveToFile(loc, this.toolBtnXML.Checked); } } }// end of if else { NexusEditor.Program.ShowError("Static Mesh Resource Save FAILED!"); } }
private void AdapterTerrain_Click(object sender, EventArgs e) { NLevel host = NLevelEditorEngine.Instance.MainLevel; if (host != null) { // 找到地形的大小和位置 using (NexusEngineExtension.NWaitCursor waitCursor = new NexusEngineExtension.NWaitCursor(this)) { NActor actor = host.FirstActor(); while (actor != null) { NTerrainActor terrain = actor as NTerrainActor; if (terrain != null) { levelDesc.Location = terrain.Location; levelDesc.Scale = terrain.Scale; levelDesc.Width = Math.Max(levelDesc.Width, terrain.HeightMapWidth); levelDesc.Height = Math.Max(levelDesc.Height, terrain.HeightMapHeight); this.propertyGridNavMapDesc.SelectedObject = levelDesc; break; } actor = host.NextActor(); } } } }
public void LoadStaticMesh(string pkg, string file) { try { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { NResourceLoc resLoc = new NResourceLoc(pkg, file); m_resStaticMesh = NResourceManager.Instance.LoadStaticMesh( resLoc, EResourceIOMode.Block, EResourceIOPriority.Normal ); m_prop = new ResStaticMeshProperty(m_resStaticMesh); this.propertyGridRes.SelectedObject = m_prop; m_preview.ShowStaticMesh(m_resStaticMesh); RefreshLOD(); } } catch (System.Exception ex) { NexusEditor.Program.ShowException(ex, "Load Static Mesh FAILED"); } }
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 rebuildByActors_Click(object sender, EventArgs e) { if (MessageBox.Show(NexusEditor.Properties.Resources.RebuildNavMap, NexusEditor.Properties.Resources.Ok, MessageBoxButtons.OKCancel) == DialogResult.OK) { using (NexusEngineExtension.NWaitCursor waitCursor = new NexusEngineExtension.NWaitCursor(this)) { NLevelEditorEngine.Instance.NavigateMapEd.RebuildNavigationMap(levelDesc.MaxWalkableHeight, levelDesc.MaxWalkableStep, false); } } }
private void loadAnimSetToolStripMenuItem_Click(object sender, EventArgs e) { using (LevelLocDlg dlg = new LevelLocDlg()) { dlg.Text = "Load AnimSet ..."; dlg.SetResourceLocation(NLevelEditorEngine.Instance.LevelLoc); if (dlg.ShowDialog(this) == DialogResult.OK) { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { NResourceLoc loc = dlg.ResourceLocation; LoadAnimSet(loc.pkgName, loc.fileName); } } } }
private void treeViewFileSys_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Tag != null) { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { NEFileTag tag = (NEFileTag)e.Node.Tag; NLevelEditorEngine.Instance.CurrentFolder = new NResourceLoc(tag.pkgName, tag.path); m_PathList.Add(NLevelEditorEngine.Instance.CurrentFolder); if (m_PathList.Count == 11) //10次回溯 { m_PathList.RemoveAt(0); } m_PathPointer = m_PathList.Count - 1; RefreshFileList(); } } }
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!"); } }
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!"); } }
public void LoadSkeletalMesh(string pkg, string file) { try { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { NResourceLoc resLoc = new NResourceLoc(pkg, file); SkeletalMeshPreview = NResourceManager.Instance.LoadSkeletalMesh( resLoc, EResourceIOMode.Block, EResourceIOPriority.Normal ); } } catch (System.Exception ex) { Program.ShowException(ex, "Load Skeletal Mesh Failed!"); } }
private void ImportPSA() { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "ActorX PSA File(*.PSA)|*.PSA"; dlg.RestoreDirectory = true; if (dlg.ShowDialog(this) == DialogResult.OK) { if (AnimSetPreview == null) { // 产生一个不重复的名称 string resName = "NewAnimSet"; resName += DateTime.Now.ToFileTime(); // 创建空白资源和内部数据 AnimSetPreview = NResourceManager.Instance.NewSkeletalAnimSet(resName); } using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { try { AnimSetPreview.ImportSkeletalAnimSequence(dlg.FileName); AnimSetPreview.PostEditChange(true); if (animPlayer != null) { animPlayer.Init(AnimSetPreview, true); } } catch (System.Exception ex) { NexusEditor.Program.ShowException(ex, "Import Anim Set LOD FAILED!"); } // 更新界面 RefreshAnimSequeneList(); RefreshSkeletonTree(); } } }
private void toolStripButtonSave_Click(object sender, EventArgs e) { if (m_resAnimMesh != null) { NResourceLoc loc; if (m_prop.Name == m_prop.Location) { loc = new NResourceLoc(m_prop.Name); } else { loc = NLevelEditorEngine.Instance.CurrentFolder; if (!loc.IsValid()) { NexusEditor.Program.ShowError("Please Select a Folder in Resource Manager File System Tree!"); return; } string saveFileName = string.Format("{0}/{1}.nam", loc.FileName, m_prop.Name); loc.FileName = saveFileName; } string confirmTxt = string.Format("Save As [{1}]", m_resAnimMesh.Name, loc.ToString()); if (MessageBox.Show(this, confirmTxt, "Save Anim Mesh", MessageBoxButtons.OKCancel) == DialogResult.OK) { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) m_resAnimMesh.SaveToFile(loc, this.toolBtnXML.Checked); } }// end of if else { NexusEditor.Program.ShowError("Anim Mesh Resource Save FAILED!"); } }
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) }
private void SaveCurrentAnimSet() { if (AnimSetPreview == null) { NexusEditor.Program.ShowError("Anim Set 资源尚未创建!"); } using (VirtualFileDialog dlg = new VirtualFileDialog(false, "", "animset")) { //-- 设置dialogue属性 dlg.SetResourceLocation(NLevelEditorEngine.Instance.CurrentFolder); dlg.Text = "保存Anim Set ..."; //-- 请用户确认 if (dlg.ShowDialog(this) == DialogResult.OK) { NResourceLoc loc = dlg.GetResourceLocation(); using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) AnimSetPreview.SaveToFile(loc, this.toolBtnXML.Checked); } } }
public void LoadAnimSet(string pkg, string file) { try { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { NResourceLoc resLoc = new NResourceLoc(pkg, file); AnimSetPreview = NResourceManager.Instance.LoadSkeletalAnimSet( resLoc, EResourceIOMode.Block, EResourceIOPriority.Normal ); if (animPlayer != null) { animPlayer.Init(AnimSetPreview, true); } } } catch (System.Exception ex) { Program.ShowException(ex, "Load AnimSet Failed!"); } }
private void listViewResource_MouseDoubleClick(object sender, MouseEventArgs e) { ListView.SelectedListViewItemCollection selItems = this.listViewResource.SelectedItems; if (selItems.Count <= 0) { return; } ListViewItem sel = selItems[0]; NFileEntity nfile = (NFileEntity)sel.Tag; using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { switch (nfile.FileExtension) { case "spt": m_sptViewer.ShowSpt(nfile.pkg, nfile.path); m_sptViewer.Show(this); break; case "nmdl": m_staticMeshEditor.LoadStaticMesh(nfile.PackageName, nfile.FilePath); m_staticMeshEditor.Show(); break; case "nam": m_animMeshEditor.LoadAnimMesh(nfile.PackageName, nfile.FilePath); m_animMeshEditor.Show(); break; case "skm": m_animSetEditor.LoadSkeletalMesh(nfile.PackageName, nfile.FilePath); m_animSetEditor.Show(); break; case "animset": m_animSetEditor.LoadAnimSet(nfile.PackageName, nfile.FilePath); m_animSetEditor.Show(); break; case "txa": m_texAtlasViewer.LoadTextureAtlas(nfile.pkg, nfile.path); m_texAtlasViewer.Show(this); break; case "nui": m_guiEditor.LoadUI(nfile.pkg, nfile.path); if (!m_guiEditor.Visible) { m_guiEditor.Show(); } break; case "mtl": m_MaterialEditor.LoadMaterial(nfile.PackageName, nfile.FilePath); m_MaterialEditor.Show(); break; case "att": ResAttributeInfoEditor infoEditor = new ResAttributeInfoEditor(); infoEditor.ResetAttributeInfo(nfile.PackageName, nfile.FilePath); infoEditor.Show(); break; } } }