Quadrilateral dense paving plane

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.