Sources excerpted from terrain.cpp:
Code:
Vec3f corner0( minU + u * stepU, 0, minV + v * stepV);
Vec3f corner1( minU + u * stepU, 0, minV + (v + 1) * stepV);
Vec3f corner2( minU + (u + 1) * stepU, 0, minV + v * stepV);
Vec3f corner3( minU + (u + 1) * stepU, 0, minV + (v + 1) * stepV);
......
Plane tri0( corner0, corner1, corner2 );
Plane tri1( corner1, corner2, corner3 );
for( float vv = 0; vv <= stepV; vv += pixelStep )
{
for( float uu = 0; uu <= stepU; uu += pixelStep )
{
Plane &curTri = uu <= vv ? tri0 : tri1;
Assume (0,0) to be the left-top corner (or any), as follows:
V0 -------V2
| Tri0 / |
| / |
| / Tri1|
V1--------V3
IMHO for statement curTri = tri0 iff uu <= vv to be true, the tri0 should be (V0, V1, V3) and tri1 (V0, V2, V3). Otherwise different rule for deciding curTri needed.