From 25efdb4a062183224644b4677bb0befe38f04bbe Mon Sep 17 00:00:00 2001 From: thecelloman Date: Thu, 21 Mar 2013 17:45:23 -0400 Subject: [PATCH] Adding a basic rule-based terrain painting implementation. http://www.garagegames.com/community/resources/view/17145 --- .../source/gui/worldEditor/terrainEditor.cpp | 71 ++++ Engine/source/gui/worldEditor/terrainEditor.h | 2 + .../gui/ProceduralTerrainPainterGui.gui | 326 ++++++++++++++++++ .../gui/TerrainPainterWindow.ed.gui | 20 ++ .../Empty/game/tools/worldEditor/main.cs | 1 + .../scripts/editors/terrainEditor.ed.cs | 1 + .../gui/ProceduralTerrainPainterGui.gui | 326 ++++++++++++++++++ .../gui/TerrainPainterWindow.ed.gui | 20 ++ Templates/Full/game/tools/worldEditor/main.cs | 1 + .../scripts/editors/terrainEditor.ed.cs | 1 + 10 files changed, 769 insertions(+) create mode 100644 Templates/Empty/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui create mode 100644 Templates/Full/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui diff --git a/Engine/source/gui/worldEditor/terrainEditor.cpp b/Engine/source/gui/worldEditor/terrainEditor.cpp index 1b2239911..1c663254a 100644 --- a/Engine/source/gui/worldEditor/terrainEditor.cpp +++ b/Engine/source/gui/worldEditor/terrainEditor.cpp @@ -2933,3 +2933,74 @@ ConsoleMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, 3, 3, 0) object->mSlopeMaxAngle = angle; return angle; } + +//------------------------------------------------------------------------------ +void TerrainEditor::autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinSlope, F32 mMaxSlope ) +{ + if (!mActiveTerrain) + return; + + S32 mat = getPaintMaterialIndex(); + if (mat == -1) + return; + + mUndoSel = new Selection; + + U32 terrBlocks = mActiveTerrain->getBlockSize(); + for (U32 y = 0; y < terrBlocks; y++) + { + for (U32 x = 0; x < terrBlocks; x++) + { + // get info + GridPoint gp; + gp.terrainBlock = mActiveTerrain; + gp.gridPos.set(x, y); + + GridInfo gi; + getGridInfo(gp, gi); + + if (gi.mMaterial == mat) + continue; + + Point3F wp; + gridToWorld(gp, wp); + + if (!(wp.z >= mMinHeight && wp.z <= mMaxHeight)) + continue; + + // transform wp to object space + Point3F op; + mActiveTerrain->getWorldTransform().mulP(wp, &op); + + Point3F norm; + mActiveTerrain->getNormal(Point2F(op.x, op.y), &norm, true); + + if (mMinSlope > 0) + if (norm.z > mSin(mDegToRad(90.0f - mMinSlope))) + continue; + + if (mMaxSlope < 90) + if (norm.z < mSin(mDegToRad(90.0f - mMaxSlope))) + continue; + + gi.mMaterialChanged = true; + mUndoSel->add(gi); + gi.mMaterial = mat; + setGridInfo(gi); + } + } + + if(mUndoSel->size()) + submitUndo( mUndoSel ); + else + delete mUndoSel; + + mUndoSel = 0; + + scheduleMaterialUpdate(); +} + +ConsoleMethod( TerrainEditor, autoMaterialLayer, void, 6, 6, "(float minHeight, float maxHeight, float minSlope, float maxSlope)") +{ + object->autoMaterialLayer( dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4]), dAtof(argv[5]) ); +} diff --git a/Engine/source/gui/worldEditor/terrainEditor.h b/Engine/source/gui/worldEditor/terrainEditor.h index 03bfe3058..1477b4e02 100644 --- a/Engine/source/gui/worldEditor/terrainEditor.h +++ b/Engine/source/gui/worldEditor/terrainEditor.h @@ -230,6 +230,8 @@ class TerrainEditor : public EditTSCtrl void submitMaterialUndo( String actionName ); void onMaterialUndo( TerrainBlock *terr ); + void autoMaterialLayer(F32, F32, F32, F32); + private: typedef EditTSCtrl Parent; diff --git a/Templates/Empty/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui b/Templates/Empty/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui new file mode 100644 index 000000000..d2eccdbb7 --- /dev/null +++ b/Templates/Empty/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui @@ -0,0 +1,326 @@ +//--- OBJECT WRITE BEGIN --- +%guiContent = new GuiControl(ProceduralTerrainPainterGui) { + canSaveDynamicFields = "0"; + isContainer = "1"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "0 0"; + Extent = "1024 768"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + + new GuiWindowCtrl(ProceduralTerrainPainterDescription) { + canSaveDynamicFields = "0"; + isContainer = "1"; + Profile = "ToolsGuiWindowProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "285 83"; + Extent = "175 209"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + resizeWidth = "0"; + resizeHeight = "0"; + canMove = "1"; + canClose = "1"; + canMinimize = "0"; + canMaximize = "0"; + minSize = "50 50"; + EdgeSnap = "1"; + canCollapse = "0"; + CollapseGroup = "-1"; + CollapseGroupNum = "-1"; + closeCommand = "Canvas.popDialog(ProceduralTerrainPainterGui);"; + text = "Generate layer mask"; + + new GuiButtonCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiButtonProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "19 164"; + Extent = "140 30"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "generateProceduralTerrainMask();"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + text = "Generate"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "15 37"; + Extent = "33 13"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "HEIGHT"; + maxLength = "1024"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "59 37"; + Extent = "23 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "Min."; + maxLength = "1024"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "59 62"; + Extent = "23 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "Max."; + maxLength = "1024"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "97 35"; + Extent = "66 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Variable = "$TPPHeightMin"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + maxLength = "1024"; + historySize = "0"; + password = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + passwordMask = "*"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "97 60"; + Extent = "66 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Variable = "$TPPHeightMax"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + maxLength = "1024"; + historySize = "0"; + password = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + passwordMask = "*"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "15 101"; + Extent = "33 13"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "SLOPE"; + maxLength = "1024"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "59 101"; + Extent = "23 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "Min."; + maxLength = "1024"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "59 126"; + Extent = "23 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "Max."; + maxLength = "1024"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "97 99"; + Extent = "66 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Variable = "$TPPSlopeMin"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + maxLength = "1024"; + historySize = "0"; + password = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + passwordMask = "*"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "97 124"; + Extent = "66 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Variable = "$TPPSlopeMax"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + maxLength = "1024"; + historySize = "0"; + password = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + passwordMask = "*"; + }; + }; +}; +//--- OBJECT WRITE END --- + +$TPPHeightMin = -10000; +$TPPHeightMax = 10000; +$TPPSlopeMin = 0; +$TPPSlopeMax = 90; + +function autoLayers() +{ + Canvas.pushDialog(ProceduralTerrainPainterGui); +} + +function generateProceduralTerrainMask() +{ + Canvas.popDialog(ProceduralTerrainPainterGui); + ETerrainEditor.autoMaterialLayer($TPPHeightMin, $TPPHeightMax, $TPPSlopeMin, $TPPSlopeMax); +} diff --git a/Templates/Empty/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui b/Templates/Empty/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui index 7db06a9e1..b9abec3c3 100644 --- a/Templates/Empty/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui +++ b/Templates/Empty/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui @@ -224,6 +224,26 @@ text = "None"; maxLength = "1024"; }; + new GuiButtonCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiButtonProfile"; + HorizSizing = "left"; + VertSizing = "bottom"; + Position = "100 229"; + Extent = "50 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "autoLayers();"; + tooltipprofile = "ToolsGuiToolTipProfile"; + tooltip = "Generate a layer mask for this material."; + hovertime = "1000"; + text = "AutoPaint"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + }; }; }; //--- OBJECT WRITE END --- diff --git a/Templates/Empty/game/tools/worldEditor/main.cs b/Templates/Empty/game/tools/worldEditor/main.cs index 0f8228b82..d028f8923 100644 --- a/Templates/Empty/game/tools/worldEditor/main.cs +++ b/Templates/Empty/game/tools/worldEditor/main.cs @@ -43,6 +43,7 @@ function initializeWorldEditor() exec("./gui/TimeAdjustGui.ed.gui"); exec("./gui/AddFMODProjectDlg.ed.gui"); exec("./gui/SelectObjectsWindow.ed.gui"); + exec("./gui/ProceduralTerrainPainterGui.gui" ); // Load Scripts. exec("./scripts/menus.ed.cs"); diff --git a/Templates/Empty/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs b/Templates/Empty/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs index aa43f67fa..63d185541 100644 --- a/Templates/Empty/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs +++ b/Templates/Empty/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs @@ -64,6 +64,7 @@ function TerrainEditor::setPaintMaterial( %this, %matIndex, %terrainMat ) ETerrainMaterialSelected.bitmap = %terrainMat.diffuseMap; ETerrainMaterialSelectedEdit.Visible = isObject(%terrainMat); TerrainTextureText.text = %terrainMat.getInternalName(); + ProceduralTerrainPainterDescription.text = "Generate "@ %terrainMat.getInternalName() @" layer"; } function TerrainEditor::setup( %this ) diff --git a/Templates/Full/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui b/Templates/Full/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui new file mode 100644 index 000000000..d2eccdbb7 --- /dev/null +++ b/Templates/Full/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui @@ -0,0 +1,326 @@ +//--- OBJECT WRITE BEGIN --- +%guiContent = new GuiControl(ProceduralTerrainPainterGui) { + canSaveDynamicFields = "0"; + isContainer = "1"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "0 0"; + Extent = "1024 768"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + + new GuiWindowCtrl(ProceduralTerrainPainterDescription) { + canSaveDynamicFields = "0"; + isContainer = "1"; + Profile = "ToolsGuiWindowProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "285 83"; + Extent = "175 209"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + resizeWidth = "0"; + resizeHeight = "0"; + canMove = "1"; + canClose = "1"; + canMinimize = "0"; + canMaximize = "0"; + minSize = "50 50"; + EdgeSnap = "1"; + canCollapse = "0"; + CollapseGroup = "-1"; + CollapseGroupNum = "-1"; + closeCommand = "Canvas.popDialog(ProceduralTerrainPainterGui);"; + text = "Generate layer mask"; + + new GuiButtonCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiButtonProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "19 164"; + Extent = "140 30"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "generateProceduralTerrainMask();"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + text = "Generate"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "15 37"; + Extent = "33 13"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "HEIGHT"; + maxLength = "1024"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "59 37"; + Extent = "23 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "Min."; + maxLength = "1024"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "59 62"; + Extent = "23 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "Max."; + maxLength = "1024"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "97 35"; + Extent = "66 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Variable = "$TPPHeightMin"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + maxLength = "1024"; + historySize = "0"; + password = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + passwordMask = "*"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "97 60"; + Extent = "66 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Variable = "$TPPHeightMax"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + maxLength = "1024"; + historySize = "0"; + password = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + passwordMask = "*"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "15 101"; + Extent = "33 13"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "SLOPE"; + maxLength = "1024"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "59 101"; + Extent = "23 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "Min."; + maxLength = "1024"; + }; + new GuiTextCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiTextProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "59 126"; + Extent = "23 14"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "Max."; + maxLength = "1024"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "97 99"; + Extent = "66 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Variable = "$TPPSlopeMin"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + maxLength = "1024"; + historySize = "0"; + password = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + passwordMask = "*"; + }; + new GuiTextEditCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + Position = "97 124"; + Extent = "66 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Variable = "$TPPSlopeMax"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + maxLength = "1024"; + historySize = "0"; + password = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + passwordMask = "*"; + }; + }; +}; +//--- OBJECT WRITE END --- + +$TPPHeightMin = -10000; +$TPPHeightMax = 10000; +$TPPSlopeMin = 0; +$TPPSlopeMax = 90; + +function autoLayers() +{ + Canvas.pushDialog(ProceduralTerrainPainterGui); +} + +function generateProceduralTerrainMask() +{ + Canvas.popDialog(ProceduralTerrainPainterGui); + ETerrainEditor.autoMaterialLayer($TPPHeightMin, $TPPHeightMax, $TPPSlopeMin, $TPPSlopeMax); +} diff --git a/Templates/Full/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui b/Templates/Full/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui index 7db06a9e1..b9abec3c3 100644 --- a/Templates/Full/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui +++ b/Templates/Full/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui @@ -224,6 +224,26 @@ text = "None"; maxLength = "1024"; }; + new GuiButtonCtrl() { + canSaveDynamicFields = "0"; + isContainer = "0"; + Profile = "GuiButtonProfile"; + HorizSizing = "left"; + VertSizing = "bottom"; + Position = "100 229"; + Extent = "50 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "autoLayers();"; + tooltipprofile = "ToolsGuiToolTipProfile"; + tooltip = "Generate a layer mask for this material."; + hovertime = "1000"; + text = "AutoPaint"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + }; }; }; //--- OBJECT WRITE END --- diff --git a/Templates/Full/game/tools/worldEditor/main.cs b/Templates/Full/game/tools/worldEditor/main.cs index 0f8228b82..d028f8923 100644 --- a/Templates/Full/game/tools/worldEditor/main.cs +++ b/Templates/Full/game/tools/worldEditor/main.cs @@ -43,6 +43,7 @@ function initializeWorldEditor() exec("./gui/TimeAdjustGui.ed.gui"); exec("./gui/AddFMODProjectDlg.ed.gui"); exec("./gui/SelectObjectsWindow.ed.gui"); + exec("./gui/ProceduralTerrainPainterGui.gui" ); // Load Scripts. exec("./scripts/menus.ed.cs"); diff --git a/Templates/Full/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs index aa43f67fa..63d185541 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs @@ -64,6 +64,7 @@ function TerrainEditor::setPaintMaterial( %this, %matIndex, %terrainMat ) ETerrainMaterialSelected.bitmap = %terrainMat.diffuseMap; ETerrainMaterialSelectedEdit.Visible = isObject(%terrainMat); TerrainTextureText.text = %terrainMat.getInternalName(); + ProceduralTerrainPainterDescription.text = "Generate "@ %terrainMat.getInternalName() @" layer"; } function TerrainEditor::setup( %this )