a bunch of shit

This commit is contained in:
2026-02-13 22:53:09 +01:00
parent 0c1541e98c
commit 7c03b1b81d
11 changed files with 242 additions and 40 deletions
+13 -11
View File
@@ -3,10 +3,9 @@
// please, dont. if you do continue, edit the value below
// as a warning for future you.
// hoursWasted = 2
// hoursWasted = 5
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <cmath>
#include "renderer/camera.hpp"
@@ -27,20 +26,23 @@ DeltaVector2 DeltaCamera::projectPointVec(const DeltaVector3 &worldPos) {
// yaw translate
calculatedPos.x = (worldPos.x - pos.x) * cosineX - (worldPos.y - pos.y) * sineX;
calculatedPos.y = (worldPos.y - pos.y) * cosineX + (worldPos.x - pos.x) * sineX;
calculatedPos.z = (worldPos.z - pos.z);
DeltaVector3 t = worldPos - pos;
float rx = t.x * cosineX - t.y * sineX;
float ry = t.y * cosineX + t.x * sineX;
float rz = (worldPos.z - pos.z);
// pitch translate
float tempY = calculatedPos.y, tempZ = calculatedPos.z;
calculatedPos.y = tempY * cosineY - tempZ * sineY;
calculatedPos.z = tempY * sineY + tempZ * cosineY;
calculatedPos.x = rx;
calculatedPos.y = ry * cosineY - t.z * sineY;
calculatedPos.z = t.z * cosineY + ry * sineY;
// dont touch calculatedPos.x
projected.x = calculatedPos.x * FOCAL / calculatedPos.y + SIMULATED_WIDTH / 2;
projected.y = calculatedPos.z * FOCAL / calculatedPos.y + SIMULATED_HEIGHT / 2;
// calculatedPos.y = calculatedPos.y * cosineY;
projected.x = calculatedPos.x * FOCAL / calculatedPos.y + SIMULATED_WIDTH / 2.0f;
projected.y = calculatedPos.z * FOCAL / calculatedPos.y + SIMULATED_HEIGHT / 2.0f;
// now gotta convert y to our y
projected.y = SIMULATED_HEIGHT - projected.y;