public override bool OnMouseDown(System.Windows.Forms.MouseEventArgs e, CSharpFramework.Contexts.KeyModifier eKeyMod, int iOldX, int iOldY)
        {
            if ((IsEditingKeyPressed(eKeyMod) && (EditorSettingsBase.CameraStyle_e.MayaStyle != EditorManager.Settings.CameraStyle)) || eKeyMod == KeyModifier.Ctrl)
            {
                CurrentMode = TerrainEditor.HeightmapEditMode;

                // apply variants locally to this context
                if (CurrentMode == HeightmapEditMode_e.Elevate && (e.Button == MouseButtons.Right || (EditorManager.Tablet != null && EditorManager.Tablet.IsEraserPressed)))
                {
                    CurrentMode = HeightmapEditMode_e.Subtract;
                }
                else if (CurrentMode == HeightmapEditMode_e.AddHoles && (e.Button == MouseButtons.Right || (EditorManager.Tablet != null && EditorManager.Tablet.IsEraserPressed)))
                {
                    CurrentMode = HeightmapEditMode_e.RemoveHoles;
                }

                // in flatten mode with RMB we pick the height first
                if (CurrentMode == HeightmapEditMode_e.Flatten && e.Button == MouseButtons.Right)
                {
                    Vector3F cursorCenter = TerrainEditor.CurrentTerrain.EngineTerrain.GetCurrentCursorCenter();
                    float    fHeight      = TerrainEditor.CurrentTerrain.TerrainHeightAtPosition(cursorCenter);
                    HeightmapCursorProperties cursorProp = TerrainEditor.Cursor3DProperties as HeightmapCursorProperties;
                    if (cursorProp != null)
                    {
                        cursorProp.AbsoluteHeight = fHeight;
                    }
                }
            }
            return(base.OnMouseDown(e, eKeyMod, iOldX, iOldY));
        }
        void EditorManager_CustomSceneSerialization(object sender, CustomSceneSerializationArgs e)
        {
            if (e.CustomSceneObjects.IsSaving)
              {
            if (TerrainEditor.CurrentTerrain != null) // only save data when a terrain is used
            {
              // get data from panel
              TerrainPanelSettings brushes = new TerrainPanelSettings();
              brushes.HeightmapCursor_Elevate = this._heightmapCursor_Elevate;
              brushes.HeightmapCursor_Flatten = this._heightmapCursor_Flatten;
              brushes.HeightmapCursor_Smooth = this._heightmapCursor_Smooth;
              brushes.HeightmapCursor_Holes = this._heightmapCursor_Holes;
              brushes.DetailTextureCursor = this._detailTextureCursor;
              brushes.VegetationCursor = this._decorationCursor;

              e.CustomSceneObjects.AddObject("TerrainEditorPlugin.EditorPlugin", brushes);
            }
              }
              else
              {
            TerrainPanelSettings brushes =
              (TerrainPanelSettings)e.CustomSceneObjects.FindObject("TerrainEditorPlugin.EditorPlugin", typeof(TerrainPanelSettings));
            if (brushes != null)
            {
              if (brushes.HeightmapCursor_Elevate != null) this._heightmapCursor_Elevate = brushes.HeightmapCursor_Elevate;
              if (brushes.HeightmapCursor_Flatten != null) this._heightmapCursor_Flatten = brushes.HeightmapCursor_Flatten;
              if (brushes.HeightmapCursor_Smooth != null) this._heightmapCursor_Smooth = brushes.HeightmapCursor_Smooth;
              if (brushes.HeightmapCursor_Holes != null) this._heightmapCursor_Holes = brushes.HeightmapCursor_Holes;
              if (brushes.DetailTextureCursor != null) this._detailTextureCursor = brushes.DetailTextureCursor;
              if (brushes.VegetationCursor != null) this._decorationCursor = brushes.VegetationCursor;
            }
              }
        }
 public void SetHeightmapEditMode(HeightmapEditMode_e mode)
 {
     TerrainEditor.HeightmapEditMode = mode;
       switch (mode)
       {
     case HeightmapEditMode_e.Subtract:
     case HeightmapEditMode_e.Elevate: _heightmapCursor = _heightmapCursor_Elevate; break;
     case HeightmapEditMode_e.Flatten: _heightmapCursor = _heightmapCursor_Flatten; break;
     case HeightmapEditMode_e.Smooth: _heightmapCursor = _heightmapCursor_Smooth; break;
     case HeightmapEditMode_e.RemoveHoles:
     case HeightmapEditMode_e.AddHoles: _heightmapCursor = _heightmapCursor_Holes; break;
       }
       TerrainEditor.Cursor3DProperties = _heightmapCursor;
       EditorManager.ActiveView.CurrentContext = g_heightmapContext;
       this.tabControl.SelectedTab = tabPage_Heightmap;
       UpdateToolbar();
 }
 protected TerrainPanelSettings(SerializationInfo info, StreamingContext context)
 {
     HeightmapCursor_Elevate = (HeightmapCursorProperties)info.GetValue("HeightmapCursor_Elevate", typeof(HeightmapCursorProperties));
     HeightmapCursor_Flatten = (HeightmapCursorProperties)info.GetValue("HeightmapCursor_Flatten", typeof(HeightmapCursorProperties));
     HeightmapCursor_Smooth = (HeightmapCursorProperties)info.GetValue("HeightmapCursor_Smooth", typeof(HeightmapCursorProperties));
     HeightmapCursor_Holes = (HeightmapCursorProperties)info.GetValue("HeightmapCursor_Holes", typeof(HeightmapCursorProperties));
     DetailTextureCursor = (Cursor3DProperties)info.GetValue("DetailTextureCursor", typeof(Cursor3DProperties));
     VegetationCursor = (Cursor3DProperties)info.GetValue("VegetationCursor", typeof(Cursor3DProperties));
     if (SerializationHelper.HasElement(info, "BrushName"))
     {
       string file = info.GetString("BrushName");
       TerrainEditor.SetBrushByName(file);
     }
 }
        public TerrainEditorPanel(DockingContainer container)
            : base(container)
        {
            // actually this has to be done here
              this.brushListCtrl1 = new TerrainEditorPlugin.Controls.BrushListCtrl();
              this.brushListCtrl1.Dock = System.Windows.Forms.DockStyle.Top;
              this.brushListCtrl1.Location = new System.Drawing.Point(0, 254);
              this.brushListCtrl1.Name = "brushListCtrl1";
              this.brushListCtrl1.Size = new System.Drawing.Size(444, 400);
              this.brushListCtrl1.TabIndex = 1;
              //this.Controls.Add(this.brushListCtrl1);

              InitializeComponent();

              UpdatePanelStatus();
              UpdateHeightmapPanel();

              this.listView_DetailTextures.SmallImageList = _detailTexturesImageList.ImageList;
              _heightmapCursor = _heightmapCursor_Elevate;

              // add listeners
              EditorManager.SceneEvent += new SceneEventHandler(EditorManager_SceneEvent);
              EditorManager.SceneChanged += new SceneChangedEventHandler(EditorManager_SceneChanged);
              IScene.LayerChanged += new LayerChangedEventHandler(IScene_LayerChanged);
              TerrainEditor.OnTerrainChanged += new EventHandler(TerrainEditor_OnTerrainChanged);
              TerrainEditor.OnHeightmapEditModeChanged += new EventHandler(TerrainEditor_OnHeightmapEditModeChanged);
              TerrainEditor.OnCurrentDecorationModelChanged += new EventHandler(TerrainEditor_OnCurrentDecorationModelChanged);
              TerrainEditor.OnDecorationModelListChanged += new EventHandler(TerrainEditor_OnDecorationModelListChanged);
              TerrainEditor.OnDecorationDirtyRegionChanged += new EventHandler(TerrainEditor_OnDecorationDirtyRegionChanged);
              TerrainEditor.OnCurrentDetailTextureChanged += new EventHandler(TerrainEditor_OnCurrentDetailTextureChanged);
              TerrainEditor.OnDetailTextureListChanged += new DetailTextureListChangedEventHandler(TerrainEditor_OnDetailTextureListChanged);
              TerrainEditor.OnTextureBakedViewChanged += new EventHandler(TerrainEditor_OnTextureBakedViewChanged);
              TerrainEditor.OnDirectionalLightingChanged += new EventHandler(TerrainEditor_OnDirectionalLightingChanged);
              TerrainEditor.OnMiniMapStatusChanged += new EventHandler(TerrainEditor_OnMiniMapStatusChanged);
              TerrainEditor.OnPreviewFullResolutionStatusChanged += new EventHandler(TerrainEditor_OnPreviewFullResolutionStatusChanged);
              TerrainEditor.OnHeightmapExportFilenameChanged += new EventHandler(TerrainEditor_OnHeightmapExportFilenameChanged);
              DetailTextureResource.OnDetailTextureResourcePropertyChanged += new DetailTextureResourcePropertyChangedEventHandler(DetailTextureResource_OnDetailTextureResourcePropertyChanged);
              DecorationModelResource.OnDecorationModelResourcePropertyChanged += new EventHandler(DecorationModelResource_OnDecorationModelResourcePropertyChanged);
              VisionViewBase.MouseContextChanged += new CSharpFramework.Contexts.ContextChangedEventHandler(VisionViewBase_MouseContextChanged);
              TextureAtlas.OnAtlasFileSaved += new EventHandler(TextureAtlas_OnAtlasFileSaved);
              ShapeComponent.OnUIUpdateBegin += new EventHandler(ShapeComponent_OnUIUpdateBegin);
              ShapeComponent.OnUIUpdateFinished += new EventHandler(ShapeComponent_OnUIUpdateFinished);
              EditorManager.CustomSceneSerialization += new CustomSceneSerializationEventHandler(EditorManager_CustomSceneSerialization);
              brushListCtrl1.Dock = DockStyle.Fill;
              brushListCtrl1.AutoSize = true;

              EditorManager.GUI.RecordableControls.Add("Terrain Editor: Toggle baked mode", toolStripButton_TextureBaked);

              this.splitContainer1.Panel2.Controls.Add(brushListCtrl1);
        }
 public TerrainPickHandler(TerrainShape terrain, HeightmapCursorProperties dest)
 {
     _terrain = terrain;
       _destHeight = dest;
 }
 public TerrainPickHandler(TerrainShape terrain, HeightmapCursorProperties dest)
 {
     _terrain    = terrain;
     _destHeight = dest;
 }