finishing up

This commit is contained in:
InventorXtreme 2023-12-04 23:28:44 -05:00
parent 71fa8e21e3
commit 2190fd187e

34
c3d.c
View file

@ -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);