void btnTrnAddLayer_Click(object sender, EventArgs e) { if (m_brush.target == ETrnBurshTarget.Alphamap) { EditorMain.TerrainSplattingLayerForm dlg = new EditorMain.TerrainSplattingLayerForm(); dlg.LayerApplied += new EventHandler(layerDialog_Add); dlg.Show(this); } else if (m_brush.target == ETrnBurshTarget.Decomap) { NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd; if (trnEd.Empty()) { NexusEditor.Program.ShowError("当前地形编辑器没有绑定对象."); return; } using (CreateDecoLayerDialog dlg = new CreateDecoLayerDialog()) { dlg.Text = "加载材质 ..."; if (dlg.ShowDialog(this) == DialogResult.OK) { NTerrainDecoLayer layer = trnEd.GetTerrainBinded().GetDeco().AddLayer(dlg.LayerType, dlg.GridSize); if (layer != null) { layer.Name = dlg.LayerName; this.listViewTrnTarget.Items.Add(layer.Name, "NoTexture").Tag = layer; } } } } }
void layerDialog_Update(object sender, EventArgs e) { NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd; if (trnEd.Empty()) { NexusEditor.Program.ShowError("当前地形编辑器没有绑定对象."); return; } EditorMain.TerrainSplattingLayerForm dlg = sender as EditorMain.TerrainSplattingLayerForm; EditorMain.NETerrainTextureLayerProp ld = dlg.Data; if (!ld.TextureRes.IsValid()) { NexusEditor.Program.ShowError("更新图层失败:图层贴图路径为空."); return; } try { NTerrainMtlSetup mtl = trnEd.GetMaterial(); mtl.SetLayerData(dlg.LayerIndex, ld.data); this.BuildTargetList(); } catch (System.Exception ex) { NexusEditor.Program.ShowException(ex, "地形材质图层更新失败!"); } }
/// <summary> /// 双击List,显示Height Map, Alpha Map, Deco Layer,Navigation Map属性, 可编辑它们 /// </summary> private void listViewTrnTarget_DoubleClick(object sender, EventArgs e) { UpdateBrush(); switch (m_brush.target) { case ETrnBurshTarget.Heightmap: MessageBox.Show("TODO : Show Heightmap"); break; case ETrnBurshTarget.Alphamap: { EditorMain.TerrainSplattingLayerForm dlg = new EditorMain.TerrainSplattingLayerForm(); dlg.LayerApplied += new EventHandler(layerDialog_Update); dlg.Show(this); dlg.BindLayer(m_brush.targetIndex); } break; case ETrnBurshTarget.Decomap: NTerrainDecoLayer layer = this.listViewTrnTarget.SelectedItems[0].Tag as NTerrainDecoLayer; if (layer == null) { break; } TerrainDecoLayerProperty tdp = new TerrainDecoLayerProperty(); tdp.PropertyView.SelectedObject = layer; tdp.Show(this); this.listViewTrnTarget.SelectedItems[0].Text = layer.Name; break; case ETrnBurshTarget.NavigationMap: case ETrnBurshTarget.WalkableMap: // 显示导航图属性对话框 NavigationMapDlg navDesc = new NavigationMapDlg(); navDesc.Show(); break; } }