mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Utilities created during an attempt at signs
- Cuboids can be inverted across Y and Z - TransformStack scaling - VecBuffer coloring
This commit is contained in:
parent
b0d317f9a2
commit
04b906d06f
7 changed files with 83 additions and 18 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,11 @@ public class QuaternionTransformStack implements TransformStack {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformStack scale(float factor) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformStack pop() {
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ public interface TransformStack {
|
|||
|
||||
TransformStack multiply(Quaternion quaternion);
|
||||
|
||||
TransformStack scale(float factor);
|
||||
|
||||
TransformStack push();
|
||||
|
||||
TransformStack pop();
|
||||
|
|
|
@ -7,21 +7,21 @@ import net.minecraft.tileentity.TileEntityType;
|
|||
/**
|
||||
* TODO:
|
||||
* <table>
|
||||
* <tr><td>{@link TileEntityType#SHULKER_BOX}</td><td> {@link net.minecraft.client.renderer.tileentity.ShulkerBoxTileEntityRenderer ShulkerBoxTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#SIGN}</td><td> {@link net.minecraft.client.renderer.tileentity.SignTileEntityRenderer SignTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#MOB_SPAWNER}</td><td> {@link net.minecraft.client.renderer.tileentity.MobSpawnerTileEntityRenderer MobSpawnerTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#PISTON}</td><td> {@link net.minecraft.client.renderer.tileentity.PistonTileEntityRenderer PistonTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#CONDUIT}</td><td> {@link net.minecraft.client.renderer.tileentity.ConduitTileEntityRenderer ConduitTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#ENCHANTING_TABLE}</td><td> {@link net.minecraft.client.renderer.tileentity.EnchantmentTableTileEntityRenderer EnchantmentTableTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#LECTERN}</td><td> {@link net.minecraft.client.renderer.tileentity.LecternTileEntityRenderer LecternTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#MOB_SPAWNER}</td><td> {@link net.minecraft.client.renderer.tileentity.MobSpawnerTileEntityRenderer MobSpawnerTileEntityRenderer}</td></tr>
|
||||
* <tr><td>^^ Interesting - Major vv</td></tr>
|
||||
* <tr><td>{@link TileEntityType#END_PORTAL}</td><td> {@link net.minecraft.client.renderer.tileentity.EndPortalTileEntityRenderer EndPortalTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#END_GATEWAY}</td><td> {@link net.minecraft.client.renderer.tileentity.EndGatewayTileEntityRenderer EndGatewayTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#BEACON}</td><td> {@link net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer BeaconTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#SKULL}</td><td> {@link net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer SkullTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#BANNER}</td><td> {@link net.minecraft.client.renderer.tileentity.BannerTileEntityRenderer BannerTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#STRUCTURE_BLOCK}</td><td> {@link net.minecraft.client.renderer.tileentity.StructureTileEntityRenderer StructureTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#SHULKER_BOX}</td><td> {@link net.minecraft.client.renderer.tileentity.ShulkerBoxTileEntityRenderer ShulkerBoxTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#BED}</td><td> {@link net.minecraft.client.renderer.tileentity.BedTileEntityRenderer BedTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#CONDUIT}</td><td> {@link net.minecraft.client.renderer.tileentity.ConduitTileEntityRenderer ConduitTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#BELL}</td><td> {@link net.minecraft.client.renderer.tileentity.BellTileEntityRenderer BellTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#CAMPFIRE}</td><td> {@link net.minecraft.client.renderer.tileentity.CampfireTileEntityRenderer CampfireTileEntityRenderer}</td></tr>
|
||||
* </table>
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue