pinhole camera ray map like vanilla (vertical fov 70, horizontal from aspect, pixel centres, no roll) instead of yaw/pitch corner rotation that squashed photos vertically by cos 35, shared buildRayMap in test tools, camera projection test scenes

This commit is contained in:
MineTec committed 2026-11-04 17:07:19 +01:00
1 parent 88bae41a03
commit 6660ebe557
5 files changed
+77 -112

No files matched your search

+4 -24
View File
@@ -6,7 +6,6 @@ import eu.mhsl.minecraft.pixelpics.render.render.*;
import eu.mhsl.minecraft.pixelpics.render.sky.SkyContext;
import eu.mhsl.minecraft.pixelpics.render.snapshot.WorldSnapshot;
import eu.mhsl.minecraft.pixelpics.render.tint.BiomeTintProvider;
import eu.mhsl.minecraft.pixelpics.render.util.MathUtil;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
@@ -25,8 +24,7 @@ import java.util.logging.Logger;
public class BlockEntityTestRender {
static final String ROOT = "/home/elias/Dokumente/mcTestServer/plugins/PixelPics";
static final double H_FOV_HALF = Math.toRadians(35);
static final Vector BASE = new Vector(1, 0, 0);
static final double V_FOV_HALF = Math.toRadians(eu.mhsl.minecraft.pixelpics.render.render.DefaultScreenRenderer.V_FOV_DEG / 2);
static final int SSAA = 3;
static final int TW = 220, TH = 240;
@@ -271,7 +269,7 @@ public class BlockEntityTestRender {
double cx = (min[0] + max[0]) / 2, cy = (min[1] + max[1]) / 2, cz = (min[2] + max[2]) / 2;
double ext = 0.5;
for (int a = 0; a < 3; a++) ext = Math.max(ext, max[a] - min[a]);
double dist = ext / (2 * Math.tan(H_FOV_HALF)) * 1.4 + 0.6;
double dist = ext / (2 * Math.tan(V_FOV_HALF)) * 1.4 + 0.6;
Vector center = new Vector(cx, cy, cz);
Vector cam = new Vector(cx - dist, cy + dist * 0.45, cz - dist * 0.35);
@@ -300,7 +298,7 @@ public class BlockEntityTestRender {
double cx = (min[0] + max[0]) / 2, cy = (min[1] + max[1]) / 2, cz = (min[2] + max[2]) / 2;
double ext = 0.5;
for (int a = 0; a < 3; a++) ext = Math.max(ext, max[a] - min[a]);
double dist = ext / (2 * Math.tan(H_FOV_HALF)) * 1.4 + 0.6;
double dist = ext / (2 * Math.tan(V_FOV_HALF)) * 1.4 + 0.6;
// View from the front side (along +facing) so the picture is visible, not the back.
DecorationState.Facing f = states.get(0).facing();
double fx = f.axis() == 0 ? f.sign() : 0, fy = f.axis() == 1 ? f.sign() : 0, fz = f.axis() == 2 ? f.sign() : 0;
@@ -328,24 +326,6 @@ public class BlockEntityTestRender {
}
static List<Vector> buildRayMap(Location eye, int width, int height) {
Vector dir = eye.getDirection();
double angleYaw = Math.atan2(dir.getZ(), dir.getX());
double anglePitch = Math.atan2(dir.getY(), Math.sqrt(dir.getX() * dir.getX() + dir.getZ() * dir.getZ()));
double yawHalf = H_FOV_HALF;
double pitchHalf = Math.atan(Math.tan(yawHalf) * ((double) height / width));
Vector ll = MathUtil.doubleYawPitchRotation(BASE, -yawHalf, -pitchHalf, angleYaw, anglePitch);
Vector ul = MathUtil.doubleYawPitchRotation(BASE, -yawHalf, pitchHalf, angleYaw, anglePitch);
Vector lr = MathUtil.doubleYawPitchRotation(BASE, yawHalf, -pitchHalf, angleYaw, anglePitch);
Vector ur = MathUtil.doubleYawPitchRotation(BASE, yawHalf, pitchHalf, angleYaw, anglePitch);
List<Vector> rayMap = new ArrayList<>(width * height);
Vector leftFrac = ul.clone().subtract(ll).multiply(1.0 / (height - 1));
Vector rightFrac = ur.clone().subtract(lr).multiply(1.0 / (height - 1));
for (int pitch = 0; pitch < height; pitch++) {
Vector leftPitch = ul.clone().subtract(leftFrac.clone().multiply(pitch));
Vector rightPitch = ur.clone().subtract(rightFrac.clone().multiply(pitch));
Vector yawFrac = rightPitch.clone().subtract(leftPitch).multiply(1.0 / (width - 1));
for (int yaw = 0; yaw < width; yaw++) rayMap.add(leftPitch.clone().add(yawFrac.clone().multiply(yaw)).normalize());
}
return rayMap;
return eu.mhsl.minecraft.pixelpics.render.render.DefaultScreenRenderer.buildRayMap(eye, width, height);
}
}