by Spike » Tue Jan 20, 2015 11:14 am
its best expressed as A*x + B*y + C*z - D = 0
some useful formulas:
distfromplane = DotProduct (plane->normal, point) - plane->dist;
plane->dist = DotProduct(plane->normal, pointonplane);
pointonplane = point - (distfromplane*plane->normal);
isinfront = distfromplane>0;
isbehind = distfromplane<0;
isfloatingpointprecisionmiraclethatyouhavetosomehowrollintoonesideyetstillallowsplayerstofallthroughcracks = distfromplane==0;
note that the distance is negated relative to more standard plane notation. in mathematics, the plane is generally two-sided. in quake, the normal faces directly forwards into empty space (unless the surface has SURF_PLANEBACK set, in which case the normal faces backwards - all 4 values are logically negated (or in the case of nodes, the two children are pre-swapped, avoiding the need for the engine to do anything special). note that the plane normals in a quake bsp are arranged to be primarily positive, reducing the total number of planes needed, and facilitating axial lookups).
for surfaces, the two tangents are normally available via the texture vector values, but note that these vectors are not kept strictly perpedicular to the normal, nor are they always normalized. because quake is weird and has annoying texture mapping, as well as texture scaling.
.