Esempio n. 1
0
        /// <summary>
        /// Noise Generate按钮事件响应
        /// </summary>
        /// <remarks>
        /// 根据所选择的Target-Target Index调用引擎接口,来产生随机Noise
        /// </remarks>
        private void buttonGenNoise_Click(object sender, EventArgs e)
        {
            NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;

            if (trnEd.Empty())
            {
                NexusEditor.Program.ShowError("Terrain Actor NOT Bind.");
                return;
            }

            switch (m_noiseGen.Target)
            {
            case ETrnBurshTarget.Heightmap:
                trnEd.GenerateNoise(m_noiseGen.AreaRect, m_noiseGen.NumOctaves,
                                    m_noiseGen.Amplitude, m_noiseGen.Frequency);
                break;

            case ETrnBurshTarget.Alphamap:
            {
                NTerrainMtlSetup mtl = trnEd.GetMaterial();
                mtl.GenerateNoise((int)m_noiseGen.TargetIndex,
                                  m_noiseGen.AreaRect, m_noiseGen.NumOctaves,
                                  m_noiseGen.Amplitude, m_noiseGen.Frequency);
            }
            break;

            case ETrnBurshTarget.Decomap:
                break;
            }
        }
Esempio n. 2
0
 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;
                 }
             }
         }
     }
 }
Esempio n. 3
0
        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, "地形材质图层更新失败!");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Heightmap Import按钮事件
        /// </summary>
        private void btnImportHmap_Click(object sender, EventArgs e)
        {
            NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;

            if (trnEd.Empty())
            {
                NexusEditor.Program.ShowError("Terrain Actor NOT Bind.");
                return;
            }

            try
            {
                string fileName = this.textBoxHMapFile.Text;
                if (fileName.Length > 0)
                {
                    trnEd.ImportHeightmap(fileName);
                }
                else
                {
                    NexusEditor.Program.ShowError("Please input heightmap file name.");
                }
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Import Hiehgtmap FAILED!");
            }
        }
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;

            if (trnEd.Empty())
            {
                NexusEditor.Program.ShowError("Terrain Actor NOT Bind.");
                return;
            }

            if (!m_prop.DiffuseTextureRes.IsValid())
            {
                NexusEditor.Program.ShowError("Please input texture location for terrain basic material.");
                return;
            }

            try
            {
                trnEd.CreateMaterialBasic(m_prop.DiffuseTextureRes);
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Create Basic Terrain Material FAILED!");
            }
        }
Esempio n. 6
0
        void btnTrnMtl_Click(object sender, EventArgs e)
        {
            NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;

            if (trnEd.Empty())
            {
                NexusEditor.Program.ShowError("当前地形编辑器没有绑定对象.");
                return;
            }

            EditorMain.NewTerrainMaterial dlg = new NexusEditor.EditorMain.NewTerrainMaterial(
                NLevelEditorEngine.Instance.TerrainEd.GetTerrainBinded());
            dlg.Show(this);
        }
        /// <summary>
        /// [Material]创建Texture Splatting材质按钮事件
        /// </summary>
        private void btnCreateSplat_Click(object sender, EventArgs e)
        {
            NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;

            if (trnEd.Empty())
            {
                NexusEditor.Program.ShowError("Terrain Actor NOT Bind.");
                return;
            }

            int alphaW = int.Parse(this.textBoxAlphaW.Text);
            int alphaH = int.Parse(this.textBoxAlphaH.Text);

            trnEd.CreateTextureSplatting(alphaW, alphaH);
        }
Esempio n. 8
0
        void btnTrnLayerDown_Click(object sender, EventArgs e)
        {
            if (m_brush.target == ETrnBurshTarget.Alphamap)
            {
                NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;
                if (trnEd.Empty())
                {
                    NexusEditor.Program.ShowError("当前地形编辑器没有绑定对象.");
                    return;
                }

                NTerrainMtlSetup mtl = trnEd.GetMaterial();
                mtl.ShiftDownLayer(m_brush.targetIndex);
                this.BuildTargetList();
            }
        }
        public void BindLayer(int layer)
        {
            m_layerIndex = layer;

            NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;

            if (trnEd.Empty())
            {
                NexusEditor.Program.ShowError("当前地形编辑器没有绑定对象.");
                this.Close();
                return;
            }

            NTerrainMtlSetup mtl = trnEd.GetMaterial();

            m_layer.data = mtl.GetLayerData(layer);

            this.propertyGridLayer.SelectedObject = m_layer;
        }
Esempio n. 10
0
        void btnTrnRemoveLayer_Click(object sender, EventArgs e)
        {
            NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;

            if (trnEd.Empty())
            {
                NexusEditor.Program.ShowError("当前地形编辑器没有绑定对象.");
                return;
            }

            if (m_brush.target == ETrnBurshTarget.Alphamap)
            {
                NTerrainMtlSetup mtl = trnEd.GetMaterial();
                mtl.RemoveLayer(m_brush.targetIndex);
                this.BuildTargetList();
            }
            else if (m_brush.target == ETrnBurshTarget.Decomap)
            {
                NTerrainDecoSetup deco = trnEd.GetTerrainBinded().GetDeco();
                deco.DeleteLayer(m_brush.targetIndex);
                this.BuildTargetList();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 取得当前地形的图层,更新列表
        /// </summary>
        private void BuildTargetList()
        {
            this.listViewTrnTarget.Items.Clear();

            //--
            this.listViewTrnTarget.SuspendLayout();
            this.listViewTrnTarget.BeginUpdate();

            //-- todo: clear ImageList
            NTerrainEditor trnEd = NLevelEditorEngine.Instance.TerrainEd;

            System.Drawing.Size imgSize = this.imageListTrnTarget.ImageSize;
            //-- build target list
            switch (m_brush.target)
            {
            case ETrnBurshTarget.Heightmap:
                this.listViewTrnTarget.Items.Add("高度图", "Heightmap");
                this.btnTrnLayerDown.Enabled   = false;
                this.btnTrnLayerUp.Enabled     = false;
                this.btnTrnAddLayer.Enabled    = false;
                this.btnTrnRemoveLayer.Enabled = false;
                break;

            case ETrnBurshTarget.Alphamap:
            {
                this.btnTrnLayerDown.Enabled   = true;
                this.btnTrnLayerUp.Enabled     = true;
                this.btnTrnAddLayer.Enabled    = true;
                this.btnTrnRemoveLayer.Enabled = true;

                if (!trnEd.Empty())
                {
                    NTerrainMtlSetup mtl = trnEd.GetMaterial();

                    for (int i = 0; i < mtl.GetNumLayers(); i++)
                    {
                        LayerData ld  = mtl.GetLayerData(i);
                        string    txt = string.Format("[{0}]{1}",
                                                      i, ld.DiffuseTexture.FileName);

                        if (ld.DiffuseTexture.IsValid())
                        {
                            IntPtr hbmp = NLevelEditorEngine.Instance.CreateThumbnail(
                                ld.DiffuseTexture, imgSize.Width, imgSize.Height);
                            String thumbName = ld.DiffuseTexture.ToString();
                            this.imageListTrnTarget.Images.Add(thumbName, Image.FromHbitmap(hbmp));

                            this.listViewTrnTarget.Items.Add(txt, thumbName);
                        }
                        else
                        {
                            this.listViewTrnTarget.Items.Add(txt, "NoTexture");
                        }
                    }    // end of for()
                }        // end of if()
            }
            break;

            case ETrnBurshTarget.Decomap:
                this.btnTrnLayerDown.Enabled   = false;
                this.btnTrnLayerUp.Enabled     = false;
                this.btnTrnAddLayer.Enabled    = true;
                this.btnTrnRemoveLayer.Enabled = true;
                if (!trnEd.Empty())
                {
                    List <NTerrainDecoLayer> layers = trnEd.GetTerrainBinded().GetDeco().DecoLayers;
                    for (int i = 0; i < layers.Count; ++i)
                    {
                        this.listViewTrnTarget.Items.Add(layers[i].Name, "NoTexture").Tag = layers[i];
                    }
                }

                break;

            case ETrnBurshTarget.NavigationMap:
            case ETrnBurshTarget.WalkableMap:
                ListViewItem li = new ListViewItem(NexusEngineExtension.Utility.GetEnumItemDescription(m_brush.target), "Heightmap");
                li.Tag = m_brush.target;
                this.listViewTrnTarget.Items.Add(li);
                break;
            }

            this.listViewTrnTarget.EndUpdate();
            this.listViewTrnTarget.ResumeLayout();
        }