mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-17 00:33:41 +01:00
Towards better normals.
- Easier SuperByteBuffer transform settings. - Some cleanup here and there.
This commit is contained in:
parent
e930e62436
commit
bb3fed2a3b
15 changed files with 182 additions and 141 deletions
|
@ -15,7 +15,7 @@ public class BackHalfShaftInstance extends HalfShaftInstance {
|
||||||
InstancedTileRenderRegistry.instance.register(type, BackHalfShaftInstance::new));
|
InstancedTileRenderRegistry.instance.register(type, BackHalfShaftInstance::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackHalfShaftInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
public BackHalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,13 @@ public class KineticData<D extends KineticData<D>> extends InstanceData {
|
||||||
return (D) this;
|
return (D) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public D nudge(float x, float y, float z) {
|
||||||
|
this.x += x;
|
||||||
|
this.y += y;
|
||||||
|
this.z += z;
|
||||||
|
return (D) this;
|
||||||
|
}
|
||||||
|
|
||||||
public D setBlockLight(int blockLight) {
|
public D setBlockLight(int blockLight) {
|
||||||
this.blockLight = (byte) ((blockLight & 0xF) << 4);
|
this.blockLight = (byte) ((blockLight & 0xF) << 4);
|
||||||
return (D) this;
|
return (D) this;
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntit
|
||||||
|
|
||||||
protected InstanceKey<RotatingData> rotatingModelKey;
|
protected InstanceKey<RotatingData> rotatingModelKey;
|
||||||
|
|
||||||
public SingleRotatingInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
public SingleRotatingInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class DrillInstance extends SingleRotatingInstance {
|
||||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
||||||
InstancedTileRenderRegistry.instance.register(type, DrillInstance::new)); }
|
InstancedTileRenderRegistry.instance.register(type, DrillInstance::new)); }
|
||||||
|
|
||||||
public DrillInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
public DrillInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,17 +32,16 @@ public class StickerRenderer extends SafeTileEntityRenderer<StickerTileEntity> {
|
||||||
offset = state.get(StickerBlock.EXTENDED) ? 1 : 0;
|
offset = state.get(StickerBlock.EXTENDED) ? 1 : 0;
|
||||||
|
|
||||||
Direction facing = state.get(StickerBlock.FACING);
|
Direction facing = state.get(StickerBlock.FACING);
|
||||||
ms.push();
|
head.matrixStacker()
|
||||||
MatrixStacker.of(ms)
|
|
||||||
.nudge(te.hashCode())
|
.nudge(te.hashCode())
|
||||||
.centre()
|
.centre()
|
||||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||||
.rotateX(AngleHelper.verticalAngle(facing) + 90)
|
.rotateX(AngleHelper.verticalAngle(facing) + 90)
|
||||||
.unCentre();
|
.unCentre()
|
||||||
ms.translate(0, (offset * offset) * 4 / 16f, 0);
|
.translate(0, (offset * offset) * 4 / 16f, 0);
|
||||||
|
|
||||||
head.light(light)
|
head.light(light)
|
||||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
ms.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||||
|
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.Iterate;
|
import com.simibubi.create.foundation.utility.Iterate;
|
||||||
|
@ -50,25 +51,20 @@ public class GantryPinionRenderer extends KineticTileEntityRenderer {
|
||||||
if (facing == Direction.NORTH || facing == Direction.EAST)
|
if (facing == Direction.NORTH || facing == Direction.EAST)
|
||||||
angleForTe *= -1;
|
angleForTe *= -1;
|
||||||
|
|
||||||
ms.push();
|
SuperByteBuffer cogs = AllBlockPartials.GANTRY_COGS.renderOn(state);
|
||||||
|
cogs.matrixStacker()
|
||||||
MatrixStacker msr = MatrixStacker.of(ms);
|
.centre()
|
||||||
|
|
||||||
msr.centre()
|
|
||||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||||
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
||||||
.rotateY(alongFirst ^ facing.getAxis() == Axis.Z ? 90 : 0);
|
.rotateY(alongFirst ^ facing.getAxis() == Axis.Z ? 90 : 0)
|
||||||
|
.translate(0, -9 / 16f, 0)
|
||||||
|
.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(-angleForTe))
|
||||||
|
.translate(0, 9 / 16f, 0)
|
||||||
|
.unCentre();
|
||||||
|
|
||||||
ms.translate(0, -9 / 16f, 0);
|
cogs.light(light)
|
||||||
ms.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(-angleForTe));
|
|
||||||
ms.translate(0, 9 / 16f, 0);
|
|
||||||
|
|
||||||
msr.unCentre();
|
|
||||||
AllBlockPartials.GANTRY_COGS.renderOn(state)
|
|
||||||
.light(light)
|
|
||||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
|
|
||||||
ms.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) {
|
public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) {
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
|
||||||
|
|
||||||
public class ContraptionRenderer {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -71,11 +71,11 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||||
boolean sideways = beltSlope == BeltSlope.SIDEWAYS;
|
boolean sideways = beltSlope == BeltSlope.SIDEWAYS;
|
||||||
boolean alongX = facing.getAxis() == Axis.X;
|
boolean alongX = facing.getAxis() == Axis.X;
|
||||||
|
|
||||||
MatrixStacker msr = MatrixStacker.of(ms);
|
MatrixStack localTransforms = new MatrixStack();
|
||||||
|
MatrixStacker msr = MatrixStacker.of(localTransforms);
|
||||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
float renderTick = AnimationTickHolder.getRenderTime();
|
float renderTick = AnimationTickHolder.getRenderTime();
|
||||||
|
|
||||||
ms.push();
|
|
||||||
msr.centre();
|
msr.centre();
|
||||||
msr.rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0));
|
msr.rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0));
|
||||||
msr.rotateZ(sideways ? 90 : 0);
|
msr.rotateZ(sideways ? 90 : 0);
|
||||||
|
@ -117,12 +117,13 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||||
beltBuffer.shiftUVScrolling(spriteShift, (float) scroll);
|
beltBuffer.shiftUVScrolling(spriteShift, (float) scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
beltBuffer.renderInto(ms, vb);
|
beltBuffer
|
||||||
|
.transform(localTransforms)
|
||||||
|
.renderInto(ms, vb);
|
||||||
|
|
||||||
// Diagonal belt do not have a separate bottom model
|
// Diagonal belt do not have a separate bottom model
|
||||||
if (diagonal) break;
|
if (diagonal) break;
|
||||||
}
|
}
|
||||||
ms.pop();
|
|
||||||
|
|
||||||
if (te.hasPulley()) {
|
if (te.hasPulley()) {
|
||||||
// TODO 1.15 find a way to cache this model matrix computation
|
// TODO 1.15 find a way to cache this model matrix computation
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class ShaftInstance extends SingleRotatingInstance {
|
||||||
InstancedTileRenderRegistry.instance.register(type, ShaftInstance::new));
|
InstancedTileRenderRegistry.instance.register(type, ShaftInstance::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShaftInstance(InstancedTileRenderer dispatcher, KineticTileEntity tile) {
|
public ShaftInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
||||||
ArmTileEntity arm = (ArmTileEntity) te;
|
ArmTileEntity arm = (ArmTileEntity) te;
|
||||||
IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid());
|
IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid());
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
MatrixStacker msr = MatrixStacker.of(ms);
|
|
||||||
|
MatrixStack msLocal = new MatrixStack();
|
||||||
|
MatrixStacker msr = MatrixStacker.of(msLocal);
|
||||||
int color = 0xFFFFFF;
|
int color = 0xFFFFFF;
|
||||||
|
|
||||||
float baseAngle = arm.baseAngle.get(pt);
|
float baseAngle = arm.baseAngle.get(pt);
|
||||||
|
@ -59,8 +61,6 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
||||||
color = ColorHelper.rainbowColor(AnimationTickHolder.getTicks() * 100);
|
color = ColorHelper.rainbowColor(AnimationTickHolder.getTicks() * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.push();
|
|
||||||
|
|
||||||
SuperByteBuffer base = AllBlockPartials.ARM_BASE.renderOn(blockState).light(light);
|
SuperByteBuffer base = AllBlockPartials.ARM_BASE.renderOn(blockState).light(light);
|
||||||
SuperByteBuffer lowerBody = AllBlockPartials.ARM_LOWER_BODY.renderOn(blockState).light(light);
|
SuperByteBuffer lowerBody = AllBlockPartials.ARM_LOWER_BODY.renderOn(blockState).light(light);
|
||||||
SuperByteBuffer upperBody = AllBlockPartials.ARM_UPPER_BODY.renderOn(blockState).light(light);
|
SuperByteBuffer upperBody = AllBlockPartials.ARM_UPPER_BODY.renderOn(blockState).light(light);
|
||||||
|
@ -73,27 +73,32 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
||||||
if (blockState.get(ArmBlock.CEILING))
|
if (blockState.get(ArmBlock.CEILING))
|
||||||
msr.rotateX(180);
|
msr.rotateX(180);
|
||||||
|
|
||||||
ms.translate(0, 4 / 16d, 0);
|
msLocal.translate(0, 4 / 16d, 0);
|
||||||
msr.rotateY(baseAngle);
|
msr.rotateY(baseAngle);
|
||||||
base.renderInto(ms, builder);
|
base.transform(msLocal)
|
||||||
|
|
||||||
ms.translate(0, 1 / 16d, -2 / 16d);
|
|
||||||
msr.rotateX(lowerArmAngle);
|
|
||||||
ms.translate(0, -1 / 16d, 0);
|
|
||||||
lowerBody.color(color)
|
|
||||||
.renderInto(ms, builder);
|
.renderInto(ms, builder);
|
||||||
|
|
||||||
ms.translate(0, 12 / 16d, 12 / 16d);
|
msLocal.translate(0, 1 / 16d, -2 / 16d);
|
||||||
|
msr.rotateX(lowerArmAngle);
|
||||||
|
msLocal.translate(0, -1 / 16d, 0);
|
||||||
|
lowerBody.color(color)
|
||||||
|
.transform(msLocal)
|
||||||
|
.renderInto(ms, builder);
|
||||||
|
|
||||||
|
msLocal.translate(0, 12 / 16d, 12 / 16d);
|
||||||
msr.rotateX(upperArmAngle);
|
msr.rotateX(upperArmAngle);
|
||||||
upperBody.color(color)
|
upperBody.color(color)
|
||||||
|
.transform(msLocal)
|
||||||
.renderInto(ms, builder);
|
.renderInto(ms, builder);
|
||||||
|
|
||||||
ms.translate(0, 11 / 16d, -11 / 16d);
|
msLocal.translate(0, 11 / 16d, -11 / 16d);
|
||||||
msr.rotateX(headAngle);
|
msr.rotateX(headAngle);
|
||||||
head.renderInto(ms, builder);
|
head.transform(msLocal)
|
||||||
|
.renderInto(ms, builder);
|
||||||
|
|
||||||
ms.translate(0, 0, -4 / 16d);
|
msLocal.translate(0, 0, -4 / 16d);
|
||||||
claw.renderInto(ms, builder);
|
claw.transform(msLocal)
|
||||||
|
.renderInto(ms, builder);
|
||||||
ItemStack item = arm.heldItem;
|
ItemStack item = arm.heldItem;
|
||||||
ItemRenderer itemRenderer = Minecraft.getInstance()
|
ItemRenderer itemRenderer = Minecraft.getInstance()
|
||||||
.getItemRenderer();
|
.getItemRenderer();
|
||||||
|
@ -103,23 +108,27 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
||||||
.isGui3d();
|
.isGui3d();
|
||||||
|
|
||||||
for (int flip : Iterate.positiveAndNegative) {
|
for (int flip : Iterate.positiveAndNegative) {
|
||||||
ms.push();
|
msLocal.push();
|
||||||
ms.translate(0, flip * 3 / 16d, -1 / 16d);
|
msLocal.translate(0, flip * 3 / 16d, -1 / 16d);
|
||||||
msr.rotateX(flip * (hasItem ? isBlockItem ? 0 : -35 : 0));
|
msr.rotateX(flip * (hasItem ? isBlockItem ? 0 : -35 : 0));
|
||||||
clawGrip.light(light).renderInto(ms, builder);
|
clawGrip.light(light).transform(msLocal).renderInto(ms, builder);
|
||||||
ms.pop();
|
msLocal.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasItem) {
|
if (hasItem) {
|
||||||
|
ms.push();
|
||||||
float itemScale = isBlockItem ? .5f : .625f;
|
float itemScale = isBlockItem ? .5f : .625f;
|
||||||
msr.rotateX(90);
|
msr.rotateX(90);
|
||||||
ms.translate(0, -4 / 16f, 0);
|
msLocal.translate(0, -4 / 16f, 0);
|
||||||
ms.scale(itemScale, itemScale, itemScale);
|
msLocal.scale(itemScale, itemScale, itemScale);
|
||||||
|
|
||||||
|
ms.peek().getModel().multiply(msLocal.peek().getModel());
|
||||||
|
|
||||||
itemRenderer
|
itemRenderer
|
||||||
.renderItem(item, TransformType.FIXED, light, overlay, ms, buffer);
|
.renderItem(item, TransformType.FIXED, light, overlay, ms, buffer);
|
||||||
|
ms.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,7 +42,6 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
|
||||||
|
|
||||||
double yaw = 0;
|
double yaw = 0;
|
||||||
double pitch = 40;
|
double pitch = 40;
|
||||||
double recoil = 0;
|
|
||||||
|
|
||||||
BlockPos pos = tileEntityIn.getPos();
|
BlockPos pos = tileEntityIn.getPos();
|
||||||
if (tileEntityIn.target != null) {
|
if (tileEntityIn.target != null) {
|
||||||
|
@ -67,7 +66,34 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tileEntityIn.flyingBlocks.isEmpty()) {
|
double recoil = !tileEntityIn.flyingBlocks.isEmpty() ? getRecoil(tileEntityIn, partialTicks, ms, buffer, light, overlay) : 0;
|
||||||
|
|
||||||
|
ms.push();
|
||||||
|
BlockState state = tileEntityIn.getBlockState();
|
||||||
|
int lightCoords = WorldRenderer.getLightmapCoordinates(tileEntityIn.getWorld(), pos);
|
||||||
|
|
||||||
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
|
|
||||||
|
SuperByteBuffer connector = AllBlockPartials.SCHEMATICANNON_CONNECTOR.renderOn(state);
|
||||||
|
connector.translate(.5f, 0, .5f);
|
||||||
|
connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
|
||||||
|
connector.translate(-.5f, 0, -.5f);
|
||||||
|
connector.light(lightCoords).renderInto(ms, vb);
|
||||||
|
|
||||||
|
SuperByteBuffer pipe = AllBlockPartials.SCHEMATICANNON_PIPE.renderOn(state);
|
||||||
|
pipe.translate(.5f, 15 / 16f, .5f);
|
||||||
|
pipe.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
|
||||||
|
pipe.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI));
|
||||||
|
pipe.translate(-.5f, -15 / 16f, -.5f);
|
||||||
|
pipe.translate(0, -recoil / 100, 0);
|
||||||
|
pipe.light(lightCoords).renderInto(ms, vb);
|
||||||
|
|
||||||
|
ms.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getRecoil(SchematicannonTileEntity tileEntityIn, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||||
|
double recoil = 0;
|
||||||
|
|
||||||
for (LaunchedItem launched : tileEntityIn.flyingBlocks) {
|
for (LaunchedItem launched : tileEntityIn.flyingBlocks) {
|
||||||
|
|
||||||
if (launched.ticksRemaining == 0)
|
if (launched.ticksRemaining == 0)
|
||||||
|
@ -103,16 +129,14 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
|
||||||
if (launched instanceof ForBlockState) {
|
if (launched instanceof ForBlockState) {
|
||||||
float scale = .3f;
|
float scale = .3f;
|
||||||
ms.scale(scale, scale, scale);
|
ms.scale(scale, scale, scale);
|
||||||
Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(((ForBlockState) launched).state,
|
Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(((ForBlockState) launched).state, ms, buffer, light, overlay, EmptyModelData.INSTANCE);
|
||||||
ms, buffer, light, overlay, EmptyModelData.INSTANCE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the item
|
// Render the item
|
||||||
if (launched instanceof ForEntity) {
|
if (launched instanceof ForEntity) {
|
||||||
float scale = 1.2f;
|
float scale = 1.2f;
|
||||||
ms.scale(scale, scale, scale);
|
ms.scale(scale, scale, scale);
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem(launched.stack, TransformType.GROUND, light,
|
Minecraft.getInstance().getItemRenderer().renderItem(launched.stack, TransformType.GROUND, light, overlay, ms, buffer);
|
||||||
overlay, ms, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.pop();
|
ms.pop();
|
||||||
|
@ -138,29 +162,8 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ms.push();
|
return recoil;
|
||||||
BlockState state = tileEntityIn.getBlockState();
|
|
||||||
int lightCoords = WorldRenderer.getLightmapCoordinates(tileEntityIn.getWorld(), pos);
|
|
||||||
|
|
||||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
|
||||||
|
|
||||||
SuperByteBuffer connector = AllBlockPartials.SCHEMATICANNON_CONNECTOR.renderOn(state);
|
|
||||||
connector.translate(.5f, 0, .5f);
|
|
||||||
connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
|
|
||||||
connector.translate(-.5f, 0, -.5f);
|
|
||||||
connector.light(lightCoords).renderInto(ms, vb);
|
|
||||||
|
|
||||||
SuperByteBuffer pipe = AllBlockPartials.SCHEMATICANNON_PIPE.renderOn(state);
|
|
||||||
pipe.translate(.5f, 15 / 16f, .5f);
|
|
||||||
pipe.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
|
|
||||||
pipe.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI));
|
|
||||||
pipe.translate(-.5f, -15 / 16f, -.5f);
|
|
||||||
pipe.translate(0, -recoil / 100, 0);
|
|
||||||
pipe.light(lightCoords).renderInto(ms, vb);
|
|
||||||
|
|
||||||
ms.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,6 @@ public class ClientEvents {
|
||||||
if (!isGameActive())
|
if (!isGameActive())
|
||||||
return;
|
return;
|
||||||
TurntableHandler.gameRenderTick();
|
TurntableHandler.gameRenderTick();
|
||||||
ContraptionRenderDispatcher.renderTick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean isGameActive() {
|
protected static boolean isGameActive() {
|
||||||
|
|
|
@ -8,17 +8,15 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2DoubleMap;
|
import it.unimi.dsi.fastutil.longs.Long2DoubleMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.*;
|
||||||
import net.minecraft.client.renderer.Matrix3f;
|
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
|
||||||
import net.minecraft.client.renderer.Vector3f;
|
|
||||||
import net.minecraft.client.renderer.Vector4f;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.LightType;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||||
|
@ -107,13 +105,16 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||||
float staticDiffuse = LightUtil.diffuseLight(normalX, normalY, normalZ);
|
float staticDiffuse = LightUtil.diffuseLight(normalX, normalY, normalZ);
|
||||||
normal.set(normalX, normalY, normalZ);
|
normal.set(normalX, normalY, normalZ);
|
||||||
normal.transform(normalMat);
|
normal.transform(normalMat);
|
||||||
float instanceDiffuse = LightUtil.diffuseLight(normal.getX(), normal.getY(), normal.getZ());
|
float nx = normal.getX();
|
||||||
|
float ny = normal.getY();
|
||||||
|
float nz = normal.getZ();
|
||||||
|
float instanceDiffuse = LightUtil.diffuseLight(nx, ny, nz);
|
||||||
|
|
||||||
pos.set(x, y, z, 1F);
|
pos.set(x, y, z, 1F);
|
||||||
pos.transform(modelMat);
|
pos.transform(modelMat);
|
||||||
builder.vertex(pos.getX(), pos.getY(), pos.getZ());
|
builder.vertex(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
|
||||||
//builder.color((byte) Math.max(0, normal.getX() * 255), (byte) Math.max(0, normal.getY() * 255), (byte) Math.max(0, normal.getZ() * 255), a);
|
//builder.color((byte) Math.max(0, nx * 255), (byte) Math.max(0, ny * 255), (byte) Math.max(0, nz * 255), a);
|
||||||
if (shouldColor) {
|
if (shouldColor) {
|
||||||
//float lum = (r < 0 ? 255 + r : r) / 256f;
|
//float lum = (r < 0 ? 255 + r : r) / 256f;
|
||||||
int colorR = Math.min(255, (int) (((float) this.r) * instanceDiffuse));
|
int colorR = Math.min(255, (int) (((float) this.r) * instanceDiffuse));
|
||||||
|
@ -152,7 +153,7 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||||
} else
|
} else
|
||||||
builder.light(getLight(buffer, i));
|
builder.light(getLight(buffer, i));
|
||||||
|
|
||||||
builder.normal(normal.getX(), normal.getY(), normal.getZ())
|
builder.normal(nx, ny, nz)
|
||||||
.endVertex();
|
.endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +165,14 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||||
otherBlockLight = -1;
|
otherBlockLight = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MatrixStacker matrixStacker() {
|
||||||
|
return MatrixStacker.of(transforms);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer translate(Vec3d vec) {
|
||||||
|
return translate(vec.x, vec.y, vec.z);
|
||||||
|
}
|
||||||
|
|
||||||
public SuperByteBuffer translate(double x, double y, double z) {
|
public SuperByteBuffer translate(double x, double y, double z) {
|
||||||
return translate((float) x, (float) y, (float) z);
|
return translate((float) x, (float) y, (float) z);
|
||||||
}
|
}
|
||||||
|
@ -173,6 +182,12 @@ public class SuperByteBuffer extends TemplateBuffer {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer transform(MatrixStack stack) {
|
||||||
|
transforms.peek().getModel().multiply(stack.peek().getModel());
|
||||||
|
transforms.peek().getNormal().multiply(stack.peek().getNormal());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public SuperByteBuffer rotate(Direction axis, float radians) {
|
public SuperByteBuffer rotate(Direction axis, float radians) {
|
||||||
if (radians == 0)
|
if (radians == 0)
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -77,6 +77,14 @@ public abstract class InstancedModel<D extends InstanceData> extends BufferedMod
|
||||||
key.invalidate();
|
key.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public D getInstance(InstanceKey<D> key) {
|
||||||
|
verifyKey(key);
|
||||||
|
|
||||||
|
markIndexChanged(key.index);
|
||||||
|
|
||||||
|
return this.data.get(key.index);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void modifyInstance(InstanceKey<D> key, Consumer<D> edit) {
|
public synchronized void modifyInstance(InstanceKey<D> key, Consumer<D> edit) {
|
||||||
verifyKey(key);
|
verifyKey(key);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.foundation.utility;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.Quaternion;
|
||||||
import net.minecraft.client.renderer.Vector3f;
|
import net.minecraft.client.renderer.Vector3f;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -10,7 +11,7 @@ import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
public class MatrixStacker {
|
public class MatrixStacker {
|
||||||
|
|
||||||
static Vec3d center = VecHelper.getCenterOf(BlockPos.ZERO);
|
public static final Vec3d center = VecHelper.getCenterOf(BlockPos.ZERO);
|
||||||
static MatrixStacker instance;
|
static MatrixStacker instance;
|
||||||
|
|
||||||
MatrixStack ms;
|
MatrixStack ms;
|
||||||
|
@ -63,6 +64,16 @@ public class MatrixStacker {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MatrixStacker translate(double x, double y, double z) {
|
||||||
|
ms.translate(x, y, z);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MatrixStacker multiply(Quaternion quaternion) {
|
||||||
|
ms.multiply(quaternion);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public MatrixStacker nudge(int id) {
|
public MatrixStacker nudge(int id) {
|
||||||
long randomBits = (long) id * 493286711L;
|
long randomBits = (long) id * 493286711L;
|
||||||
randomBits = randomBits * randomBits * 4392167121L + randomBits * 98761L;
|
randomBits = randomBits * randomBits * 4392167121L + randomBits * 98761L;
|
||||||
|
|
Loading…
Reference in a new issue