public void CreateEditorForms() { NLevelEditorEngine.Instance.LevelChanged += new EventHandler(Editor_LevelChanged); NEditorCommandManager cmdMgr = NLevelEditorEngine.Instance.CommandMgr; cmdMgr.UndoStackChanged += new EventHandler(this.UndoStackChangedEvent); cmdMgr.RedoStackChanged += new EventHandler(this.RedoStackChangedEvent); m_layerDlg = new LayerManagerDlg(); m_GlobalSettingForm = new GlobalSettingForm(); //加载最近用过的文件 m_RecentFile = new RecentFile(); m_RecentFile.Load(); for (int i = 0; i < m_RecentFile.FileCount; ++i) { NResourceLoc loc = m_RecentFile.GetFile(i); if (loc.IsValid()) { ToolStripItem item = MTU.DropDown.Items.Add(loc.ToString()); if (item != null) { item.Click += this.OnLoadRecentFile; } } } //读取各种设置 ReadSettings(); }
/// <summary> /// 拖放结束事件, Resource Quick List中拖动一个Mesh资源文件,创建响应的Actor到Level中 /// </summary> void NEMainViewport_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(NexusEngine.NFileEntity))) { NFileEntity resFile = (NFileEntity)e.Data.GetData(typeof(NFileEntity)); NResourceLoc resLoc = new NResourceLoc(resFile.PackageName, resFile.FilePath); if (ResourceEditor.ResourceActorCreator.AcceptResoruceFile(resLoc)) { NLevel mainLv = NLevelEditorEngine.Instance.MainLevel; NActor newActor = ResourceEditor.ResourceActorCreator.CreateActor(resLoc); if (newActor == null) { MessageBox.Show("添加对象失败,可能的原因是读取对象数据失败,或者当前作业层被锁定,等等", "错误"); return; } Point scrPt = new Point(e.X, e.Y); Point clientPt = this.PointToClient(scrPt); Ray ray = m_view.Camera.GetMouseRay(clientPt.X, clientPt.Y); NCheckResult chk; if (RayCheck(out chk, ray, 512 * 1024, LineCheckType.Terrain)) { newActor.Location = chk.location; } else { Vector3 pt = ray.Position + ray.Direction * 500; newActor.Location = pt; } } } }
public void LoadTextureAtlas(string pkgName, string fileName) { try { //-- Load资源对象 NResourceLoc loc = new NResourceLoc(pkgName, fileName); m_resource = NResourceManager.Instance.LoadTextureAtlas(loc, EResourceIOMode.Block, EResourceIOPriority.Normal); //-- Load贴图文件 fileName = fileName.Replace(".txa", ".tga");//找到对应的贴图文件 IntPtr hbmp = NLevelEditorEngine.Instance.LoadTextureAsBitmap( new NResourceLoc(pkgName, fileName) ); //-- 更新控件显示 Image img = Image.FromHbitmap(hbmp); m_imgSize = img.Size; this.pictureBoxMain.Image = img; //-- 显示Item List UpdateAtlasList(); } catch (System.Exception e) { Program.ShowException(e, "Texture Atlas Load Failed"); } }
/// <summary> /// 响应Resource列表选中事件, 将选中的文件的缩略图显示到列表下方的PictureBox上 /// </summary> private void listViewResource_SelectedIndexChanged(object sender, EventArgs e) { ListView.SelectedListViewItemCollection selItems = this.listViewResource.SelectedItems; if (selItems.Count <= 0) { return; } ListViewItem sel = selItems[0]; NFileEntity nfile = (NFileEntity)sel.Tag; NResourceLoc resLoc = new NResourceLoc(nfile.PackageName, nfile.FilePath); //m_resPreview.ShowResource(resLoc); //m_resPreview.ZoomExtents(); int i = m_resBigImgList.Images.IndexOfKey(resLoc.ToString()); if (i == -1) { this.pictureBoxResource.Image = null; } else { this.pictureBoxResource.Image = m_resBigImgList.Images[i]; } }
static private string MakeComponentName(string prefix, NResourceLoc res) { string ret = prefix + res.ToString(); ret = ret.Replace(':', '_'); return(ret.Replace('/', '_')); }
public void LoadMaterial(string pkg, string file) { m_Location = new NResourceLoc(pkg, file); m_Material = NMtlBase.FromFile(m_Location); if (m_Material == null) { this.propertyGridMtl.SelectedObject = null; return; } m_Material.Name = m_Location.ToString(); MaterialProperty mtlProp = new MaterialProperty(m_Material); mtlProp.ApplyChange(); this.propertyGridMtl.SelectedObject = mtlProp; if (m_Sphere == null) { LoadSphere(); } if (m_Material != null) { m_Sphere.SetMaterial(m_Material); } m_preview.Refresh(); }
//加载静态模型并将当前材质赋给模型 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"); } }
static public NActor ReplaceActor(NActor actor, NResourceLoc resLoc) { actor.RemoveAllComponents(); CreateActorComponent(actor, resLoc); actor.UpdateComponentsTransform(); return(actor); }
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!"); } }
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 btnOK_Click(object sender, EventArgs e) { if (!m_OpenFileMode) { NResourceLoc loc = GetResourceLocation(); if (NEngine.Instance().FileSystem.IsFileExist(loc.PackageName, loc.FileName)) { DialogResult rst = MessageBox.Show("当前名称的文件已经存在,是否覆盖?", "警告", MessageBoxButtons.YesNo); if (rst != DialogResult.Yes) { return; } else { DialogResult = DialogResult.OK; this.Close(); } } else { DialogResult = DialogResult.OK; this.Close(); } } else { DialogResult = DialogResult.OK; this.Close(); } }
public void LoadMainLevel(NResourceLoc loc) { try { //-- 必须先销毁当前的, 因为加载进来的关卡可能和他同名 DestroyLevel(m_mainLevel); m_mainLevel.Dispose(); //-- load NLevel lv = LoadLevel(loc); //-- m_mainLevel = lv; m_levelLoc = loc; ResetSubEditors(); if (LevelChanged != null) { LevelChanged(this, null); } } catch (System.Exception e) { NexusEditor.Program.ShowException(e, "Level Load FAILED!"); // 保持一个空关卡 CreateMainLevel("defaultLevel"); } }
public override void CreateMainLevel(string levelName) { base.CreateMainLevel(levelName); m_levelLoc = new NResourceLoc(); if (LevelChanged != null) { LevelChanged(this, null); } }
virtual public void ResetResource(NResourceLoc loc) { if (TargetActor != null && animMesh == null) { NActorComponent comp = TargetActor.CreateComponent(animMeshNameGenerator.GetNextUniqueName(), "nanim_mesh_component"); animMesh = comp as NAnimMeshComponent; } animMesh.ResetResource(loc); }
public void SaveMainLevel(NResourceLoc loc) { SaveLevel(this.MainLevelName, loc); m_levelLoc = loc; if (LevelChanged != null) { LevelChanged(this, null); } }
private void RelocationStytlePath(NResourceLoc loc) { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { // 便利该目录中的所有Style *.nui文件 using (UIFileQurery qurery = new UIFileQurery(this.listViewStyle, loc.PackageName, loc.FileName)) { this.textBoxStyle.Text = loc.ToString(); } } }
/// <summary> /// 响应引擎当前工作目录更改时间, 把当前工作目录中的Mesh资源文件显示到列表中 /// </summary> void Engine_CurrentFolderChanged(object sender, EventArgs e) { NResourceLoc folder = NLevelEditorEngine.Instance.CurrentFolder; NEFileListBuilder lb = new NEFileListBuilder( this.listViewResource, m_resBigImgList, this.imageListResource, folder.PackageName, folder.FileName); lb.SetFilter(m_meshFileFilter); lb.BuildList(); }
public NResourceLoc GetResourceLocation() { string fileName = textFile.Text; if (m_DefaultExtName.Length > 0 && fileName.LastIndexOf('.') == -1) { fileName = fileName + "." + m_DefaultExtName; } NResourceLoc loc = new NResourceLoc(txtPackage.Text, txtFolder.Text + "\\" + fileName); return(loc); }
public void MakeIt() { NResourceLoc inputLoc = new NResourceLoc(textBoxFolder.Text); NResourceLoc outputLoc = new NResourceLoc(textBoxOutputFolder.Text); NLevelEditorEngine.Instance.MakeTextureAtlas( inputLoc, outputLoc, int.Parse(txtWidth.Text), int.Parse(txtHeight.Text) ); }
public SkeletalMeshMaterialProperty(NResourceSkeletalMesh res, int lod, int sec) { m_Res = res; m_Lod = lod; m_Section = sec; if (m_Res != null) { NMtlBase mtl = m_Res.GetMaterial(m_Lod, m_Section); if (mtl != null) { m_Loc = new NResourceLoc(mtl.Name); } } }
public void SetResourceLocation(NResourceLoc loc) { if (loc.IsValid()) { this.txtPackage.Text = loc.PackageName; this.txtFolder.Text = loc.FileName; } else { this.txtPackage.Text = ""; this.txtFolder.Text = ""; } }
private void saveSToolStripMenuItem_Click(object sender, EventArgs e) { //保存特效 using (VirtualFileDialog dlg = new VirtualFileDialog()) { dlg.Text = "保存特效 ..."; if (dlg.ShowDialog(this) == DialogResult.OK) { NResourceLoc loc = dlg.GetResourceLocation(); m_res.SaveToFile(loc, true); } } }
private void toolStripButton2_Click(object sender, EventArgs e) { //打开现有的材质文件 using (VirtualFileDialog dlg = new VirtualFileDialog(true, "", "mtl")) { dlg.Text = "Load Material ..."; if (dlg.ShowDialog(this) == DialogResult.OK) { m_Location = dlg.GetResourceLocation(); LoadMaterial(m_Location.PackageName, m_Location.FileName); } } }
public override void PostCreateActor(NexusEngine.NActor actor) { base.PostCreateActor(actor); //创建体积雾部件 actor.CreateComponent("WaterComponent", "nwater_component"); //创建显示用部件 NResourceLoc res = new NResourceLoc("engine_data", "/editor_res/ball.nmdl"); NActorComponent comp = actor.CreateComponent("WaterSignBoard", "nstatic_editor_mesh_component"); NStaticMeshComponent meshComp = comp as NStaticMeshComponent; meshComp.ResetResource(res); }
private void toolStripButton1_Click(object sender, EventArgs e) { //新建材质 NResourceLoc resLoc = new NResourceLoc("engine_data", "material/standard.hlsl"); NMtlStatic mtl = new NMtlStatic(resLoc.ToString()); mtl.DefaultCreate(resLoc); m_Material = mtl; MaterialProperty mtlProp = new MaterialProperty(m_Material); mtlProp.ApplyChange(); this.propertyGridMtl.SelectedObject = mtlProp; LoadSphere(); }
public override void PostCreateActor(NexusEngine.NActor actor) { base.PostCreateActor(actor); //创建光源部件 actor.CreateComponent("DirectionalLightComponent", "ndirectional_light_component"); //创建显示用部件 NResourceLoc res = new NResourceLoc("engine_data", "/editor_res/light.nmdl"); NActorComponent comp = actor.CreateComponent("LightSignBoard", "nstatic_editor_mesh_component"); NStaticMeshComponent meshComp = comp as NStaticMeshComponent; meshComp.ResetResource(res); }
private void RefreshFileList() { NResourceLoc curFolder = NLevelEditorEngine.Instance.CurrentFolder; if (curFolder.IsValid()) { NEFileListBuilder lb = new NEFileListBuilder(m_backEndList, this.imageListForList, this.imageListForListSmall, curFolder.PackageName, curFolder.FileName); lb.SetFilter(m_filter); lb.BuildList(); SearchFliterResourceList(); } }
public void OnLoadRecentFile(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; NResourceLoc loc = new NResourceLoc(item.Text); if (loc.IsValid()) { using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this)) { NLevelEditorEngine.Instance.LoadMainLevel(loc); this.toolStripStatusLableNote.Text = "Level Load from " + loc.ToString(); this.RefreshViewports(); } } }
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); } } } }
public void ShowResource(NResourceLoc resLoc) { switch (resLoc.FileExtension) { case "spt": this.LoadSpeedTree(resLoc); break; case "nmdl": this.LoadStaticMesh(resLoc); break; case "nam": break; } }