polygon_z_normal(3alleg4)
π polygon_z_normal β ok bestie, let's find that Z π
so like, this is a page from the Allegro manual, manual section 3alleg4, and it's all about polygon_z_normal, polygon_z_normal_f β finding the Z component of the normal vector to three vertices. Allegro game programming library, yes ma'am. π
β¨ NAME β¨
polygon_z_normal, polygon_z_normal_f β finds the Z component of the normal vector to three vertices. it's giving Allegro game programming library energy fr fr π
πΈ SYNOPSIS πΈ
#include <allegro.h>
fixed polygon_z_normal(const V3D *v1, const V3D *v2, const V3D *v3);
float polygon_z_normal_f(const V3D_f *v1, const V3D_f *v2, const V3D_f *v3);
π¦ DESCRIPTION π¦
okay so basically, this finds the Z component of the normal vector to the three vertices you hand it β and those three vertices must be part of a convex polygon, no cap. that's the vibe.
what's it for? mainly back-face culling, bestie. the back-faces of closed polyhedra are literally never visible to the viewer, so they never need to be drawn. never ever. and the way that this can cull on average half the polygons from a scene?? iconic. half!! free real estate!! π₯
here's the rule:
- if the normal is negative, the polygon can safely be culled π
- if it's zero, the polygon is perpendicular to the screen π
β οΈ BUT β and this is the important part β this method of culling back-faces must only be used once the X and Y coordinates have been projected into screen space using persp_project(). (or, alternatively, if an orthographic (isometric) projection is being used, that's fine too.) do not skip this step, i am begging π«Ά
π also, note that this function will fail if the three vertices are co-linear β like, they lie on the same line β in 3D space. so don't do that. co-linear vertices = no normal, no answer, just sadness.
π SEE ALSO π
and that's the whole page, bestie!! this beauty lives in the Allegro docs, version 4.4.3, and it was written way back on the date stamped in the footer of the original polygon_z_normal(3alleg4) page. go cull some polygons responsibly, mwah ππβ¨
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms