Jump to content

Manual mesh generation


photo

Recommended Posts

Posted


Hi,

i am currently working on creating static meshes on-the-fly by using OSM data (I see that topic on your beta branch too. Very nice work by the way!). The import of the vertices data and processing of them works fine, but I have some issues creating an proper looking mesh with a base material.

image.png.c77863c9c12878c3c34a6f93aef2b0d4.png

 

I am using the written approach at the tutorial section to create a dynamic Mesh, adding vertices and indices to it, and automatically calculate the triangles and normals (result in the picture above). It seems, that there is a problem on my side to setup the faces properly. If I just generate the top of the house, the normal/tangent creation seems to be fine, but after adding the building sides, I got a weird result. Should I now recalculate for every tangent and normal the proper matrices or are there a specific order of how to add the vertices and indices?

 

Second, I created the mesh around the world center coordinates and transform the result StaticMesh to the proper position (which is in the above picutre outside the standard plane of the base world. If the plane leaves the frustrum of the camera, also the mesh won't be rendered anymore. The same happens, when I didn't move the mesh and move the camera up. So as long as the plane is inside my camera frustrum, everything works as expected. Is this an expected behavior or did I miss something during mesh generation?

 

 

 

 

 

Posted

Hi,

to create a proper face, order of vertices/ indices is important (face side is located on clockwise vertices direction ). So to build correct walls, you need to know the orientation of your vector polygon (house perimeter).

In 2.7 we added api for that and some other stuff: UnigineMath2d.h. Besides orientation there is a simple triangulation function, that we use to triangulate building's roof.

As about visibility, you probably forget to call Mesh::createBounds after generating it. It should help.

 

 

Posted

Hello maxi,

 

thanks a lot for your detailed answer. I will look into the orientation stuff (I thought something like that). For roofes, I actually didn't have any problems with it. At least if I create only the roof data. Do you know what type of triangulation algorithm are you using? I made some very good results with Delaunay algorithm regarding performance and data memory usage.

 

The "Mesh::createBounds" do the trick for me. Thanks a lot. Can you please add this line of code in the example project inside your documentation? Will be helpful for other users by following this tutorial.

 

Thanks you!

Posted

I am glad, it helped. As for triangulation algorithm, we use pretty straightforward "ear clipping", so I guiess, Delaunay will give you more effective results.

We'll add code snippet with Mesh::createBounds, thanks.

×
×
  • Create New...