Stop hacking the base plate size

- Added proper scene scale/alignment instructions
This commit is contained in:
simibubi 2021-03-11 13:48:31 +01:00
parent d1e96c3b4b
commit 4445872959
10 changed files with 132 additions and 41 deletions

View file

@ -76,9 +76,11 @@ public class PonderScene {
WorldSectionElement baseWorldSection;
Entity renderViewEntity;
int offsetX;
int offsetZ;
int size;
int basePlateOffsetX;
int basePlateOffsetZ;
int basePlateSize;
float scaleFactor;
float yOffset;
boolean stoppedCounting;
int totalTime;
@ -98,10 +100,12 @@ public class PonderScene {
schedule = new ArrayList<>();
activeSchedule = new ArrayList<>();
transform = new SceneTransform();
size = getBounds().getXSize();
basePlateSize = getBounds().getXSize();
info = new SceneRenderInfo();
baseWorldSection = new WorldSectionElement();
renderViewEntity = new ArmorStandEntity(world, 0, 0, 0);
scaleFactor = 1;
yOffset = 0;
setPointOfInterest(new Vec3d(0, 4, 0));
}
@ -136,11 +140,12 @@ public class PonderScene {
BlockPos selectedPos = nearestHit.getValue()
.getSecond();
BlockPos origin = new BlockPos(offsetX, 0, offsetZ);
BlockPos origin = new BlockPos(basePlateOffsetX, 0, basePlateOffsetZ);
if (!world.getBounds()
.isVecInside(selectedPos))
return Pair.of(ItemStack.EMPTY, null);
if (new MutableBoundingBox(origin, origin.add(new Vec3i(size - 1, 0, size - 1))).isVecInside(selectedPos)) {
if (new MutableBoundingBox(origin, origin.add(new Vec3i(basePlateSize - 1, 0, basePlateSize - 1)))
.isVecInside(selectedPos)) {
if (PonderIndex.EDITOR_MODE)
nearestHit.getValue()
.getFirst()
@ -383,11 +388,11 @@ public class PonderScene {
}
public MatrixStack apply(MatrixStack ms) {
return apply(ms, AnimationTickHolder.getPartialTicks());
return apply(ms, AnimationTickHolder.getPartialTicks(world));
}
public MatrixStack apply(MatrixStack ms, float pt) {
ms.translate(width / 2, height / 2, 200);
ms.translate(width / 2, height / 2, 200 + offset);
MatrixStacker.of(ms)
.rotateX(-35)
@ -396,12 +401,15 @@ public class PonderScene {
MatrixStacker.of(ms)
.rotateY(-55)
.rotateX(35);
MatrixStacker.of(ms)
.rotateX(xRotation.getValue(pt))
.rotateY(yRotation.getValue(pt));
ms.scale(30, -30, 30);
ms.translate((size + offsetX) / -2f, -1f, (size + offsetZ) / -2f);
float f = 30 * scaleFactor;
ms.scale(f, -f, f);
ms.translate((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset,
(basePlateSize + basePlateOffsetZ) / -2f);
return ms;
}
@ -416,7 +424,7 @@ public class PonderScene {
float pt = AnimationTickHolder.getPartialTicks();
Vec3d vec = new Vec3d(x, y, depth);
vec = vec.subtract(width / 2, height / 2, 200);
vec = vec.subtract(width / 2, height / 2, 200 + offset);
vec = VecHelper.rotate(vec, 35, Axis.X);
vec = VecHelper.rotate(vec, -55, Axis.Y);
vec = vec.subtract(offset, 0, 0);
@ -424,8 +432,12 @@ public class PonderScene {
vec = VecHelper.rotate(vec, -35, Axis.X);
vec = VecHelper.rotate(vec, -xRotation.getValue(pt), Axis.X);
vec = VecHelper.rotate(vec, -yRotation.getValue(pt), Axis.Y);
vec = vec.mul(1f / 30, 1f / -30, 1f / 30);
vec = vec.subtract((size + offsetX) / -2f, -1f, (size + offsetZ) / -2f);
float f = 1f / (30 * scaleFactor);
vec = vec.mul(f, -f, f);
vec = vec.subtract((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset,
(basePlateSize + basePlateOffsetZ) / -2f);
return vec;
}

View file

@ -24,7 +24,6 @@ import com.simibubi.create.foundation.ponder.content.PonderTag;
import com.simibubi.create.foundation.ponder.content.PonderTagScreen;
import com.simibubi.create.foundation.ponder.ui.PonderButton;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
@ -139,7 +138,7 @@ public class PonderUI extends AbstractSimiScreen {
tags.forEach(t -> {
int i = tagButtons.size();
int x = 31;
int y = 71 + i * 30;
int y = 81 + i * 30;
PonderButton b = new PonderButton(x, y, (mouseX, mouseY) -> {
centerScalingOn(mouseX, mouseY);
ScreenOpener.transitionTo(new PonderTagScreen(t));
@ -315,6 +314,11 @@ public class PonderUI extends AbstractSimiScreen {
renderWidgets(mouseX, mouseY, identifyMode ? ponderPartialTicksPaused : partialTicks);
}
@Override
public void renderBackground() {
super.renderBackground();
}
protected void renderVisibleScenes(int mouseX, int mouseY, float partialTicks) {
renderScene(mouseX, mouseY, index, partialTicks);
float lazyIndexValue = lazyIndex.getValue(partialTicks);
@ -326,7 +330,7 @@ public class PonderUI extends AbstractSimiScreen {
SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance();
PonderScene story = scenes.get(i);
MatrixStack ms = new MatrixStack();
double value = lazyIndex.getValue(AnimationTickHolder.getPartialTicks(story.world));
double value = lazyIndex.getValue(minecraft.getRenderPartialTicks());
double diff = i - value;
double slide = MathHelper.lerp(diff * diff, 200, 600) * diff;
@ -341,15 +345,36 @@ public class PonderUI extends AbstractSimiScreen {
story.renderScene(buffer, ms, partialTicks);
buffer.draw();
MutableBoundingBox bounds = story.getBounds();
RenderSystem.pushMatrix();
RenderSystem.multMatrix(ms.peek()
.getModel());
// kool shadow fx
{
RenderSystem.enableCull();
RenderSystem.enableDepthTest();
RenderSystem.pushMatrix();
RenderSystem.translated(story.basePlateOffsetX, 0, story.basePlateOffsetZ);
RenderSystem.scaled(1, -1, 1);
for (int f = 0; f < 4; f++) {
RenderSystem.translated(story.basePlateSize, 0, 0);
RenderSystem.pushMatrix();
RenderSystem.translated(0, 0, 1/1024f);
GuiUtils.drawGradientRect(0, 0, 0, -story.basePlateSize, 4, 0x66_000000, 0x00_000000);
RenderSystem.popMatrix();
RenderSystem.rotatef(-90, 0, 1, 0);
}
RenderSystem.popMatrix();
RenderSystem.disableCull();
RenderSystem.disableDepthTest();
}
// coords for debug
if (PonderIndex.EDITOR_MODE && !userViewMode) {
MutableBoundingBox bounds = story.getBounds();
RenderSystem.pushMatrix();
RenderSystem.multMatrix(ms.peek()
.getModel());
RenderSystem.scaled(-1 / 16d, -1 / 16d, 1 / 16d);
RenderSystem.scaled(-1, -1, 1);
RenderSystem.scaled(1 / 16d, 1 / 16d, 1 / 16d);
RenderSystem.translated(1, -8, -1 / 64f);
// X AXIS
@ -389,11 +414,11 @@ public class PonderUI extends AbstractSimiScreen {
RenderSystem.popMatrix();
}
RenderSystem.popMatrix();
buffer.draw();
RenderSystem.popMatrix();
}
RenderSystem.popMatrix();
ms.pop();
}
@ -416,7 +441,7 @@ public class PonderUI extends AbstractSimiScreen {
int y = 31;
String title = activeScene.getTitle();
int wordWrappedHeight = font.getWordWrappedHeight(title, left.x);
int wordWrappedHeight = font.getWordWrappedHeight(title, left.x - 51);
int streakHeight = 35 - 9 + wordWrappedHeight;
UIRenderHelper.streak(0, x - 4, y - 12 + streakHeight / 2, streakHeight, (int) (150 * fade), 0x101010);
@ -435,7 +460,7 @@ public class PonderUI extends AbstractSimiScreen {
RenderSystem.translated(x, y, 0);
RenderSystem.rotatef(indexDiff * -75, 1, 0, 0);
RenderSystem.translated(0, 0, 5);
font.drawSplitString(title, 0, 0, left.x, ColorHelper.applyAlpha(textColor, 1 - indexDiff));
font.drawSplitString(title, 0, 0, left.x - 51, ColorHelper.applyAlpha(textColor, 1 - indexDiff));
RenderSystem.popMatrix();
if (chapter != null) {
@ -477,7 +502,6 @@ public class PonderUI extends AbstractSimiScreen {
}
RenderSystem.popMatrix();
}
scan.flash();
} else {
scan.dim();
@ -523,11 +547,16 @@ public class PonderUI extends AbstractSimiScreen {
int x = (width / 2) - 110;
int y = right.y + right.getHeight() + 4;
int w = width - 2 * x;
RenderSystem.pushMatrix();
RenderSystem.translated(0, 0, 400);
renderBox(x, y, w, 1, false);
RenderSystem.popMatrix();
RenderSystem.pushMatrix();
RenderSystem.translated(x - 2, y - 2, 0);
RenderSystem.scaled((w + 4) * sceneProgress.getValue(partialTicks), 1, 1);
GuiUtils.drawGradientRect(200, 0, 3, 1, 4, 0x60ffeedd, 0x60ffeedd);
GuiUtils.drawGradientRect(500, 0, 3, 1, 4, 0x60ffeedd, 0x60ffeedd);
RenderSystem.popMatrix();
}

View file

@ -141,9 +141,29 @@ public class SceneBuilder {
* assumes it to be square
*/
public void configureBasePlate(int xOffset, int zOffset, int basePlateSize) {
scene.offsetX = xOffset;
scene.offsetZ = zOffset;
scene.size = basePlateSize;
scene.basePlateOffsetX = xOffset;
scene.basePlateOffsetZ = zOffset;
scene.basePlateSize = basePlateSize;
}
/**
* Use this in case you are not happy with the scale of the scene relative to
* the overlay
*
* @param factor >1 will make the scene appear larger, smaller otherwise
*/
public void scaleSceneView(float factor) {
scene.scaleFactor = factor;
}
/**
* Use this in case you are not happy with the vertical alignment of the scene
* relative to the overlay
*
* @param yOffset >0 moves the scene up, down otherwise
*/
public void setSceneOffsetY(float yOffset) {
scene.yOffset = yOffset;
}
/**
@ -151,8 +171,10 @@ public class SceneBuilder {
* of the schematic's structure. Makes for a nice opener
*/
public void showBasePlate() {
world.showSection(scene.getSceneBuildingUtil().select.cuboid(new BlockPos(scene.offsetX, 0, scene.offsetZ),
new Vec3i(scene.size, 0, scene.size)), Direction.UP);
world.showSection(
scene.getSceneBuildingUtil().select.cuboid(new BlockPos(scene.basePlateOffsetX, 0, scene.basePlateOffsetZ),
new Vec3i(scene.basePlateSize, 0, scene.basePlateSize)),
Direction.UP);
}
/**

View file

@ -21,6 +21,9 @@ public class BearingScenes {
public static void windmillsAsSource(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("windmill_source", "Generating Rotational Force using Windmill Bearings");
scene.configureBasePlate(1, 1, 5);
scene.setSceneOffsetY(-1);
scene.world.showSection(util.select.fromTo(1, 0, 1, 5, 0, 5), Direction.UP);
scene.world.setBlock(util.grid.at(2, -1, 0), AllBlocks.SAIL.getDefaultState()
.with(SailBlock.FACING, Direction.NORTH), false);
@ -144,6 +147,8 @@ public class BearingScenes {
public static void windmillsAnyStructure(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("windmill_structure", "Windmill Contraptions");
scene.configureBasePlate(1, 1, 5);
scene.setSceneOffsetY(-1);
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.idle(5);
@ -191,6 +196,8 @@ public class BearingScenes {
public static void mechanicalBearing(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("mechanical_bearing", "Movings Structures using the Mechanical Bearing");
scene.configureBasePlate(1, 1, 5);
scene.setSceneOffsetY(-1);
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.idle(5);
scene.world.showSection(util.select.layer(1), Direction.DOWN);
@ -268,6 +275,9 @@ public class BearingScenes {
public static void bearingModes(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("bearing_modes", "Movement Modes of the Mechanical Bearing");
scene.configureBasePlate(1, 1, 6);
scene.setSceneOffsetY(-1);
Selection sideCog = util.select.position(util.grid.at(7, 0, 3));
Selection cogColumn = util.select.fromTo(6, 1, 3, 6, 4, 3);
Selection cogAndClutch = util.select.fromTo(5, 3, 1, 5, 4, 2);
@ -350,6 +360,8 @@ public class BearingScenes {
public static void stabilizedBearings(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("stabilized_bearings", "Stabilized Contraptions");
scene.configureBasePlate(1, 1, 5);
scene.setSceneOffsetY(-1);
Selection beltAndBearing = util.select.fromTo(3, 3, 4, 3, 1, 6);
Selection largeCog = util.select.position(2, 0, 6);

View file

@ -161,6 +161,7 @@ public class BeltScenes {
public static void directions(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("belt_directions", "Valid Orientations for Mechanical Belts");
scene.configureBasePlate(0, 0, 5);
scene.setSceneOffsetY(-1);
scene.showBasePlate();
scene.idle(5);
@ -305,6 +306,7 @@ public class BeltScenes {
public static void transport(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("belt_transport", "Using Mechanical Belts for Logistics");
scene.configureBasePlate(0, 0, 5);
scene.setSceneOffsetY(-1);
scene.world.modifyKineticSpeed(util.select.everywhere(), f -> -.6f * f);
scene.showBasePlate();
scene.idle(5);
@ -379,6 +381,7 @@ public class BeltScenes {
public static void beltsCanBeEncased(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("belt_casing", "Encasing Belts");
scene.configureBasePlate(0, 0, 5);
scene.setSceneOffsetY(-1);
scene.showBasePlate();
scene.idle(5);
scene.world.showSection(util.select.layersFrom(1), Direction.DOWN);

View file

@ -92,7 +92,8 @@ public class ChainDriveScenes {
public static void adjustableChainGearshift(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("chain_gearshift", "Controlling rotational speed with Chain Gearshifts");
scene.configureBasePlate(0, 0, 7);
scene.configureBasePlate(0, 0, 5);
scene.setSceneOffsetY(-1);
scene.world.showSection(util.select.layer(0), Direction.UP);
BlockPos leverPos = util.grid.at(3, 1, 0);

View file

@ -241,6 +241,7 @@ public class GantryScenes {
public static void subgantry(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("gantry_cascaded", "Cascaded Gantries");
scene.configureBasePlate(0, 0, 5);
scene.setSceneOffsetY(-1);
scene.world.modifyKineticSpeed(util.select.everywhere(), f -> -2 * f);
scene.world.showSection(util.select.layer(0)
.add(util.select.column(5, 3))

View file

@ -279,6 +279,8 @@ public class KineticsScenes {
public static void gearbox(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("gearbox", "Relaying rotational force using Gearboxes");
scene.configureBasePlate(1, 1, 5);
scene.setSceneOffsetY(-1);
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.world.showSection(util.select.fromTo(4, 1, 6, 3, 2, 5), Direction.UP);
scene.idle(10);

View file

@ -22,7 +22,9 @@ public class MovementActorScenes {
public static void psiTransfer(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("portable_storage_interface", "Contraption Storage Exchange");
scene.configureBasePlate(0, 0, 8);
scene.configureBasePlate(0, 0, 6);
scene.scaleSceneView(0.95f);
scene.setSceneOffsetY(-1);
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.idle(5);
@ -112,7 +114,7 @@ public class MovementActorScenes {
scene.world.modifyEntity(entity2, Entity::remove);
scene.overlay
.showControls(new InputWindowElement(util.vector.topOf(6, 3, 2), Pointing.DOWN).withItem(itemStack), 40);
.showControls(new InputWindowElement(util.vector.topOf(5, 3, 2), Pointing.DOWN).withItem(itemStack), 40);
scene.idle(30);
scene.world.hideSection(util.select.position(hopper), Direction.UP);
@ -148,7 +150,8 @@ public class MovementActorScenes {
public static void psiRedstone(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("portable_storage_interface_redstone", "Redstone Control");
scene.configureBasePlate(0, 0, 6);
scene.configureBasePlate(0, 0, 5);
scene.setSceneOffsetY(-1);
Class<PortableItemInterfaceTileEntity> psiClass = PortableItemInterfaceTileEntity.class;
Selection psis = util.select.fromTo(1, 1, 3, 1, 3, 3);

View file

@ -16,7 +16,9 @@ public class PulleyScenes {
public static void movement(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("rope_pulley", "Moving Structures using Rope Pulleys");
scene.configureBasePlate(0, 0, 8);
scene.configureBasePlate(0, 0, 5);
scene.scaleSceneView(0.95f);
scene.setSceneOffsetY(-1);
Selection reversable = util.select.fromTo(2, 3, 4, 2, 4, 2);
BlockPos leverPos = util.grid.at(1, 2, 4);
@ -101,7 +103,9 @@ public class PulleyScenes {
public static void movementModes(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("rope_pulley_modes", "Movement Modes of the Rope Pulley");
scene.configureBasePlate(0, 0, 8);
scene.configureBasePlate(0, 0, 5);
scene.scaleSceneView(0.95f);
scene.setSceneOffsetY(-1);
Selection reversable = util.select.fromTo(2, 3, 4, 2, 4, 2);
BlockPos leverPos = util.grid.at(1, 2, 4);
@ -172,7 +176,9 @@ public class PulleyScenes {
public static void attachment(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("rope_pulley_attachment", "Moving Pulleys as part of a Contraption");
scene.configureBasePlate(0, 0, 8);
scene.configureBasePlate(0, 0, 5);
scene.scaleSceneView(0.95f);
scene.setSceneOffsetY(-1);
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.idle(5);