diff --git a/Engine/source/gfx/bitmap/gBitmap.cpp b/Engine/source/gfx/bitmap/gBitmap.cpp index d9a0d162c..b317107f2 100644 --- a/Engine/source/gfx/bitmap/gBitmap.cpp +++ b/Engine/source/gfx/bitmap/gBitmap.cpp @@ -319,7 +319,7 @@ void GBitmap::allocateBitmap(const U32 in_width, const U32 in_height, const bool U32 currWidth = in_width; U32 currHeight = in_height; - do + while (currWidth != 1 || currHeight != 1) { mMipLevelOffsets[mNumMipLevels] = mMipLevelOffsets[mNumMipLevels - 1] + (currWidth * currHeight * mBytesPerPixel); @@ -330,7 +330,7 @@ void GBitmap::allocateBitmap(const U32 in_width, const U32 in_height, const bool mNumMipLevels++; allocPixels += currWidth * currHeight * mBytesPerPixel; - } while (currWidth != 1 || currHeight != 1); + } U32 expectedMips = mFloor(mLog2(mMax(in_width, in_height))) + 1; AssertFatal(mNumMipLevels == expectedMips, "GBitmap::allocateBitmap: mipmap count wrong"); diff --git a/Engine/source/terrain/terrData.cpp b/Engine/source/terrain/terrData.cpp index 8be5b7990..90fd7c2f2 100644 --- a/Engine/source/terrain/terrData.cpp +++ b/Engine/source/terrain/terrData.cpp @@ -197,14 +197,6 @@ TerrainBlock::TerrainBlock() mLayerTexDirty( false ), mBaseTexSize( 1024 ), mBaseTexFormat( TerrainBlock::DDS ), - mDetailTexSize(0), - mDetailTexFormat(GFXFormat_COUNT), - mMacroTexSize(0), - mMacroTexFormat(GFXFormat_COUNT), - mNormalTexSize(0), - mNormalTexFormat(GFXFormat_COUNT), - mOrmTexSize(0), - mOrmTexFormat(GFXFormat_COUNT), mCell( NULL ), mBaseMaterial( NULL ), mDefaultMatInst( NULL ), @@ -355,142 +347,6 @@ bool TerrainBlock::_setLightMapSize( void *obj, const char *index, const char *d return false; } -bool TerrainBlock::_setDetailTexSize(void* obj, const char* index, const char* data) -{ - TerrainBlock* terrain = static_cast(obj); - - S32 size; - castConsoleTypeFromString(size, data); - - if (terrain->mDetailTexSize != size) - { - terrain->mDetailTexSize = size; - terrain->_updateMaterials(); - terrain->setMaskBits(MaterialMask); - } - - return false; -} - -bool TerrainBlock::_setDetailTexFormat(void* obj, const char* index, const char* data) -{ - TerrainBlock* terrain = static_cast(obj); - - GFXFormat format; - castConsoleTypeFromString(format, data); - - if (terrain->mDetailTexFormat != format) - { - terrain->mDetailTexFormat = format; - terrain->_updateMaterials(); - terrain->setMaskBits(MaterialMask); - } - - return false; -} - -bool TerrainBlock::_setMacroTexSize(void* obj, const char* index, const char* data) -{ - TerrainBlock* terrain = static_cast(obj); - - S32 size; - castConsoleTypeFromString(size, data); - - if (terrain->mMacroTexSize != size) - { - terrain->mMacroTexSize = size; - terrain->_updateMaterials(); - terrain->setMaskBits(MaterialMask); - } - - return false; -} - -bool TerrainBlock::_setMacroTexFormat(void* obj, const char* index, const char* data) -{ - TerrainBlock* terrain = static_cast(obj); - - GFXFormat format; - castConsoleTypeFromString(format, data); - - if (terrain->mMacroTexFormat != format) - { - terrain->mMacroTexFormat = format; - terrain->_updateMaterials(); - terrain->setMaskBits(MaterialMask); - } - - return false; -} - -bool TerrainBlock::_setNormalTexSize(void* obj, const char* index, const char* data) -{ - TerrainBlock* terrain = static_cast(obj); - - S32 size; - castConsoleTypeFromString(size, data); - - if (terrain->mNormalTexSize != size) - { - terrain->mNormalTexSize = size; - terrain->_updateMaterials(); - terrain->setMaskBits(MaterialMask); - } - - return false; -} - -bool TerrainBlock::_setNormalTexFormat(void* obj, const char* index, const char* data) -{ - TerrainBlock* terrain = static_cast(obj); - - GFXFormat format; - castConsoleTypeFromString(format, data); - - if (terrain->mNormalTexFormat != format) - { - terrain->mNormalTexFormat = format; - terrain->_updateMaterials(); - terrain->setMaskBits(MaterialMask); - } - - return false; -} - -bool TerrainBlock::_setOrmTexSize(void* obj, const char* index, const char* data) -{ - TerrainBlock* terrain = static_cast(obj); - - S32 size; - castConsoleTypeFromString(size, data); - - if (terrain->mOrmTexSize != size) - { - terrain->mOrmTexSize = size; - terrain->_updateMaterials(); - terrain->setMaskBits(MaterialMask); - } - - return false; -} - -bool TerrainBlock::_setOrmTexFormat(void* obj, const char* index, const char* data) -{ - TerrainBlock* terrain = static_cast(obj); - - GFXFormat format; - castConsoleTypeFromString(format, data); - - if (terrain->mOrmTexFormat != format) - { - terrain->mOrmTexFormat = format; - terrain->_updateMaterials(); - terrain->setMaskBits(MaterialMask); - } - - return false; -} - bool TerrainBlock::setFile( const FileName &terrFileName ) { if ( mTerrainAsset && mTerrainAsset->getTerrainFilePath() == terrFileName ) @@ -1440,38 +1296,6 @@ void TerrainBlock::initPersistFields() &TerrainBlock::_setLightMapSize, &defaultProtectedGetFn, "Light map dimensions in pixels." ); - addProtectedField("detailTexSize", TypeS32, Offset(mDetailTexSize, TerrainBlock), - &TerrainBlock::_setDetailTexSize, &defaultProtectedGetFn, - ""); - - addProtectedField("detailTexFormat", TypeGFXFormat, Offset(mDetailTexFormat, TerrainBlock), - &TerrainBlock::_setDetailTexFormat, &defaultProtectedGetFn, - ""); - - addProtectedField("macroTexSize", TypeS32, Offset(mMacroTexSize, TerrainBlock), - &TerrainBlock::_setMacroTexSize, &defaultProtectedGetFn, - ""); - - addProtectedField("macroTexFormat", TypeGFXFormat, Offset(mMacroTexFormat, TerrainBlock), - &TerrainBlock::_setMacroTexFormat, &defaultProtectedGetFn, - ""); - - addProtectedField("normalTexSize", TypeS32, Offset(mNormalTexSize, TerrainBlock), - &TerrainBlock::_setNormalTexSize, &defaultProtectedGetFn, - ""); - - addProtectedField("normalTexFormat", TypeGFXFormat, Offset(mNormalTexFormat, TerrainBlock), - &TerrainBlock::_setNormalTexFormat, &defaultProtectedGetFn, - ""); - - addProtectedField("ormTexSize", TypeS32, Offset(mOrmTexSize, TerrainBlock), - &TerrainBlock::_setOrmTexSize, &defaultProtectedGetFn, - ""); - - addProtectedField("ormTexFormat", TypeGFXFormat, Offset(mOrmTexFormat, TerrainBlock), - &TerrainBlock::_setOrmTexFormat, &defaultProtectedGetFn, - ""); - addField( "screenError", TypeS32, Offset( mScreenError, TerrainBlock ), "Not yet implemented." ); addField( "updateBasetex", TypeBool, Offset( mUpdateBasetex, TerrainBlock ), "Whether or not to update the Base Texture" ); @@ -1524,15 +1348,6 @@ U32 TerrainBlock::packUpdate(NetConnection* con, U32 mask, BitStream *stream) { stream->write( mBaseTexSize ); stream->write( mLightMapSize ); - - stream->write( mDetailTexSize ); - stream->write( static_cast(mDetailTexFormat) ); - stream->write( mMacroTexSize ); - stream->write( static_cast(mMacroTexFormat) ); - stream->write( mNormalTexSize ); - stream->write( static_cast(mNormalTexFormat) ); - stream->write( mOrmTexSize ); - stream->write( static_cast(mOrmTexFormat) ); } stream->writeFlag( mask & HeightMapChangeMask ); @@ -1595,73 +1410,6 @@ void TerrainBlock::unpackUpdate(NetConnection* con, BitStream *stream) clearLightMap(); } } - - bool updateMaterials = false; - - U32 detailTexSize; - stream->read(&detailTexSize); - if (mDetailTexSize != detailTexSize) - { - mDetailTexSize = detailTexSize; - updateMaterials = true; - } - S32 detailTexFormat; - stream->read(&detailTexFormat); - if (mDetailTexFormat != detailTexFormat) - { - mDetailTexFormat = static_cast(detailTexFormat); - updateMaterials = true; - } - - U32 macroTexSize; - stream->read(¯oTexSize); - if (mMacroTexSize != macroTexSize) - { - mMacroTexSize = macroTexSize; - updateMaterials = true; - } - S32 macroTexFormat; - stream->read(¯oTexFormat); - if (mMacroTexFormat != macroTexFormat) - { - mMacroTexFormat = static_cast(macroTexFormat); - updateMaterials = true; - } - - U32 normalTexSize; - stream->read(&normalTexSize); - if (mNormalTexSize != normalTexSize) - { - mNormalTexSize = normalTexSize; - updateMaterials = true; - } - S32 normalTexFormat; - stream->read(&normalTexFormat); - if (mNormalTexFormat != normalTexFormat) - { - mNormalTexFormat = static_cast(normalTexFormat); - updateMaterials = true; - } - - U32 ormTexSize; - stream->read(&ormTexSize); - if (mOrmTexSize != ormTexSize) - { - mOrmTexSize = ormTexSize; - updateMaterials = true; - } - S32 ormTexFormat; - stream->read(&ormTexFormat); - if (mOrmTexFormat != ormTexFormat) - { - mOrmTexFormat = static_cast(ormTexFormat); - updateMaterials = true; - } - - if (updateMaterials && isProperlyAdded()) - { - _updateMaterials(); - } } if ( stream->readFlag() && isProperlyAdded() ) // HeightMapChangeMask diff --git a/Engine/source/terrain/terrData.h b/Engine/source/terrain/terrData.h index 3df260b7b..cfef5c29d 100644 --- a/Engine/source/terrain/terrData.h +++ b/Engine/source/terrain/terrData.h @@ -174,15 +174,6 @@ protected: BaseTexFormat mBaseTexFormat; - U32 mDetailTexSize; - GFXFormat mDetailTexFormat; - U32 mMacroTexSize; - GFXFormat mMacroTexFormat; - U32 mNormalTexSize; - GFXFormat mNormalTexFormat; - U32 mOrmTexSize; - GFXFormat mOrmTexFormat; - /// TerrCell *mCell; @@ -267,14 +258,6 @@ protected: static bool _setSquareSize( void *obj, const char *index, const char *data ); static bool _setBaseTexSize(void *obj, const char *index, const char *data); static bool _setBaseTexFormat(void *obj, const char *index, const char *data); - static bool _setDetailTexSize(void *obj, const char *index, const char *data); - static bool _setDetailTexFormat(void *obj, const char *index, const char *data); - static bool _setMacroTexSize(void *obj, const char *index, const char *data); - static bool _setMacroTexFormat(void *obj, const char *index, const char *data); - static bool _setNormalTexSize(void *obj, const char *index, const char *data); - static bool _setNormalTexFormat(void *obj, const char *index, const char *data); - static bool _setOrmTexSize(void *obj, const char *index, const char *data); - static bool _setOrmTexFormat(void *obj, const char *index, const char *data); static bool _setLightMapSize( void *obj, const char *index, const char *data ); public: diff --git a/Engine/source/terrain/terrRender.cpp b/Engine/source/terrain/terrRender.cpp index 4d1524009..ee3856eef 100644 --- a/Engine/source/terrain/terrRender.cpp +++ b/Engine/source/terrain/terrRender.cpp @@ -173,41 +173,52 @@ void TerrainBlock::_updateMaterials() #endif // Format has been explicitly set - if (mDetailTexSize != 0) + const U32 detailTexSize = Con::getIntVariable("Terrain::DetailTextureSize"); + const GFXFormat detailTexFormat = static_cast(Con::getIntVariable("Terrain::DetailTextureFormat")); + if (detailTexSize != 0) { GFXFormat format = GFXFormatR8G8B8A8; - if (mDetailTexFormat < GFXFormat_COUNT) + if (detailTexFormat < GFXFormat_COUNT) { - format = mDetailTexFormat; + format = detailTexFormat; } - mDetailTextureArray->set(mDetailTexSize, mDetailTexSize, detailTexArraySize, format); + mDetailTextureArray->set(detailTexSize, detailTexSize, detailTexArraySize, format); } - if (mMacroTexSize != 0) + + const U32 macroTexSize = Con::getIntVariable("Terrain::MacroTextureSize"); + const GFXFormat macroTexFormat = static_cast(Con::getIntVariable("Terrain::MacroTextureFormat")); + if (macroTexSize != 0) { GFXFormat format = GFXFormatR8G8B8A8; - if (mMacroTexFormat < GFXFormat_COUNT) + if (macroTexFormat < GFXFormat_COUNT) { - format = mMacroTexFormat; + format = macroTexFormat; } - mMacroTextureArray->set(mMacroTexSize, mMacroTexSize, macroTexArraySize, format); + mMacroTextureArray->set(macroTexSize, macroTexSize, macroTexArraySize, format); } - if (mNormalTexSize != 0) + + const U32 normalTexSize = Con::getIntVariable("Terrain::NormalTextureSize"); + const GFXFormat normalTexFormat = static_cast(Con::getIntVariable("Terrain::NormalTextureFormat")); + if (normalTexSize != 0) { GFXFormat format = GFXFormatR8G8B8A8; - if (mNormalTexFormat < GFXFormat_COUNT) + if (normalTexFormat < GFXFormat_COUNT) { - format = mNormalTexFormat; + format = normalTexFormat; } - mNormalTextureArray->set(mNormalTexSize, mNormalTexSize, normalTexArraySize, format); + mNormalTextureArray->set(normalTexSize, normalTexSize, normalTexArraySize, format); } - if (mOrmTexSize != 0) + + const U32 ormTexSize = Con::getIntVariable("Terrain::OrmTextureSize"); + const GFXFormat ormTexFormat = static_cast(Con::getIntVariable("Terrain::OrmTextureFormat")); + if (ormTexSize != 0) { GFXFormat format = GFXFormatR8G8B8A8; - if (mOrmTexFormat < GFXFormat_COUNT) + if (ormTexFormat < GFXFormat_COUNT) { - format = mOrmTexFormat; + format = ormTexFormat; } - mOrmTextureArray->set(mOrmTexSize, mOrmTexSize, ormTexArraySize, format); + mOrmTextureArray->set(ormTexSize, ormTexSize, ormTexArraySize, format); } if (!mDetailTextureArray->fromTextureArray(detailTexArray, detailTexArraySize)) diff --git a/Templates/BaseGame/game/core/rendering/Core_Rendering.cs b/Templates/BaseGame/game/core/rendering/Core_Rendering.cs index 653482d43..8ed5daf45 100644 --- a/Templates/BaseGame/game/core/rendering/Core_Rendering.cs +++ b/Templates/BaseGame/game/core/rendering/Core_Rendering.cs @@ -11,6 +11,18 @@ function Core_Rendering::onCreate(%this) $pref::ReflectionProbes::BakeResolution = ProjectSettings.value("Rendering/ProbeCaptureResolution", "64"); + $Terrain::LerpBlend = ProjectSettings.value("Terrain/LerpBlend"); + + $Terrain::DetailTextureSize = ProjectSettings.value("Terrain/DetailTextureSize"); + $Terrain::MacroTextureSize = ProjectSettings.value("Terrain/MacroTextureSize"); + $Terrain::NormalTextureSize = ProjectSettings.value("Terrain/NormalTextureSize"); + $Terrain::OrmTextureSize = ProjectSettings.value("Terrain/OrmTextureSize"); + + $Terrain::DetailTextureFormat = ProjectSettings.value("Terrain/DetailTextureFormat"); + $Terrain::MacroTextureFormat = ProjectSettings.value("Terrain/MacroTextureFormat"); + $Terrain::NormalTextureFormat = ProjectSettings.value("Terrain/NormalTextureFormat"); + $Terrain::OrmTextureFormat = ProjectSettings.value("Terrain/OrmTextureFormat"); + exec("./scripts/graphicsOptions.cs"); exec("./scripts/renderManager.cs"); exec("./scripts/gfxData/clouds.cs"); diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui index ae353fd22..ca4126330 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui @@ -464,9 +464,9 @@ bitmap = "tools/gui/images/separator-h.png"; }; - new GuiControl(LerpBlendCheckButtonContainer,EditorGuiGroup) { + new GuiControl(TerrainTextureSettingsButtonContainer,EditorGuiGroup) { position = "628 5"; - extent = "70 50"; + extent = "90 18"; minExtent = "8 2"; horizSizing = "right"; vertSizing = "bottom"; @@ -478,27 +478,17 @@ isContainer = "1"; canSave = "1"; canSaveDynamicFields = "0"; - - new GuiCheckBoxCtrl() { - text = " LerpBlend"; - groupNum = "-1"; - buttonType = "ToggleButton"; - useMouseEvents = "0"; - position = "0 2"; - extent = "140 18"; - minExtent = "8 2"; + + new GuiButtonCtrl() { + text = "Texture Settings"; + buttonType = "pushButton"; + profile = "ToolsGuiButtonProfile"; + command = "TerrainTextureSettingsDlg.show();"; + tooltipProfile = "ToolsGuiToolTipProfile"; + position = "0 0"; + extent = "90 18"; horizSizing = "right"; vertSizing = "bottom"; - profile = "ToolsGuiCheckBoxProfile"; - visible = "1"; - active = "1"; - command = "ETerrainEditor.toggleBlendType($ThisControl);"; - tooltipProfile = "ToolsGuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "LerpBlendCheckBox"; - canSave = "1"; - canSaveDynamicFields = "0"; }; }; }; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui new file mode 100644 index 000000000..72801178d --- /dev/null +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui @@ -0,0 +1,278 @@ +//--- OBJECT WRITE BEGIN --- +%guiContent = new GuiControl(TerrainTextureSettingsDlg, EditorGuiGroup) { + position = "0 0"; + extent = "1024 768"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "1"; + + new GuiWindowCtrl() { + canSaveDynamicFields = "0"; + internalName = "TerrainTextureSettings"; + Enabled = "1"; + isContainer = "1"; + Profile = "ToolsGuiWindowProfile"; + position = "342 184"; + extent = "340 400"; + minExtent = "340 400"; + horizSizing = "center"; + vertSizing = "center"; + canSave = "1"; + isDecoy = "0"; + Visible = "1"; + tooltipprofile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "1"; + AnchorLeft = "1"; + AnchorRight = "1"; + resizeWidth = "1"; + resizeHeight = "0"; + canMove = "1"; + canClose = "1"; + canMinimize = "0"; + canMaximize = "0"; + minSize = "4 4"; + closeCommand = "TerrainTextureSettingsDlg.cancel();"; + EdgeSnap = "0"; + text = "Global Terrain Texture Settings"; + + new GuiCheckBoxCtrl() { + internalName = "lerpBlendCheckBox"; + text = "LerpBlend"; + profile = "ToolsGuiCheckBoxProfile"; + tooltipProfile = "ToolsGuiToolTipProfile"; + tooltip = "If enabled, terrain textures will use a simple linear interpolation blending method."; + + command = "TerrainTextureSettingsDlg.apply();"; + + position = "20 40"; + extent = "300 20"; + }; + + new GuiControl() { + position = "20 80"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "Detail Texture Size:"; + profile = "ToolsGuiTextProfile"; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiTextEditCtrl() { + internalName = "detailTextureSizeTextEdit"; + profile = "ToolsGuiTextEditProfile"; + + command = "TerrainTextureSettingsDlg.apply();"; + + position = "130 0"; + extent = "170 20"; + }; + }; + + new GuiControl() { + position = "20 110"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "Detail Texture Format:"; + profile = "ToolsGuiTextProfile"; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiPopUpMenuCtrl() { + internalName = "detailTextureFormatPopUpMenu"; + profile = "ToolsGuiPopUpMenuProfile"; + + command = "TerrainTextureSettingsDlg.apply();"; + + position = "130 0"; + extent = "170 20"; + }; + }; + + new GuiControl() { + position = "20 140"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "Macro Texture Size:"; + profile = "ToolsGuiTextProfile"; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiTextEditCtrl() { + internalName = "macroTextureSizeTextEdit"; + profile = "ToolsGuiTextEditProfile"; + + command = "TerrainTextureSettingsDlg.apply();"; + + position = "130 0"; + extent = "170 20"; + }; + }; + + new GuiControl() { + position = "20 170"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "Macro Texture Format:"; + profile = "ToolsGuiTextProfile"; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiPopUpMenuCtrl() { + internalName = "macroTextureFormatPopUpMenu"; + profile = "ToolsGuiPopUpMenuProfile"; + + command = "TerrainTextureSettingsDlg.apply();"; + + position = "130 0"; + extent = "170 20"; + }; + }; + + new GuiControl() { + position = "20 200"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "Normal Texture Size:"; + profile = "ToolsGuiTextProfile"; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiTextEditCtrl() { + internalName = "normalTextureSizeTextEdit"; + profile = "ToolsGuiTextEditProfile"; + + command = "TerrainTextureSettingsDlg.apply();"; + + position = "130 0"; + extent = "170 20"; + }; + }; + + new GuiControl() { + position = "20 230"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "Normal Texture Format:"; + profile = "ToolsGuiTextProfile"; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiPopUpMenuCtrl() { + internalName = "normalTextureFormatPopUpMenu"; + profile = "ToolsGuiPopUpMenuProfile"; + + command = "TerrainTextureSettingsDlg.apply();"; + + position = "130 0"; + extent = "170 20"; + }; + }; + + new GuiControl() { + position = "20 260"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "ORM Texture Size:"; + profile = "ToolsGuiTextProfile"; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiTextEditCtrl() { + internalName = "ormTextureSizeTextEdit"; + profile = "ToolsGuiTextEditProfile"; + + position = "130 0"; + extent = "170 20"; + }; + }; + + new GuiControl() { + position = "20 290"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 20"; + + new GuiTextCtrl() { + text = "ORM Texture Format:"; + profile = "ToolsGuiTextProfile"; + + position = "0 0"; + extent = "120 20"; + }; + + new GuiPopUpMenuCtrl() { + internalName = "ormTextureFormatPopUpMenu"; + profile = "ToolsGuiPopUpMenuProfile"; + + position = "130 0"; + extent = "170 20"; + }; + }; + + new GuiControl() { + position = "20 350"; + profile = "ToolsGuiDefaultProfile"; + extent = "300 30"; + + new GuiButtonCtrl() { + text = "Apply & Save"; + profile = "ToolsGuiButtonProfile"; + position = "0 0"; + + extent = "145 30"; + + command = "TerrainTextureSettingsDlg.applyAndSave();"; + }; + + new GuiButtonCtrl() { + text = "Cancel"; + profile = "ToolsGuiButtonProfile"; + position = "155 0"; + + command = "TerrainTextureSettingsDlg.cancel();"; + + extent = "145 30"; + }; + }; + }; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.cs index b39839e8d..dd1693405 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.cs @@ -119,7 +119,8 @@ function EditorGui::init(%this) } exec("~/worldEditor/gui/guiTerrainMaterialDlg.ed.gui"); - exec("~/worldEditor/gui/TerrainBrushSoftnessCurveDlg.ed.gui"); + exec("~/worldEditor/gui/TerrainBrushSoftnessCurveDlg.ed.gui"); + exec("~/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui"); } if ( !isObject( %this-->TerrainPainterToolbar) ) { diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs index 27dbff083..c0a883fda 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/editors/terrainEditor.ed.cs @@ -222,8 +222,6 @@ function EPainter::setup( %this, %matIndex ) ETerrainEditor.setAction( ETerrainEditor.currentAction ); EditorGuiStatusBar.setInfo(ETerrainEditor.currentActionDesc); ETerrainEditor.renderVertexSelection = true; - - EWTerrainPainterToolbar-->LerpBlendCheckBox.setValue($Terrain::LerpBlend); } function onNeedRelight() @@ -259,12 +257,6 @@ function TerrainEditor::toggleBrushType( %this, %brush ) %this.setBrushType( %brush.internalName ); } -function TerrainEditor::toggleBlendType( %this, %check ) -{ - $Terrain::LerpBlend = %check.getValue(); - %this.getActiveTerrain().getClientObject().setMaterialsDirty(); -} - function TerrainEditor::offsetBrush(%this, %x, %y) { %curPos = %this.getBrushPos(); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainTextureSettingsDlg.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainTextureSettingsDlg.ed.cs new file mode 100644 index 000000000..59b72e82b --- /dev/null +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainTextureSettingsDlg.ed.cs @@ -0,0 +1,151 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +$TerrainTextureSettingsDlg::TerrainTextureFormat = + "R8G8B8 10" TAB + "R8G8B8_SRGB 11" TAB + "R8G8B8A8 12" TAB + "R8G8B8A8_SRGB 15" TAB + "BC5 33"; + +//----------------------------------------------------------------------------- + +function TerrainTextureSettingsDlg::show( %this ) +{ + //%this.onWake(); + Canvas.pushDialog( %this ); +} + +function TerrainTextureSettingsDlg::onWake( %this ) { + %this-->lerpBlendCheckBox.setStateOn(ProjectSettings.value("Terrain/LerpBlend")); + + %this-->detailTextureFormatPopUpMenu.clear(); + %this-->macroTextureFormatPopUpMenu.clear(); + %this-->normalTextureFormatPopUpMenu.clear(); + %this-->ormTextureFormatPopUpMenu.clear(); + + for(%i = 0; %i < getFieldCount($TerrainTextureSettingsDlg::TerrainTextureFormat); %i++) { + %field = getField($TerrainTextureSettingsDlg::TerrainTextureFormat, %i); + + %this-->detailTextureFormatPopUpMenu.add(getWord(%field, 0), getWord(%field, 1)); + %this-->macroTextureFormatPopUpMenu.add(getWord(%field, 0), getWord(%field, 1)); + %this-->normalTextureFormatPopUpMenu.add(getWord(%field, 0), getWord(%field, 1)); + %this-->ormTextureFormatPopUpMenu.add(getWord(%field, 0), getWord(%field, 1)); + } + + %this-->detailTextureFormatPopUpMenu.setSelected(ProjectSettings.value("Terrain/DetailTextureFormat"), false); + %this-->macroTextureFormatPopUpMenu.setSelected(ProjectSettings.value("Terrain/MacroTextureFormat"), false); + %this-->normalTextureFormatPopUpMenu.setSelected(ProjectSettings.value("Terrain/NormalTextureFormat"), false); + %this-->ormTextureFormatPopUpMenu.setSelected(ProjectSettings.value("Terrain/OrmTextureFormat"), false); + + %this-->detailTextureSizeTextEdit.setText(ProjectSettings.value("Terrain/DetailTextureSize")); + %this-->macroTextureSizeTextEdit.setText(ProjectSettings.value("Terrain/MacroTextureSize")); + %this-->normalTextureSizeTextEdit.setText(ProjectSettings.value("Terrain/NormalTextureSize")); + %this-->ormTextureSizeTextEdit.setText(ProjectSettings.value("Terrain/OrmTextureSize")); +} + +function TerrainTextureSettingsDlg::apply( %this ) { + $Terrain::LerpBlend = %this-->lerpBlendCheckBox.isStateOn(); + + $Terrain::DetailTextureFormat = %this-->detailTextureFormatPopUpMenu.getSelected(); + $Terrain::MacroTextureFormat = %this-->macroTextureFormatPopUpMenu.getSelected(); + $Terrain::NormalTextureFormat = %this-->normalTextureFormatPopUpMenu.getSelected(); + $Terrain::OrmTextureFormat = %this-->ormTextureFormatPopUpMenu.getSelected(); + + if (%this-->detailTextureSizeTextEdit.getText() $= "" || mIsPow2(%this-->detailTextureSizeTextEdit.getText())) { + $Terrain::DetailTextureSize = %this-->detailTextureSizeTextEdit.getText(); + } + if (%this-->macroTextureSizeTextEdit.getText() $= "" || mIsPow2(%this-->macroTextureSizeTextEdit.getText())) { + $Terrain::MacroTextureSize = %this-->macroTextureSizeTextEdit.getText(); + } + if (%this-->normalTextureSizeTextEdit.getText() $= "" || mIsPow2(%this-->normalTextureSizeTextEdit.getText())) { + $Terrain::NormalTextureSize = %this-->normalTextureSizeTextEdit.getText(); + } + if (%this-->ormTextureSizeTextEdit.getText() $= "" || mIsPow2(%this-->ormTextureSizeTextEdit.getText())) { + $Terrain::OrmTextureSize = %this-->ormTextureSizeTextEdit.getText(); + } + + ETerrainEditor.getActiveTerrain().getClientObject().setMaterialsDirty(); +} + + +function TerrainTextureSettingsDlg::validate( %this ) { + if (%this-->detailTextureSizeTextEdit.getText() !$= "" && !mIsPow2(%this-->detailTextureSizeTextEdit.getText())) { + toolsMessageBoxOK("Detail Texture Error!", "Detail texture resolution must be a power of 2"); + return false; + } + if (%this-->macroTextureSizeTextEdit.getText() !$= "" && !mIsPow2(%this-->macroTextureSizeTextEdit.getText())) { + toolsMessageBoxOK("Macro Texture Error!", "Macro texture resolution must be a power of 2"); + return false; + } + if (%this-->normalTextureSizeTextEdit.getText() !$= "" && !mIsPow2(%this-->normalTextureSizeTextEdit.getText())) { + toolsMessageBoxOK("Normal Texture Error!", "Normal texture resolution must be a power of 2"); + return false; + } + if (%this-->ormTextureSizeTextEdit.getText() !$= "" && !mIsPow2(%this-->ormTextureSizeTextEdit.getText())) { + toolsMessageBoxOK("ORM Texture Error!", "ORM texture resolution must be a power of 2"); + return false; + } + + return true; +} + + +function TerrainTextureSettingsDlg::cancel( %this ) { + $Terrain::LerpBlend = ProjectSettings.value("Terrain/LerpBlend"); + + $Terrain::DetailTextureFormat = ProjectSettings.value("Terrain/DetailTextureFormat"); + $Terrain::MacroTextureFormat = ProjectSettings.value("Terrain/MacroTextureFormat"); + $Terrain::NormalTextureFormat = ProjectSettings.value("Terrain/NormalTextureFormat"); + $Terrain::OrmTextureFormat = ProjectSettings.value("Terrain/OrmTextureFormat"); + + $Terrain::DetailTextureSize = ProjectSettings.value("Terrain/DetailTextureSize"); + $Terrain::MacroTextureSize = ProjectSettings.value("Terrain/MacroTextureSize"); + $Terrain::NormalTextureSize = ProjectSettings.value("Terrain/NormalTextureSize"); + $Terrain::OrmTextureSize = ProjectSettings.value("Terrain/OrmTextureSize"); + + ETerrainEditor.getActiveTerrain().getClientObject().setMaterialsDirty(); + Canvas.popDialog(%this); +} + +function TerrainTextureSettingsDlg::applyAndSave( %this ) { + if (!%this.validate()) { + return; + } + %this.apply(); + + ProjectSettings.setValue("Terrain/LerpBlend", $Terrain::LerpBlend); + + ProjectSettings.setValue("Terrain/DetailTextureFormat", $Terrain::DetailTextureFormat); + ProjectSettings.setValue("Terrain/MacroTextureFormat", $Terrain::MacroTextureFormat); + ProjectSettings.setValue("Terrain/NormalTextureFormat", $Terrain::NormalTextureFormat); + ProjectSettings.setValue("Terrain/OrmTextureFormat", $Terrain::OrmTextureFormat); + + ProjectSettings.setValue("Terrain/DetailTextureSize", $Terrain::DetailTextureSize); + ProjectSettings.setValue("Terrain/MacroTextureSize", $Terrain::MacroTextureSize); + ProjectSettings.setValue("Terrain/NormalTextureSize", $Terrain::NormalTextureSize); + ProjectSettings.setValue("Terrain/OrmTextureSize", $Terrain::OrmTextureSize); + + ProjectSettings.write(); + + Canvas.popDialog(%this); +} \ No newline at end of file