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:
1 parent
88bae41a03
commit
6660ebe557
5 files changed
+77
-112
No files matched your search
@@ -4,7 +4,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;
|
||||
@@ -23,8 +22,7 @@ import java.util.logging.Logger;
|
||||
public class EntityTestRender {
|
||||
|
||||
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 = 200, TH = 230; // per-view tile size
|
||||
|
||||
@@ -232,7 +230,7 @@ public class EntityTestRender {
|
||||
double ext = 0;
|
||||
for (int a = 0; a < 3; a++) ext = Math.max(ext, re.aabbMax[a] - re.aabbMin[a]);
|
||||
if (ext < 0.5) ext = 0.5;
|
||||
double dist = ext / (2 * Math.tan(H_FOV_HALF)) * 1.25 + 0.4;
|
||||
double dist = ext / (2 * Math.tan(V_FOV_HALF)) * 1.25 + 0.4;
|
||||
|
||||
Vector center = new Vector(cx, cy, cz);
|
||||
Vector cam = new Vector(cx - dist, cy + dist * 0.42, cz - dist * 0.15);
|
||||
@@ -293,28 +291,7 @@ public class EntityTestRender {
|
||||
return cell;
|
||||
}
|
||||
|
||||
// Replicated from DefaultScreenRenderer.buildRayMap.
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user