Merging coplanar triangles of a mesh into polygon

I have a 3d city model and imported it into unity. I need to merge coplanar triangles into polygon surfaces because I want to create grids on building surfaces. How can I make this possible? Are there any component, library or algorithms for this purpose?

Well, if the triangles that form the polygon share all vertices it’s quite easy to find neighbor triangles. Once you have them you can simply calculate the surface normal of two adjacent triangles and see if they are equal (to some degree). If they are you can simply remove the shared edge between the two triangles to form a “quadrilateral”. This can be repeated until all coplanar triangles have been included.

If the mesh doesn’t use shared vertices it’s a bit harder since you have to compare vertex positions to determine which edges are actually the same.