near plane clipping partial

This commit is contained in:
2026-02-21 16:28:09 +01:00
parent 7c03b1b81d
commit 7ca48a5080
9 changed files with 271 additions and 37 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
#ifndef DELTA_GLOBALS
#define DELTA_GLOBALS
const int SIMULATED_WIDTH = 1920;
const int SIMULATED_HEIGHT = 1080;
const int SIMULATED_WIDTH = 800;
const int SIMULATED_HEIGHT = 600;
const int FOCAL = 300;
#endif
+14
View File
@@ -36,11 +36,25 @@ class DeltaVector3 {
};
float getDeterminant(const DeltaVector2 &pointA, const DeltaVector2 &pointB, const DeltaVector2 &candidate);
DeltaVector2 barycentricToScreen(const DeltaVector3 &baryPoint, const DeltaVector2 &a, const DeltaVector2 &b, const DeltaVector2 &c);
DeltaVector3 intersect(DeltaVector3 a, DeltaVector3 b, float nearZ);
struct DeltaTriangle {
DeltaVector3 a, b, c;
};
struct DeltaTriangle2D {
DeltaVector2 a, b, c;
};
struct DeltaRenderTriangle {
DeltaVector3 a, b, c;
DeltaVector2 uva, uvb, uvc;
};
int clipTriangleAgainstNearPlane(float nearY, const DeltaRenderTriangle &in, DeltaRenderTriangle &out1, DeltaRenderTriangle &out2);
uint32_t SDLColorToUint32(SDL_Color color);
#endif
+1 -1
View File
@@ -7,6 +7,6 @@
void rasterizeTriangle(SDL_Renderer *renderer, const DeltaVector2 &a, const DeltaVector2 &b, const DeltaVector2 &c);
void rasterizeTriangleFast(SDL_Surface* surface, const DeltaVector2& v0, const DeltaVector2& v1, const DeltaVector2& v2, uint32_t color);
void rasterizeTriangleSurface(SDL_Surface* surface, const DeltaVector2& a, const DeltaVector2& b, const DeltaVector2& c, uint32_t color);
void rasterizeTriangleSurface(SDL_Surface* surface, const DeltaVector2& v0, const DeltaVector2& v1, const DeltaVector2& v2, uint32_t color, float u0, float v0_uv, float u1, float v1_uv, float u2, float v2_uv);
void setPixel(SDL_Surface* surface, int x, int y, uint32_t color);
#endif
+2
View File
@@ -10,7 +10,9 @@ class DeltaCamera {
DeltaCamera() {pos = DeltaVector3(); angle = DeltaVector2();};
DeltaCamera(float x, float y, float z);
DeltaVector3 translatePoint(const DeltaVector3 &worldPos);
DeltaVector2 projectPointVec(const DeltaVector3 &worldPos);
int projectTriangle(const DeltaTriangle &in, DeltaTriangle2D &out1, DeltaTriangle2D &out2);
DeltaVector2 projectPoint(float worldX, float worldY, float worldZ);
};