Previous Thread  Next Thread

chat icon Triangulate and smoothing

ionte

Posted: Mon Jan 20, 2003 8:37 pm
Joined: 20 Jan 2003
Posts: 7
Hi,

I'm new to Blender and 3D-modelling in general as I'm primarily a programmer.

I've written an export tool in python to my personal 3D format. I use only triangles so I have to triangulate the mesh first. Now, if I use ctrl-t in blender or if I create triangles from quads my self I have the same problem. To compute normals I do for each vertex take the average of all connected surfaces normals. This works great most of the time, but there is one problem.

Imagine the following four quads:

Code:

+-+-+
| | |
+-+-+
| | |
+-+-+


Triangulated:

Code:

   A B
  +-+-+
1 |\|\|
  +-+-+
2 |\|\|
  +-+-+


This means that the vertex in the middle will get 2 average values from the quads at 1A and 2B, but only 1 value from 1B and 2A.

Do you have any comments on this problem?

Is there any good way to control normal generation in blender? Is there anyway to monitor normals (such as small lines sticking out of the vertices)?
Reply with quote


K-Zimir

Posted: Mon Jan 20, 2003 10:07 pm
Joined: 20 Jan 2003
Posts: 1
Hello,


Unforunately, I can only answer to the last question of your post : you can monitor faces normals as lines by selecting the "Draw Normals" option in the Edit Panel (F9). The normals will appear in blue in each face when you're in Edit Mode. I hope I've understood what you meant (I'm not English-speaking).

Hope this helps you. Good luck with your project. Wink
Reply with quote


ionte

Posted: Tue Jan 21, 2003 12:03 am
Joined: 20 Jan 2003
Posts: 7
Ah, how could I miss that... Thanks...

It only displays the face normals though, not vertex normals.
Reply with quote


LethalSideParting

Posted: Tue Jan 21, 2003 3:04 pm
Joined: 20 Oct 2002
Posts: 83
Hmmm. A peculiar problem, but I see where it's coming from. The way I see it, you have 2 ways to solve this problem, and both of them involve getting involved in the triangulation stuff itself. In short, you're probably not going to be able to do this inside Blender (unless you write a python script to do it....).

Anyway, back to my ideas. The first is a bit of a cheat - instead of sampling both triangles from 1A and 2B, you only sample one from each quad (since they came from a quad , their normals should be almost identical, so you shouldn't get any loss of accuracy.

The second idea....well, I'll let you decide how easy it would be to code it. You change your quads so that they look like this:

Code:

     +-+-+
     |\|/|
     +-+-+
     |/|\|
     +-+-+


This way, all your vertices will either be able to take 4 or 8 triangle normals for the average. But they'll all be right next to the vertex, so you should be OK?

Hope that was clear, and helped a little. By the way, are you sure that vertexes actually need normals for whatever you're exporting this stuff for? It's only faces that need normals (I think...) so that OpenGL knows whether to display them or not - I can't think of a reason you'd need vertex normals unless you were displaying stuff in 'points only' mode and wanted to remove hidden verts...

Or have I just missed the point completely? Wink

LethalSideParting
Reply with quote


ionte

Posted: Tue Jan 21, 2003 4:19 pm
Joined: 20 Jan 2003
Posts: 7
Well, I'm starting to think that the only way to solve this problem in all cases is to never, ever, never use quads when modelling!

You are right that a quad converted to two triangles should have almost identical normals (not quite, but yet). The problem though is that blender does not mind creating non-planar quads. That should not be allowed! It's *wrong*! Evil or Very Mad

When it comes to true planar quads I'll let it be up to the artist to create triangulated surfaces in a manner such as your example. It's too bad that Blenders triangulate-command doesn't do that by itself...

Oh, and yes, you do need vertex normals to create an illusion of a smooth, curved surface.
Reply with quote


ionte

Posted: Tue Jan 21, 2003 4:21 pm
Joined: 20 Jan 2003
Posts: 7
Ehm, as a matter of fact, a triangulated quad *should* have identical normals for the two triangles.
Reply with quote


eskil

Posted: Tue Jan 21, 2003 4:59 pm
Joined: 29 Oct 2002
Posts: 141
Here is my take on it:

I will divide the problem in to 2 different problems: triangulation and normal generation.

To do the triangulation there is 2 different approaches, the first one is to take each N-sided polygon and split it to triangles so that all triangles have as close to as possible the same corner angle (ideally all triangles generated would have 60 degree corners). This avoids very stretched triangle corner angles close to 0 and 180 degrees.

this is good for flat polygons, how ever if the N-sided polygons are non flat, there is an other way. depending on how you split a non flat N-sided polygon it will become concave or convex. witch one is best depends on if the surface is concave of convex. this can done by computing a vector that starts in the middle of the polygon, and ends at a the average of all mid point of the neighboring polygons. do a dot product, between this vector and the surface normal, if the output is positive it is concave surface, and if it is negative if is concave.

Ok so how do you compute the normals? for each vertex you average together the normals of the polygons connected to it, and (here comes the trick) you weight their values depending on the angle of the corner connected to the vertex.

That's it!

This may not be the easiest or fastest way to do it, but its the way I think its the best if you have the cycles to spare.

E
Reply with quote


ionte

Posted: Tue Jan 21, 2003 5:50 pm
Joined: 20 Jan 2003
Posts: 7
Thanks, that was some good ideas! Especially that last trick.

I'm thinking about an easier solution though: If I calculate all normals (vertice and surface normals) before triangulation I will avoid the problem. The downside is that I won't be able to recalculate them afterwards if i need to. But then I could use your method!

Thanks for the help!
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group