diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/rotation/XRotationTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/rotation/XRotationTest.kt index 2f9256838..4797a3c18 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/rotation/XRotationTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/rotation/XRotationTest.kt @@ -118,7 +118,4 @@ class XRotationTest { bake(2).assertFace(Directions.EAST, block(10, 0, 0, 10, 0, 10, 10, 16, 10, 10, 16, 0)) bake(3).assertFace(Directions.EAST, block(10, 0, 0, 10, 0, 16, 10, 10, 16, 10, 10, 0)) } - - - // TODO: combined (x;y) } diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/rotation/XYRotationTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/rotation/XYRotationTest.kt new file mode 100644 index 000000000..05621e902 --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/models/baked/rotation/XYRotationTest.kt @@ -0,0 +1,60 @@ +/* + * 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.rotation + +import de.bixilon.kotlinglm.vec3.Vec3 +import de.bixilon.minosoft.data.direction.Directions +import de.bixilon.minosoft.data.registries.identified.Namespaces +import de.bixilon.minosoft.gui.rendering.models.ModelTestUtil.block +import de.bixilon.minosoft.gui.rendering.models.baked.BakedModelTestUtil +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.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.textures.TextureUtil.texture +import org.testng.annotations.Test + +@Test(groups = ["models"]) +class XYRotationTest { + + + fun `x=90_y=90`() { + val from = Vec3(6, 0, 6) / ModelElement.BLOCK_SIZE + val to = Vec3(10, 16, 16) / ModelElement.BLOCK_SIZE + + val model = SingleBlockStateApply(BlockModel(elements = listOf(ModelElement(from, to, faces = createFaces(from, to))), textures = mapOf("test" to Namespaces.minecraft("block/test").texture())), x = 1, y = 1) + + val baked = model.bake(BakedModelTestUtil.createTextureManager("block/test"))!! + baked.assertFace(Directions.DOWN, block(0, 6, 6, 0, 6, 10, 16, 6, 10, 16, 6, 6)) + baked.assertFace(Directions.UP, block(0, 16, 6, 16, 16, 6, 16, 16, 10, 0, 16, 10)) + baked.assertFace(Directions.NORTH, block(0, 6, 6, 16, 6, 6, 16, 16, 6, 0, 16, 6)) + baked.assertFace(Directions.SOUTH, block(0, 6, 10, 0, 16, 10, 16, 16, 10, 16, 6, 10)) + baked.assertFace(Directions.WEST, block(16, 6, 6, 16, 16, 6, 16, 16, 10, 16, 6, 10)) + baked.assertFace(Directions.EAST, block(0, 6, 6, 0, 6, 10, 0, 16, 10, 0, 16, 6)) + } + + fun `x=90_y=270`() { + val from = Vec3(6, 0, 6) / ModelElement.BLOCK_SIZE + val to = Vec3(10, 16, 16) / ModelElement.BLOCK_SIZE + + val model = SingleBlockStateApply(BlockModel(elements = listOf(ModelElement(from, to, faces = createFaces(from, to))), textures = mapOf("test" to Namespaces.minecraft("block/test").texture())), x = 1, y = 3) + + val baked = model.bake(BakedModelTestUtil.createTextureManager("block/test"))!! + baked.assertFace(Directions.DOWN, block(0, 6, 6, 0, 6, 10, 16, 6, 10, 16, 6, 6)) + baked.assertFace(Directions.UP, block(0, 16, 6, 16, 16, 6, 16, 16, 10, 6, 16, 10)) + } + + // TODO: 90x180, 90x270, 180x90, 180x180, 180x270, 270x90, 270x180, 270x270 +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/apply/SingleBlockStateApply.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/apply/SingleBlockStateApply.kt index deb9f963d..865053d36 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/apply/SingleBlockStateApply.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/apply/SingleBlockStateApply.kt @@ -119,13 +119,14 @@ data class SingleBlockStateApply( val texture = face.createTexture(model, textures) val rotatedDirection = direction - .rotateY(this.y) .rotateX(this.x) + .rotateY(this.y) val positions = positions(direction, element.from, element.to) - .rotateY(direction) .rotateX(direction) + .rotateY(direction.rotateX(this.x)) + var uv = face.uv.toArray(rotatedDirection, face.rotation) if (direction.axis == Axes.Y && y != 0 && !uvLock) {