Jump to content
  • Advertisement
Sign in to follow this  
MarkS

I need a mesh welding algorithm...

This topic is 2566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!