592 |
coords1.vertex(p); |
coords1.vertex(p); |
593 |
DBG(dbg) << "Vert: " << q<<p<<coords1.transform(p) <<"\\n"; |
DBG(dbg) << "Vert: " << q<<p<<coords1.transform(p) <<"\\n"; |
594 |
} |
} |
595 |
|
|
596 |
|
|
597 |
|
// Slide v1 into [x0,x1]x[y0,y1] |
598 |
|
template <class Coords> |
599 |
|
void vert(Coords& coords1, ZPt v1) { |
600 |
|
if (v1.x < x0) v1.x = x0; |
601 |
|
if (v1.x > x1) v1.x = x1; |
602 |
|
if (v1.y < y0) v1.y = y0; |
603 |
|
if (v1.y > y1) v1.y = y1; |
604 |
|
coords1.vertex(v1); |
605 |
|
} |
606 |
|
|
607 |
|
// Do vert(coords1, v) for any crossings and then vert(coords1, v1) |
608 |
|
template <class Coords> |
609 |
|
void vert(Coords& coords1, ZPt v0, ZPt v1) { |
610 |
|
ZPt v; |
611 |
|
if ((v0.x - x0) * (v1.x - x0) < 0) v = lerp(v0, v1, (x0 - v0.x) / (v1.x - v0.x)); |
612 |
|
else if ((v0.x - x1) * (v1.x - x1) < 0) v = lerp(v0, v1, (x1 - v0.x) / (v1.x - v0.x)); |
613 |
|
else if ((v0.y - y0) * (v1.y - y0) < 0) v = lerp(v0, v1, (y0 - v0.y) / (v1.y - v0.y)); |
614 |
|
else if ((v0.y - y1) * (v1.y - y1) < 0) v = lerp(v0, v1, (y1 - v0.y) / (v1.y - v0.y)); |
615 |
|
else { |
616 |
|
return vert(coords1, v1); |
617 |
|
} |
618 |
|
vert(coords1, v0, v); |
619 |
|
vert(coords1, v, v1); |
620 |
|
} |
621 |
""", |
""", |
622 |
"RenderCode" : """ |
"RenderCode" : """ |
623 |
DBG(dbg) << "Irregular quad\\n"; |
DBG(dbg) << "Irregular quad\\n"; |
731 |
ZPt(+x2,-y1,0), ZPt(+x1,-y2,0), ZPt(+x1,+y2,0) }; |
ZPt(+x2,-y1,0), ZPt(+x1,-y2,0), ZPt(+x1,+y2,0) }; |
732 |
int dice[] = { diceb, dicex, diceb, dicey, diceb, dicex, diceb, dicey }; |
int dice[] = { diceb, dicex, diceb, dicey, diceb, dicex, diceb, dicey }; |
733 |
|
|
734 |
|
#if 1 |
735 |
|
ZPt poly2[9]; |
736 |
|
for (int i = 0; i < 9; i++) poly2[i] = coords2.transform(poly[i]); |
737 |
|
|
738 |
|
// Disable the effect of TEXTURE1 as the clipping is done explicitly |
739 |
|
glMultiTexCoord2f(1, .5, .5); |
740 |
|
|
741 |
|
glBegin(GL_TRIANGLE_FAN); |
742 |
|
vert(coords1, coords2.transform(ZPt(0,0,0))); |
743 |
|
ZPt prev = poly2[0]; |
744 |
|
for (int i = 0; i < 8; i++) { |
745 |
|
for (int d = 0; d < dice[i]; d++) { |
746 |
|
float t = (float)d / dice[i]; |
747 |
|
ZPt v = lerp(poly2[i], poly2[i+1], t); |
748 |
|
vert(coords1, prev, v); |
749 |
|
prev = v; |
750 |
|
} |
751 |
|
} |
752 |
|
vert(coords1, prev, poly2[0]); |
753 |
|
glEnd(); |
754 |
|
|
755 |
|
#else |
756 |
|
|
757 |
glBegin(GL_TRIANGLE_FAN); |
glBegin(GL_TRIANGLE_FAN); |
758 |
vert(coords1, coords2, ZPt(0,0,0)); |
vert(coords1, coords2, ZPt(0,0,0)); |
759 |
for (int i = 0; i < 8; i++) { |
for (int i = 0; i < 8; i++) { |
763 |
} |
} |
764 |
} |
} |
765 |
glEnd(); |
glEnd(); |
766 |
|
#endif |
767 |
|
|
768 |
if (mode) glPopMatrix(); |
if (mode) glPopMatrix(); |
769 |
|
|