diff --git a/assets/mods/basegame/blocks/32.tga b/assets/mods/basegame/blocks/32.tga index 78e4893f0..d4b770781 100644 --- a/assets/mods/basegame/blocks/32.tga +++ b/assets/mods/basegame/blocks/32.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b09edcc18beb6645de411583e0f43783fd8a9df9fa3e766cd2065087ff7dee91 -size 50194 +oid sha256:604ad38d7c643be10f092be079b55fb2454b09983ce4d8b90a134e60a79e0b84 +size 56594 diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt index ef0de70cb..a2ac1c158 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt @@ -883,14 +883,19 @@ internal object BlocksDrawer { } val baseXY = tilenumInAtlas.map { Point2i( it % (App.tileMaker.TILES_IN_X * 2), - it / (App.tileMaker.TILES_IN_X * 2), + (it / (App.tileMaker.TILES_IN_X * 2)).let { + if (it % 2 == 1) it + 1 else it + }, ) } // apply variants return (baseXY zip variants).map { (base, va) -> Point2i( base.x + va / 2, base.y + va % 2, - ) } + ) }.also { +// println("Base: $base") +// println("Tiles: $it") + } } private fun Int.reorientSubtileUsingFliprotIdx(fliprotIndex: Int): Int { diff --git a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt index 4d7134351..ba2e79f42 100644 --- a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt +++ b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt @@ -8,6 +8,7 @@ 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.SUBTILE_SIZE @@ -407,13 +408,13 @@ class CreateTileAtlas { addTag(blockID, RenderTag.CONNECT_SELF, RenderTag.MASK_FLUID) drawToAtlantes(tilesPixmap, tilesGlowPixmap, tilesEmissivePixmap, RenderTag.MASK_FLUID) } - // subtitle generic + // subtitles else if (tilesPixmap.width == W_SUBTILE_GENERIC && tilesPixmap.height == H_SUBTILE || tilesPixmap.width == W_SUBTILE_GRASS && tilesPixmap.height == H_SUBTILE || tilesPixmap.width == 3*W_SUBTILE_GENERIC && tilesPixmap.height == 2*H_SUBTILE || tilesPixmap.width == 3*W_SUBTILE_GRASS && tilesPixmap.height == 2*H_SUBTILE) { - // TODO figure out the tags + // figure out the tags // tags are arranged horizontally, left-to-right, starting from (0,0) // Line 0: (reserved for manual subtile allocation) // Line 1: Tiling Mode @@ -440,6 +441,7 @@ class CreateTileAtlas { else -> throw IllegalArgumentException("$connectionType0") } addTag(blockID, connectionType, maskType, tilingMode) +// println("drawToAtlantes tile: $blockID") drawToAtlantes(tilesPixmap, tilesGlowPixmap, tilesEmissivePixmap, maskType) } // 112x112 or 336x224 @@ -453,19 +455,19 @@ class CreateTileAtlas { // not marked: connect-mutual // marked: connect-self var connectionType = 0 -// var maskType = 0 + var maskType = 0 for (bit in 0 until TILE_SIZE) { val x = (7 * TILE_SIZE - 1) - bit val y1 = 5 * TILE_SIZE; val y2 = y1 + 1 val pixel1 = (tilesPixmap.getPixel(x, y1).and(255) >= 128).toInt(bit) -// val pixel2 = (tilesPixmap.getPixel(x, y2).and(255) >= 128).toInt(bit) + val pixel2 = (tilesPixmap.getPixel(x, y2).and(255) >= 128).toInt(bit) connectionType += pixel1 -// maskType += pixel2 + maskType += pixel2 } - addTag(blockID, connectionType, RenderTag.MASK_47) - drawToAtlantes(tilesPixmap, tilesGlowPixmap, tilesEmissivePixmap, RenderTag.MASK_47) + addTag(blockID, connectionType, maskType) + drawToAtlantes(tilesPixmap, tilesGlowPixmap, tilesEmissivePixmap, maskType) } itemSheetNumbers[blockID] = itemSheetCursor @@ -512,10 +514,16 @@ class CreateTileAtlas { val txOfPixmapEmissive = emissive.width / TILE_SIZE if (renderMask >= MASK_SUBTILE_GENERIC) { + for (i in 0 until tilesCount) { val srcX = SUBTILE_SIZE * (i / 4) val srcY = SUBTILE_SIZE * 4 * (i % 4) + SUBTILE_SIZE + // snippet straight from the _drawToAtlantesFourSubtiles +// val atlasX = (atlasCursor % TILES_IN_X) * TILE_SIZE +// val atlasY = (atlasCursor / TILES_IN_X) * TILE_SIZE +// println("Drawing tile to the atlas: atlasCursor=${atlasCursor}, atlasXY=($atlasX,$atlasY)") + if (sixSeasonal) { _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 0*wSubtileSheet, srcY, PREVERNAL) _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 1*wSubtileSheet, srcY, VERNAL) @@ -581,8 +589,8 @@ class CreateTileAtlas { else { // destTileNum increments by one, which means FOUR SUBTILES - val atlasX = (destTileNum % SUBTILES_IN_X) * TILE_SIZE - val atlasY = (destTileNum / SUBTILES_IN_X) * TILE_SIZE + val atlasX = (destTileNum % TILES_IN_X) * TILE_SIZE + val atlasY = (destTileNum / TILES_IN_X) * TILE_SIZE val target = when (source) { PREVERNAL -> atlasPrevernal @@ -596,8 +604,18 @@ class CreateTileAtlas { else -> throw IllegalArgumentException("Unknown draw source $source") } - target.drawPixmap(pixmap, sourceX, sourceY, SUBTILE_SIZE, TILE_SIZE, atlasX, atlasY, SUBTILE_SIZE, TILE_SIZE) - target.drawPixmap(pixmap, sourceX, sourceY + TILE_SIZE, SUBTILE_SIZE, TILE_SIZE, atlasX + SUBTILE_SIZE, atlasY, SUBTILE_SIZE, TILE_SIZE) + target.drawPixmap(pixmap, + sourceX, sourceY, + SUBTILE_SIZE, TILE_SIZE, + atlasX, atlasY, + SUBTILE_SIZE, TILE_SIZE + ) + target.drawPixmap(pixmap, + sourceX, sourceY + TILE_SIZE, + SUBTILE_SIZE, TILE_SIZE, + atlasX + SUBTILE_SIZE, atlasY, + SUBTILE_SIZE, TILE_SIZE + ) } }