From e8e5b47150f7a56fb1518ee4c96fcff868fd00b9 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Fri, 24 Mar 2023 13:47:07 +0100 Subject: [PATCH] uvlock test --- .../models/baked/FaceRotationTest.kt | 17 +++++ .../gui/rendering/models/baked/UVLockTest.kt | 76 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/UVLockTest.kt diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/FaceRotationTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/FaceRotationTest.kt index 8f7d6249c..dc91913f6 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/FaceRotationTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/FaceRotationTest.kt @@ -46,6 +46,23 @@ class FaceRotationTest { baked.assertFace(Directions.EAST, positions(Directions.EAST, from, to), floatArrayOf(1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), 0.6f) } + fun rotation1Y90() { + val from = Vec3(0.0f) + val to = Vec3(1.0f) + val model = SingleBlockStateApply(BlockModel(elements = listOf(ModelElement(from, to, faces = createFaces(rotation = 1))), textures = mapOf("test" to minecraft("block/test").texture())), y = 90) + + val baked = model.bake(createTextureManager("block/test"))!! + + + // we can use positions() here, because it is not rotated and already unit tested + baked.assertFace(Directions.DOWN, positions(Directions.DOWN, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.5f) + baked.assertFace(Directions.UP, positions(Directions.UP, from, to), floatArrayOf(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), 1.0f) + baked.assertFace(Directions.NORTH, positions(Directions.NORTH, from, to), floatArrayOf(1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), 0.8f) + baked.assertFace(Directions.SOUTH, positions(Directions.SOUTH, from, to), floatArrayOf(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), 0.8f) + baked.assertFace(Directions.WEST, positions(Directions.WEST, from, to), floatArrayOf(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), 0.6f) + baked.assertFace(Directions.EAST, positions(Directions.EAST, from, to), floatArrayOf(1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), 0.6f) + } + fun rotation3() { val from = Vec3(0.0f) val to = Vec3(1.0f) diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/UVLockTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/UVLockTest.kt new file mode 100644 index 000000000..a574c6c32 --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/UVLockTest.kt @@ -0,0 +1,76 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.gui.rendering.models.baked + +import de.bixilon.kotlinglm.vec3.Vec3 +import de.bixilon.minosoft.data.direction.Directions +import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft +import de.bixilon.minosoft.gui.rendering.models.baked.BakedModelTestUtil.assertFace +import de.bixilon.minosoft.gui.rendering.models.baked.BakedModelTestUtil.createFaces +import de.bixilon.minosoft.gui.rendering.models.baked.BakedModelTestUtil.createTextureManager +import de.bixilon.minosoft.gui.rendering.models.block.BlockModel +import de.bixilon.minosoft.gui.rendering.models.block.element.ModelElement +import de.bixilon.minosoft.gui.rendering.models.block.state.apply.SingleBlockStateApply +import de.bixilon.minosoft.gui.rendering.models.block.state.baked.BakingUtil.positions +import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture +import org.testng.annotations.Test + +@Test(groups = ["models"]) +class UVLockTest { + + fun y90() { + val from = Vec3(0.0f) + val to = Vec3(1.0f) + val model = SingleBlockStateApply(BlockModel(elements = listOf(ModelElement(from, to, faces = createFaces())), textures = mapOf("test" to minecraft("block/test").texture())), y = 1, uvLock = true) + + val baked = model.bake(createTextureManager("block/test"))!! + + baked.assertFace(Directions.DOWN, positions(Directions.DOWN, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.5f) + baked.assertFace(Directions.UP, positions(Directions.UP, from, to), floatArrayOf(0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f), 1.0f) + baked.assertFace(Directions.NORTH, positions(Directions.NORTH, from, to), floatArrayOf(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), 0.8f) + baked.assertFace(Directions.SOUTH, positions(Directions.SOUTH, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.8f) + baked.assertFace(Directions.WEST, positions(Directions.WEST, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.6f) + baked.assertFace(Directions.EAST, positions(Directions.EAST, from, to), floatArrayOf(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), 0.6f) + } + + fun y90Rotation1() { + val from = Vec3(0.0f) + val to = Vec3(1.0f) + val model = SingleBlockStateApply(BlockModel(elements = listOf(ModelElement(from, to, faces = createFaces(rotation = 1))), textures = mapOf("test" to minecraft("block/test").texture())), y = 1, uvLock = true) + + val baked = model.bake(createTextureManager("block/test"))!! + + baked.assertFace(Directions.DOWN, positions(Directions.DOWN, from, to), floatArrayOf(0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f), 0.5f) + baked.assertFace(Directions.UP, positions(Directions.UP, from, to), floatArrayOf(1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), 1.0f) + baked.assertFace(Directions.NORTH, positions(Directions.NORTH, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.8f) + baked.assertFace(Directions.SOUTH, positions(Directions.SOUTH, from, to), floatArrayOf(0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f), 0.8f) + baked.assertFace(Directions.WEST, positions(Directions.WEST, from, to), floatArrayOf(0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f), 0.6f) + baked.assertFace(Directions.EAST, positions(Directions.EAST, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.6f) + } + + fun x90() { + val from = Vec3(0.0f) + val to = Vec3(1.0f) + val model = SingleBlockStateApply(BlockModel(elements = listOf(ModelElement(from, to, faces = createFaces())), textures = mapOf("test" to minecraft("block/test").texture())), x = 1, uvLock = true) + + val baked = model.bake(createTextureManager("block/test"))!! + + baked.assertFace(Directions.DOWN, positions(Directions.DOWN, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.5f) + baked.assertFace(Directions.UP, positions(Directions.UP, from, to), floatArrayOf(0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f), 1.0f) + baked.assertFace(Directions.NORTH, positions(Directions.NORTH, from, to), floatArrayOf(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), 0.8f) + baked.assertFace(Directions.SOUTH, positions(Directions.SOUTH, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.8f) + baked.assertFace(Directions.WEST, positions(Directions.WEST, from, to), floatArrayOf(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f), 0.6f) + baked.assertFace(Directions.EAST, positions(Directions.EAST, from, to), floatArrayOf(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), 0.6f) + } +}