diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java index 801dab17a..22092e6ca 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/VecBuffer.java @@ -89,6 +89,14 @@ public class VecBuffer { return this; } + public VecBuffer putColor(int r, int g, int b, int a) { + internal.put((byte) r); + internal.put((byte) g); + internal.put((byte) b); + internal.put((byte) a); + return this; + } + public VecBuffer putVec3(float x, float y, float z) { internal.putFloat(x); internal.putFloat(y); diff --git a/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java b/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java index 5fe981d58..13cbf1833 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java @@ -84,6 +84,8 @@ public class PartBuilder { float posY2; float posZ2; + boolean invertYZ; + final PartBuilder partBuilder; CuboidBuilder(PartBuilder partBuilder) { @@ -123,6 +125,16 @@ public class PartBuilder { return this; } + /** + * Pulls the cuboid "inside out" through the Y and Z axes. + * + * See the {@link com.jozufozu.flywheel.vanilla.SignInstance sign} renderer for the use case. + */ + public CuboidBuilder invertYZ() { + this.invertYZ = true; + return this; + } + public PartBuilder endCuboid() { return partBuilder.addCuboid(this); } @@ -137,14 +149,21 @@ public class PartBuilder { float sizeY = posY2 - posY1; float sizeZ = posZ2 - posZ1; - Vector3f lll = new Vector3f(posX1 / 16f, posY1 / 16f, posZ1 / 16f); - Vector3f hll = new Vector3f(posX2 / 16f, posY1 / 16f, posZ1 / 16f); - Vector3f hhl = new Vector3f(posX2 / 16f, posY2 / 16f, posZ1 / 16f); - Vector3f lhl = new Vector3f(posX1 / 16f, posY2 / 16f, posZ1 / 16f); - Vector3f llh = new Vector3f(posX1 / 16f, posY1 / 16f, posZ2 / 16f); - Vector3f hlh = new Vector3f(posX2 / 16f, posY1 / 16f, posZ2 / 16f); - Vector3f hhh = new Vector3f(posX2 / 16f, posY2 / 16f, posZ2 / 16f); - Vector3f lhh = new Vector3f(posX1 / 16f, posY2 / 16f, posZ2 / 16f); + float posX1 = this.posX1 / 16f; + float posY1 = this.posY1 / 16f; + float posZ1 = this.posZ1 / 16f; + float posX2 = this.posX2 / 16f; + float posY2 = this.posY2 / 16f; + float posZ2 = this.posZ2 / 16f; + + Vector3f lll = new Vector3f(posX1, posY1, posZ1); + Vector3f hll = new Vector3f(posX2, posY1, posZ1); + Vector3f hhl = new Vector3f(posX2, posY2, posZ1); + Vector3f lhl = new Vector3f(posX1, posY2, posZ1); + Vector3f llh = new Vector3f(posX1, posY1, posZ2); + Vector3f hlh = new Vector3f(posX2, posY1, posZ2); + Vector3f hhh = new Vector3f(posX2, posY2, posZ2); + Vector3f lhh = new Vector3f(posX1, posY2, posZ2); float f4 = getU((float)textureOffsetU); float f5 = getU((float)textureOffsetU + sizeZ); float f6 = getU((float)textureOffsetU + sizeZ + sizeX); @@ -155,12 +174,21 @@ public class PartBuilder { float f11 = getV((float)textureOffsetV + sizeZ); float f12 = getV((float)textureOffsetV + sizeZ + sizeY); - quad(buffer, new Vector3f[]{hlh, llh, lll, hll}, f5, f10, f6, f11, Direction.DOWN); - quad(buffer, new Vector3f[]{hhl, lhl, lhh, hhh}, f6, f11, f7, f10, Direction.UP); - quad(buffer, new Vector3f[]{lll, llh, lhh, lhl}, f4, f11, f5, f12, Direction.WEST); - quad(buffer, new Vector3f[]{hll, lll, lhl, hhl}, f5, f11, f6, f12, Direction.NORTH); - quad(buffer, new Vector3f[]{hlh, hll, hhl, hhh}, f6, f11, f8, f12, Direction.EAST); - quad(buffer, new Vector3f[]{llh, hlh, hhh, lhh}, f8, f11, f9, f12, Direction.SOUTH); + if (invertYZ) { + quad(buffer, new Vector3f[]{hlh, llh, lll, hll}, f6, f11, f7, f10, Direction.DOWN); + quad(buffer, new Vector3f[]{hhl, lhl, lhh, hhh}, f5, f10, f6, f11, Direction.UP); + quad(buffer, new Vector3f[]{lll, llh, lhh, lhl}, f5, f12, f4, f11, Direction.WEST); + quad(buffer, new Vector3f[]{hll, lll, lhl, hhl}, f9, f12, f8, f11, Direction.NORTH); + quad(buffer, new Vector3f[]{hlh, hll, hhl, hhh}, f8, f12, f6, f11, Direction.EAST); + quad(buffer, new Vector3f[]{llh, hlh, hhh, lhh}, f6, f12, f5, f11, Direction.SOUTH); + } else { + quad(buffer, new Vector3f[]{hlh, llh, lll, hll}, f5, f10, f6, f11, Direction.DOWN); + quad(buffer, new Vector3f[]{hhl, lhl, lhh, hhh}, f6, f11, f7, f10, Direction.UP); + quad(buffer, new Vector3f[]{lll, llh, lhh, lhl}, f4, f11, f5, f12, Direction.WEST); + quad(buffer, new Vector3f[]{hll, lll, lhl, hhl}, f5, f11, f6, f12, Direction.NORTH); + quad(buffer, new Vector3f[]{hlh, hll, hhl, hhh}, f6, f11, f8, f12, Direction.EAST); + quad(buffer, new Vector3f[]{llh, hlh, hhh, lhh}, f8, f11, f9, f12, Direction.SOUTH); + } } diff --git a/src/main/java/com/jozufozu/flywheel/util/RenderUtil.java b/src/main/java/com/jozufozu/flywheel/util/RenderUtil.java index 4698835ad..2417604bb 100644 --- a/src/main/java/com/jozufozu/flywheel/util/RenderUtil.java +++ b/src/main/java/com/jozufozu/flywheel/util/RenderUtil.java @@ -10,6 +10,20 @@ import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Vector3f; public class RenderUtil { + + private static final Matrix4f IDENTITY = new Matrix4f(); + static { + IDENTITY.setIdentity(); + } + + public static Matrix4f getIdentity() { + return IDENTITY; + } + + public static Matrix4f copyIdentity() { + return IDENTITY.copy(); + } + public static int nextPowerOf2(int a) { int h = Integer.highestOneBit(a); return (h == a) ? h : (h << 1); diff --git a/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java b/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java index 93867511e..43e84469f 100644 --- a/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java +++ b/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java @@ -24,13 +24,21 @@ public class MatrixTransformStack implements TransformStack { return this; } + @Override + public TransformStack scale(float factor) { + internal.scale(factor, factor, factor); + return this; + } + @Override public TransformStack push() { + internal.pushPose(); return this; } @Override public TransformStack pop() { + internal.popPose(); return this; } } diff --git a/src/main/java/com/jozufozu/flywheel/util/transform/QuaternionTransformStack.java b/src/main/java/com/jozufozu/flywheel/util/transform/QuaternionTransformStack.java index 364371b72..3e6908201 100644 --- a/src/main/java/com/jozufozu/flywheel/util/transform/QuaternionTransformStack.java +++ b/src/main/java/com/jozufozu/flywheel/util/transform/QuaternionTransformStack.java @@ -41,6 +41,11 @@ public class QuaternionTransformStack implements TransformStack { return this; } + @Override + public TransformStack scale(float factor) { + return this; + } + @Override public TransformStack pop() { diff --git a/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java b/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java index e5c4addd2..23edcfcf8 100644 --- a/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java +++ b/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java @@ -13,6 +13,8 @@ public interface TransformStack { TransformStack multiply(Quaternion quaternion); + TransformStack scale(float factor); + TransformStack push(); TransformStack pop(); diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/VanillaInstances.java b/src/main/java/com/jozufozu/flywheel/vanilla/VanillaInstances.java index 36f6567ee..225cc5b30 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/VanillaInstances.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/VanillaInstances.java @@ -7,21 +7,21 @@ import net.minecraft.tileentity.TileEntityType; /** * TODO: * + * * - * * + * * * + * + * * * * * * * - * * - * - * * *
{@link TileEntityType#SHULKER_BOX} {@link net.minecraft.client.renderer.tileentity.ShulkerBoxTileEntityRenderer ShulkerBoxTileEntityRenderer}
{@link TileEntityType#SIGN} {@link net.minecraft.client.renderer.tileentity.SignTileEntityRenderer SignTileEntityRenderer}
{@link TileEntityType#MOB_SPAWNER} {@link net.minecraft.client.renderer.tileentity.MobSpawnerTileEntityRenderer MobSpawnerTileEntityRenderer}
{@link TileEntityType#PISTON} {@link net.minecraft.client.renderer.tileentity.PistonTileEntityRenderer PistonTileEntityRenderer}
{@link TileEntityType#CONDUIT} {@link net.minecraft.client.renderer.tileentity.ConduitTileEntityRenderer ConduitTileEntityRenderer}
{@link TileEntityType#ENCHANTING_TABLE} {@link net.minecraft.client.renderer.tileentity.EnchantmentTableTileEntityRenderer EnchantmentTableTileEntityRenderer}
{@link TileEntityType#LECTERN} {@link net.minecraft.client.renderer.tileentity.LecternTileEntityRenderer LecternTileEntityRenderer}
{@link TileEntityType#MOB_SPAWNER} {@link net.minecraft.client.renderer.tileentity.MobSpawnerTileEntityRenderer MobSpawnerTileEntityRenderer}
^^ Interesting - Major vv
{@link TileEntityType#END_PORTAL} {@link net.minecraft.client.renderer.tileentity.EndPortalTileEntityRenderer EndPortalTileEntityRenderer}
{@link TileEntityType#END_GATEWAY} {@link net.minecraft.client.renderer.tileentity.EndGatewayTileEntityRenderer EndGatewayTileEntityRenderer}
{@link TileEntityType#BEACON} {@link net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer BeaconTileEntityRenderer}
{@link TileEntityType#SKULL} {@link net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer SkullTileEntityRenderer}
{@link TileEntityType#BANNER} {@link net.minecraft.client.renderer.tileentity.BannerTileEntityRenderer BannerTileEntityRenderer}
{@link TileEntityType#STRUCTURE_BLOCK} {@link net.minecraft.client.renderer.tileentity.StructureTileEntityRenderer StructureTileEntityRenderer}
{@link TileEntityType#SHULKER_BOX} {@link net.minecraft.client.renderer.tileentity.ShulkerBoxTileEntityRenderer ShulkerBoxTileEntityRenderer}
{@link TileEntityType#BED} {@link net.minecraft.client.renderer.tileentity.BedTileEntityRenderer BedTileEntityRenderer}
{@link TileEntityType#CONDUIT} {@link net.minecraft.client.renderer.tileentity.ConduitTileEntityRenderer ConduitTileEntityRenderer}
{@link TileEntityType#BELL} {@link net.minecraft.client.renderer.tileentity.BellTileEntityRenderer BellTileEntityRenderer}
{@link TileEntityType#CAMPFIRE} {@link net.minecraft.client.renderer.tileentity.CampfireTileEntityRenderer CampfireTileEntityRenderer}
*/