Any quadrilateral can lay out the entire two-dimensional plane, and the code implementation will be given here.
voidCtilequadranglegriddrawer::buildtilequadrangle (vector3*v) {Vector2 vDis01= m_quadpositions[0]-m_quadpositions[1]; Vector2 VDis32= m_quadpositions[3]-m_quadpositions[2]; Vector2 VDis03= m_quadpositions[0]-m_quadpositions[3]; Vector2 VDIS12= m_quadpositions[1]-m_quadpositions[2]; Vector2 Vextend= ((vDis01 + vDis32) * ((float) m_uicol) + (VDIS03 + vDis12) * ((float) (M_uirow)) *0.5f; Vector2 Vstart=-vextend*0.5f; Vector2 Vcurrentrow=Vstart; Vector2 Vcurrentcol; unsignedintindex; for(unsignedinti =0; I <= M_uirow; i++) {Vcurrentcol=Vcurrentrow; for(Yuint j =0; J <= M_uicol; J + +) {Index= i* (M_uicol +1) +J; v[index].x=vcurrentcol.x; V[index].y=vcurrentcol.y; V[index].z=0.0f; Vcurrentcol+ = ((i+j) &1) ?Vdis01:vdis32; } Vcurrentrow+ = (i&1) ?vdis03:vdis12; }}
The m_quadpositions in your code represents the four vertices of a quad. V is the vertex mesh for the computed output.
In the lower right corner of the form there is a quadrilateral, the mouse drags the four-sided vertices, you can change the shape of the quadrilateral, thereby changing the tiled grid.
Software: http://files.cnblogs.com/files/WhyEngine/TileQuadrangle.7z
This is a 3D program, the right mouse button Drag can change the perspective.
X is used to revert to the default view.
F11 for full screen switching.
Quadrilateral dense paving plane