I need a mesh welding algorithm...

Started by
1 comment, last by MarkS_ 12 years, 4 months ago
The game that I am making creates the levels dynamically. The basis of the game is a maze and I can break the individual cells into 15 different variants depending on which sides of the cells have walls. I don't need to get too much into the specifics of all of this, but to simplify the creation of the cell meshes and to allow for a good variation among them, the meshes are stored in a split form, i.e., the walls, floor, and ceiling are individual mesh files that are to be combined as needed during level creation. Once the meshes are assembled, they would be stored in a VBO.

The issue is that I will need to combine all of the face indices into a single list and remove any duplicate vertices. Basically, I need to weld the meshes together. This seems like an easy exercise at first glance, but quickly turns into a more or less recursive hell upon further inspection. I'd like to come up with this myself, but I could use some references. Google has proven less than helpful as any search with "mesh" and "weld" in it returns more steel mesh welding than programming related resources and most of them are questions on other forums.

Can anyone point me in the right direction?
Advertisement

This seems like an easy exercise at first glance, but quickly turns into a more or less recursive hell upon further inspection.

How come? First thing that comes to mind in pseudo code:

[source]new list of vertices;
new list of indices;

for every triangle
{
for every vertex
{
if vertex is within welding range of a vertex in the new list
add vertex index to the new list of indices
else
{
add vertex to new list of vertices
add index of newly added vertex to the new list of indices
}
}
}[/source]

Is that what you were looking for?
Thanks. For some reason, I wasn't thinking of creating a new mesh, but combining the meshes into one of the original meshes.huh.gif

Anyway, this isn't necessary after all. I made this post at 3 AM. As I was lying in bed, it suddenly occurred to me that if I combine them like I was saying, it will totally screw up the normal and texture coordinates at the joints. I need them to be separate.

This topic is closed to new replies.

Advertisement