#### Archived

This topic is now archived and is closed to further replies.

# Rounding corners

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

## Recommended Posts

Does anyone have some example code (algorithm, etc..) of rounding a corner? For example, I would like to take a simple 3D box and round all 6 corners to however much detail I want.

##### Share on other sites
Define "rounding a corner"

Do you want to take a simple 3D box, which has 6 sides and 8 vertices, and making it ''look'' rounder. That can be done with modifying the normals. Flat shading, where the normals are 90 degrees away from each other makes everything look flat, but if you change those normals, the edges won''t look nearly as flat.

But, there''s only so much you can do with shading...

The ''real'' method would be to add more polygons...Polygons are your friend. But of course this method is quite complex, at least if you''re doing it in code instead of a 3D package.

G''luck,
-Alamar

##### Share on other sites
Try the following; I can''t guarantee that it''ll work, but it''s an idea:

Split each quad into four smaller quads, and use a cubic interpolation function to set it''s coordinates equal to a weighted average of all adjacent verteces coordinates. Repeat until the desired detail is reached.

##### Share on other sites
Alamar:
Sorry, I don''t mean smoothing shading. What I mean is adding more polygons to
curve it out.

Too bad I can''t show a pic, but I want to be able to specify the exact number
of edges along the curve of the corner. Dividing one triangle into 4 will work,
but it creates too many polys too quickly. I want to be able to pick any number,
(ie.1,2,3,4,5...) that''s not a multiply of 4.

So the box corner will look like this as it progresses from a single vertex:

No edges          1 edge       2 edges          3 edges    ....etcjust a vertex                    *            *                  *   *               / \          / \                / \                  *---*        *---*              *---*                              / \ / \            / \ / \                             *---*---*          *---*---*                                               / \ / \ / \                                              *---*---*---*

##### Share on other sites
Are you working with arbitrary geometry, or can it be expressed in terms of quads or 45 45 90 right triangles? If it can be expresed in quads, like I said, you can just split each quad into 4 smaller ones. If you''re using right triangles, you can drop a median perpendicular to the hypotenuse to split it into two smaller 45 45 90 right triangles. This is the basis of ROAM. If you''re using 100% arbitrary geometry, you might be able to (here I''m just coming up with an idea; I don''t know how good it is) recursively split each triangle into three smaller ones by splitting it along the three angle bisectors. (so that, if m is the intersection of the three angle bisectors of triangle abc, you make triangles mao, mcb, and mba). And, again, you "blur" it using a cubic interpolation function.

##### Share on other sites
TerranFury:

1. It can be any shape of 3D geometry (a cube was just a example).
2. The geometry is made up of triangles only.
3. The triangles are preferred to be isosceles triangles.

Is there any way to get the progression as shown above in my last
post using a different recursion technique other than angle bisectors?

##### Share on other sites
I tried smoothing several primitives in the demo version of Nendo, a modeling program, and tried to figure out how it did it''s work, but couldn''t really. It sort of looked like this might be what it did: It might work by combining adjacent triangles into a single quad, subdividing that quad into 4 smaller ones, and then using an averaging technique like I mentioned before. I guess it would have to combine triangles with the smallest differences in surface normals as possible. But it''s probably more complicated than just that, because the idea I just presented could at times yeild pretty bad results, I think!!!

I then tried some searches on Google and stumbled across something called "Laplacian smoothing," but then found this description: "Laplacian smoothing is the most commonly used and the simplest mesh smoothing method. This method adjusts the location of each mesh vertex to the geometric center of its neighbour vertices," which would indicate that it only makes existing geometry more regular; it doesn''t smooth a surface by adding more polygons. You might be able to arbitrarily add polygons and then use Laplacian smoothing though - but that seems to be my original idea - just with some fancy name attached, so that won''t do.

I know all that wasn''t too helpful really, but I figured I''d try to think of anything else I could. If I think of or find anything else, I''ll post it.

##### Share on other sites
Laplacian smoothing sounds interesting. Found some good links
on it too.

BTW, here''s an example of what I''m trying to achieve. This program
does exactly what I want to do:

MetasequoiaLE R2.1 - freeware
http://www1.sphere.ne.jp/mizno/main_e.html

Under "Command", select "Primitive", then select the rounded looking
cube icon. Then click "Property". Where it says, "Round" you can
enter the exact num. of edges you want for the cube.

##### Share on other sites
Try reading up on "subdivision surfaces." These really do sound like what you''re looking for. There''s an article at GamaSutra, among other places. http://www.gamasutra.com/features/20000908/lee_01.htm

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 33
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631745
• Total Posts
3002004
×