예제 #1
0
 //加载静态模型并将当前材质赋给模型
 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");
     }
 }
예제 #2
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!");
            }
        }