From 2190fd187ef9248a3ec8cb0a335e1e532139bb22 Mon Sep 17 00:00:00 2001 From: InventorXtreme Date: Mon, 4 Dec 2023 23:28:44 -0500 Subject: [PATCH] finishing up --- c3d.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/c3d.c b/c3d.c index 2cd37bc..fd207b2 100644 --- a/c3d.c +++ b/c3d.c @@ -88,8 +88,23 @@ double Max(double a, double b){ return a; } -void Tri2DSort(Tri2D * t){ - +void Tri2DSortByY(Tri2D * t){ + Vector2 temp; + if (t->a.y > t->b.y) { + temp = t->a; + t->a = t->b; + t->b = temp; + } + if (t->b.y > t->c.y){ + temp = t->b; + t->b = t->c; + t->c = temp; + } + if (t->a.y > t->b.y) { + temp = t->a; + t->a = t->b; + t->b = temp; + } } //Draws triangle with a flat top. Note A and B must be the top points with C being the bottom "spike" @@ -136,6 +151,21 @@ void FillBottomFlatZbuffer(Zee zee[][1080], Tri2D* t) { } +void DrawTriZuff(Zee zbuf[][1080], Tri2D t){ + Tri2DSortByY(&t); + + if (t.b.y == t.c.y) { + FillBottomFlatZbuffer(zbuf,&t); + } + else if (t.a.y == t.b.y) { + FillTopFlatZbuffer(zbuf,&t); + } else{ //funny split tri + + } + + + +} float Sign(Vector2* v1, Vector2* v2, Vector2* v3) { return (v1->x - v3->x) * (v2->y - v3->y) - (v2->x - v3->x) * (v1->y - v3->y);