Skip to main content
gamedev.net
🔒 Locked

Rounding Algorithm

Started by Super Llama Jun 14, 2010 at 5:16 PM 2 replies 650+ views
Original Post
Super Llama
Super Llama
I'm looking for a good algorithm to round the edges of a mesh generated by a function. The mesh will be two or more sides of a cube or wedge, and I want it to round any edges that join two of these sides. At first, I was going to just add extra vertices around the edges, but that won't work because when two edges meet, it wouldn't make a proper rounded corner. Any good algorithm will do, but if you need to know, I'm using Java and LWJGL, and my mesh building algorithm internally stores its faces as six arrays of 4 vertices. Since the algorithm will be inside the mesh building algorithm (activated via a flag) this is the format I need to use, unless it's easier to process an array of floats, which I doubt.
It's a sofa! It's a camel! No! It's Super Llama!
Zakwayda
Zakwayda
I wrote code at one point to 'round off' the edges of convex polyhedra, but as I recall, it was nontrivial - it involved computing connectivity info, subdividing the mesh in specific areas, and then repositioning the new vertices relative to the original edge.

I do still have that source code, but it's in C++ and tbh it's a big mess, so I doubt it would be of much use to anyone.

But, I imagine you can figure it out yourself with a little work. The basic idea (as I recall) is to push the faces out along their normals by the desired radius, fill in the gaps with new vertices and faces, and then adjust the positions of the new vertices so that they are 'radius' units from the original edge.
Super Llama
Super Llama
I guess it's going to require a lot more code than I thought :P

I still don't quite understand how to do corners though...
It's a sofa! It's a camel! No! It's Super Llama!
szecs
szecs
Quote:
Original post by Super Llama
I guess it's going to require a lot more code than I thought :P

I still don't quite understand how to do corners though...
Try to figure it out with paper and pen. You have to decide, what behavior you want at specific cases, no one will do that for you. If you know the behavior, all you need is to code it ;)

But just a side-note: even the biggest/coolest/whateverest programs crash with some rounding situations.

Try to google "fillet" to find the possible scenarios and the corresponding behaviors.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.