From 37492dc8a0ccfe6eb55640d077c033ad7dd50b49 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Thu, 7 Sep 2023 13:19:32 +0900 Subject: [PATCH] six ecological seasons for terrain tiles --- assets/mods/basegame/blocks/33.tga | 4 +- assets/mods/basegame/blocks/34.tga | 4 +- .../torvald/terrarum/weather/Weatherbox.kt | 2 +- .../terrarum/worlddrawer/BlocksDrawer.kt | 26 +++-- .../terrarum/worlddrawer/CreateTileAtlas.kt | 100 +++++++++++------- .../graphics/terrain/terrain_mask_type02.kra | 4 +- .../graphics/terrain/terrain_mask_type02.psd | 3 - 7 files changed, 82 insertions(+), 61 deletions(-) delete mode 100644 work_files/graphics/terrain/terrain_mask_type02.psd diff --git a/assets/mods/basegame/blocks/33.tga b/assets/mods/basegame/blocks/33.tga index 628b92398..80aad5fd4 100644 --- a/assets/mods/basegame/blocks/33.tga +++ b/assets/mods/basegame/blocks/33.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a010ac5489a95479b7314befa3055e2c9a01060357bbcc9c89f506dac99a8c78 -size 200722 +oid sha256:05317842cc2071fc8953fe118c224abc10258ed1950965a462d2959e577ad85d +size 301074 diff --git a/assets/mods/basegame/blocks/34.tga b/assets/mods/basegame/blocks/34.tga index 32800af93..3e8f55411 100644 --- a/assets/mods/basegame/blocks/34.tga +++ b/assets/mods/basegame/blocks/34.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:56be9864e042e612b5a427e00d79b3d3a9a5b82a733c0a4374540b511a947bae -size 200722 +oid sha256:2450fdfb814d65cc6539ad4570a9bfb1d5a08e938d341a8b56550d7d07724aae +size 301074 diff --git a/src/net/torvald/terrarum/weather/Weatherbox.kt b/src/net/torvald/terrarum/weather/Weatherbox.kt index 1f3f26b68..52645f529 100644 --- a/src/net/torvald/terrarum/weather/Weatherbox.kt +++ b/src/net/torvald/terrarum/weather/Weatherbox.kt @@ -14,7 +14,7 @@ data class WeatherSchedule(val weather: BaseModularWeather = WeatherMixer.DEFAUL class Weatherbox { companion object { - private val WIND_DIR_TIME_UNIT = 3600f * 6 // every 6hr + private val WIND_DIR_TIME_UNIT = 3600f * 15 // every 15hr private val WIND_SPEED_TIME_UNIT = 360f * 5 // every 0.5hr private val HALF_PIF = 1.5707964f diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt index 88b975e3b..aac68e7f6 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt @@ -45,7 +45,8 @@ internal object BlocksDrawer { /** Index zero: spring */ val weatherTerrains: Array lateinit var tilesTerrain: TextureRegionPack; private set - lateinit var tilesTerrainBlend: TextureRegionPack; private set + lateinit var tilesTerrainNext: TextureRegionPack; private set + private var tilesTerrainBlendDegree = 0f //val tilesWire: TextureRegionPack val tileItemTerrain: TextureRegionPack val tileItemTerrainGlow: TextureRegionPack @@ -103,10 +104,12 @@ internal object BlocksDrawer { // create terrain texture from pixmaps weatherTerrains = arrayOf( - TextureRegionPack(Texture(App.tileMaker.atlasSpring), TILE_SIZE, TILE_SIZE), - TextureRegionPack(Texture(App.tileMaker.atlas), TILE_SIZE, TILE_SIZE), - TextureRegionPack(Texture(App.tileMaker.atlasAutumn), TILE_SIZE, TILE_SIZE), - TextureRegionPack(Texture(App.tileMaker.atlasWinter), TILE_SIZE, TILE_SIZE) + TextureRegionPack(Texture(App.tileMaker.atlas), TILE_SIZE, TILE_SIZE), + TextureRegionPack(Texture(App.tileMaker.atlasVernal), TILE_SIZE, TILE_SIZE), + TextureRegionPack(Texture(App.tileMaker.atlasAestival), TILE_SIZE, TILE_SIZE), + TextureRegionPack(Texture(App.tileMaker.atlasSerotinal), TILE_SIZE, TILE_SIZE), + TextureRegionPack(Texture(App.tileMaker.atlasAutumnal), TILE_SIZE, TILE_SIZE), + TextureRegionPack(Texture(App.tileMaker.atlasHibernal), TILE_SIZE, TILE_SIZE), ) //tilesWire = TextureRegionPack(ModMgr.getGdxFile("basegame", "wires/wire.tga"), TILE_SIZE, TILE_SIZE) @@ -193,11 +196,12 @@ internal object BlocksDrawer { internal fun renderData() { try { - drawTIME_T = world.worldTime.TIME_T - (WorldTime.DAY_LENGTH * 15) // offset by -15 days - val seasonalMonth = (drawTIME_T.div(WorldTime.DAY_LENGTH) fmod WorldTime.YEAR_DAYS.toLong()).toInt() / WorldTime.MONTH_LENGTH + 1 + drawTIME_T = world.worldTime.TIME_T - (WorldTime.DAY_LENGTH * 10) // offset by -10 days + val seasonalMonth = (drawTIME_T fmod (WorldTime.DAY_LENGTH * WorldTime.YEAR_DAYS).toLong()).toFloat() / (WorldTime.DAY_LENGTH * WorldTime.YEAR_DAYS / weatherTerrains.size) - tilesTerrain = weatherTerrains[seasonalMonth - 1] - tilesTerrainBlend = weatherTerrains[seasonalMonth fmod 4] + tilesTerrain = weatherTerrains[seasonalMonth.floorToInt()] + tilesTerrainNext = weatherTerrains[(seasonalMonth + 1).floorToInt() fmod weatherTerrains.size] + tilesTerrainBlendDegree = seasonalMonth % 1f } catch (e: ClassCastException) { } @@ -616,7 +620,7 @@ internal object BlocksDrawer { tilesGlow.texture.bind(0) // for some fuck reason, it must be bound as last } else { - tilesTerrainBlend.texture.bind(2) + tilesTerrainNext.texture.bind(2) _tilesBufferAsTex.bind(1) // trying 1 and 0... tileAtlas.texture.bind(0) // for some fuck reason, it must be bound as last } @@ -639,7 +643,7 @@ internal object BlocksDrawer { shader.setUniformf("atlasTexSize", tileAtlas.texture.width.toFloat(), tileAtlas.texture.height.toFloat()) //depends on the tile atlas // set the blend value as world's time progresses, in linear fashion shader.setUniformf("tilesBlend", if (mode == TERRAIN || mode == WALL) - drawTIME_T.fmod(SECONDS_IN_MONTH) / SECONDS_IN_MONTH.toFloat() + tilesTerrainBlendDegree else 0f ) diff --git a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt index 3329cd5a3..1ad8c8a69 100644 --- a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt +++ b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt @@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.utils.GdxRuntimeException import com.jme3.math.FastMath import net.torvald.gdx.graphics.Cvec -import net.torvald.gdx.graphics.PixmapIO2 import net.torvald.terrarum.* import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE @@ -40,10 +39,12 @@ class CreateTileAtlas { val wallOverlayColour = Color(.65f, .65f, .65f, 1f) - lateinit var atlas: Pixmap - lateinit var atlasAutumn: Pixmap - lateinit var atlasWinter: Pixmap - lateinit var atlasSpring: Pixmap + lateinit var atlas: Pixmap // prevernal + lateinit var atlasVernal: Pixmap + lateinit var atlasAestival: Pixmap + lateinit var atlasSerotinal: Pixmap + lateinit var atlasAutumnal: Pixmap + lateinit var atlasHibernal: Pixmap lateinit var atlasFluid: Pixmap lateinit var atlasGlow: Pixmap // glowing won't be affected by the season... for now lateinit var itemTerrainTexture: Texture @@ -84,9 +85,11 @@ class CreateTileAtlas { if (MAX_TEX_SIZE >= initPixmap.width) { atlas.drawPixmap(initPixmap, 0, 0) - atlasAutumn.drawPixmap(initPixmap, 0, 0) - atlasWinter.drawPixmap(initPixmap, 0, 0) - atlasSpring.drawPixmap(initPixmap, 0, 0) + atlasVernal.drawPixmap(initPixmap, 0, 0) + atlasAestival.drawPixmap(initPixmap, 0, 0) + atlasSerotinal.drawPixmap(initPixmap, 0, 0) + atlasAutumnal.drawPixmap(initPixmap, 0, 0) + atlasHibernal.drawPixmap(initPixmap, 0, 0) } else { /* @@ -107,9 +110,11 @@ class CreateTileAtlas { val destY = scantile * TILE_SIZE atlas.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) - atlasAutumn.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) - atlasWinter.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) - atlasSpring.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) + atlasVernal.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) + atlasAestival.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) + atlasSerotinal.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) + atlasAutumnal.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) + atlasHibernal.drawPixmap(initPixmap, srcX, srcY, scanW, scanH, destX, destY, scanW, scanH) } } @@ -125,9 +130,11 @@ class CreateTileAtlas { itemSheetNumbers = HashMap() atlas = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } - atlasAutumn = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } - atlasWinter = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } - atlasSpring = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } + atlasVernal = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } + atlasAestival = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } + atlasSerotinal = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } + atlasAutumnal = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } + atlasHibernal = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } atlasFluid = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } atlasGlow = Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None } @@ -352,25 +359,29 @@ class CreateTileAtlas { expandAtlantes() } - val seasonal = matte.width == matte.height && matte.width == 14 * TILE_SIZE + val sixSeasonal = matte.width == 21 * TILE_SIZE && matte.height == 14 * TILE_SIZE val txOfPixmap = matte.width / TILE_SIZE val txOfPixmapGlow = glow.width / TILE_SIZE for (i in 0 until tilesCount) { //printdbg(this, "Rendering to atlas, tile# $atlasCursor, tilesCount = $tilesCount, seasonal = $seasonal") // different texture for different seasons (224x224) - if (seasonal) { + if (sixSeasonal) { val i = if (i < 41) i else i + 1 // to compensate the discontinuity between 40th and 41st tile - _drawToAtlantes(matte, atlasCursor, i % 7, i / 7, SUMMER) - _drawToAtlantes(matte, atlasCursor, i % 7 + 7, i / 7, AUTUMN) - _drawToAtlantes(matte, atlasCursor, i % 7 + 7, i / 7 + 7, WINTER) - _drawToAtlantes(matte, atlasCursor, i % 7, i / 7 + 7, SPRING) + _drawToAtlantes(matte, atlasCursor, i % 7 , i / 7, PREVERNAL) + _drawToAtlantes(matte, atlasCursor, i % 7 + 7 , i / 7, VERNAL) + _drawToAtlantes(matte, atlasCursor, i % 7 + 14, i / 7, AESTIVAL) + + _drawToAtlantes(matte, atlasCursor, i % 7 + 14, i / 7 + 7, SEROTINAL) + _drawToAtlantes(matte, atlasCursor, i % 7 + 7 , i / 7 + 7, AUTUMNAL) + _drawToAtlantes(matte, atlasCursor, i % 7 , i / 7 + 7, HIBERNAL) + _drawToAtlantes(glow, atlasCursor, i % 7, i / 7, GLOW) atlasCursor += 1 } else { val i = if (i < 41) i else i + 1 // to compensate the discontinuity between 40th and 41st tile - _drawToAtlantes(matte, atlasCursor, i % txOfPixmap, i / txOfPixmap, FOUR_SEASONS) + _drawToAtlantes(matte, atlasCursor, i % txOfPixmap, i / txOfPixmap, SIX_SEASONS) _drawToAtlantes(glow, atlasCursor, i % txOfPixmapGlow, i / txOfPixmapGlow, GLOW) atlasCursor += 1 } @@ -381,11 +392,13 @@ class CreateTileAtlas { * mode: 0 for all the atlantes, 1-4 for summer/autumn/winter/spring atlas */ private fun _drawToAtlantes(pixmap: Pixmap, destTileNum: Int, srcTileX: Int, srcTileY: Int, source: AtlasSource) { - if (source == FOUR_SEASONS) { - _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, SUMMER) - _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, AUTUMN) - _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, WINTER) - _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, SPRING) + if (source == SIX_SEASONS) { + _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, PREVERNAL) + _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, VERNAL) + _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, AESTIVAL) + _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, SEROTINAL) + _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, AUTUMNAL) + _drawToAtlantes(pixmap, destTileNum, srcTileX, srcTileY, HIBERNAL) } else { val atlasX = (destTileNum % TILES_IN_X) * TILE_SIZE @@ -396,10 +409,12 @@ class CreateTileAtlas { //if (mode == 1) printdbg(this, "atlaspos: ($atlasX, $atlasY), srcpos: ($sourceX, $sourceY), srcpixmap = $pixmap") when (source) { - SUMMER -> atlas.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) - AUTUMN -> atlasAutumn.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) - WINTER -> atlasWinter.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) - SPRING -> atlasSpring.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) + PREVERNAL -> atlas.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) + VERNAL -> atlasVernal.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) + AESTIVAL -> atlasAestival.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) + SEROTINAL -> atlasSerotinal.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) + AUTUMNAL -> atlasAutumnal.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) + HIBERNAL -> atlasHibernal.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) FLUID -> atlasFluid.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) GLOW -> atlasGlow.drawPixmap(pixmap, sourceX, sourceY, TILE_SIZE, TILE_SIZE, atlasX, atlasY, TILE_SIZE, TILE_SIZE) else -> throw IllegalArgumentException("Unknown draw source $source") @@ -436,9 +451,11 @@ class CreateTileAtlas { fun dispose() { atlas.dispose() - atlasAutumn.dispose() - atlasWinter.dispose() - atlasSpring.dispose() + atlasVernal.dispose() + atlasAestival.dispose() + atlasSerotinal.dispose() + atlasAutumnal.dispose() + atlasHibernal.dispose() atlasFluid.dispose() atlasGlow.dispose() //itemTerrainTexture.dispose() //BlocksDrawer will dispose of it as it disposes of 'tileItemTerrain (TextureRegionPack)' @@ -452,7 +469,8 @@ class CreateTileAtlas { } private enum class AtlasSource { - FOUR_SEASONS, SUMMER, AUTUMN, WINTER, SPRING, FLUID, GLOW + /*FOUR_SEASONS, SUMMER, AUTUMN, WINTER, SPRING,*/ FLUID, GLOW, + SIX_SEASONS, PREVERNAL, VERNAL, AESTIVAL, SEROTINAL, AUTUMNAL, HIBERNAL, } private fun expandAtlantes() { @@ -470,13 +488,13 @@ class CreateTileAtlas { TOTAL_TILES = TILES_IN_X * TILES_IN_X - val newAtlantes = Array(5) { + val newAtlantes = Array(7) { Pixmap(TILES_IN_X * TILE_SIZE, TILES_IN_X * TILE_SIZE, Pixmap.Format.RGBA8888).also { it.blending = Pixmap.Blending.None it.filter = Pixmap.Filter.NearestNeighbour } } - listOf(atlas, atlasAutumn, atlasWinter, atlasSpring, atlasGlow).forEachIndexed { index, pixmap -> + listOf(atlas, atlasVernal, atlasAestival, atlasSerotinal, atlasAutumnal, atlasHibernal, atlasGlow).forEachIndexed { index, pixmap -> /* How it works: @@ -502,10 +520,12 @@ class CreateTileAtlas { } atlas = newAtlantes[0] - atlasAutumn = newAtlantes[1] - atlasWinter = newAtlantes[2] - atlasSpring = newAtlantes[3] - atlasGlow = newAtlantes[4] + atlasVernal = newAtlantes[1] + atlasAestival = newAtlantes[2] + atlasSerotinal = newAtlantes[3] + atlasAutumnal = newAtlantes[4] + atlasHibernal = newAtlantes[5] + atlasGlow = newAtlantes[6] App.setConfig("atlastexsize", newTexSize) diff --git a/work_files/graphics/terrain/terrain_mask_type02.kra b/work_files/graphics/terrain/terrain_mask_type02.kra index 8035e7ecd..4b69bf43b 100644 --- a/work_files/graphics/terrain/terrain_mask_type02.kra +++ b/work_files/graphics/terrain/terrain_mask_type02.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:510b33c7979d1b7d276254e60cabba14d2885ca49b2ea013452a339407cc2d49 -size 457628 +oid sha256:685df8ddfb590c4d23a97c14562084ea7ee5d8b737a171b6057db9a8eeaa67ef +size 368655 diff --git a/work_files/graphics/terrain/terrain_mask_type02.psd b/work_files/graphics/terrain/terrain_mask_type02.psd deleted file mode 100644 index 23e5a8379..000000000 --- a/work_files/graphics/terrain/terrain_mask_type02.psd +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6baeb2e93110a57a0db89562a909ae6b54229b3026387318c355f5b526ee87fd -size 540748