There is something I dont quite know abt smooth group,wot does it mean,and how can I use it to generate surface normal.Thx
p.s. Im workin on a data export plugin currently,and so how my normal didnt works in the right way,hope ya can help me.
There is something I dont quite know abt smooth group,wot does it mean,and how can I use it to generate surface normal.Thx
p.s. Im workin on a data export plugin currently,and so how my normal didnt works in the right way,hope ya can help me.
Without more info no-one is going to be able to help you.
A submesh, where the 3 vertices of a triangle have normals different from the triangle’s normal. In contrast, a flat-shaded triangle’s vertices have identical normals.
Defining a flat-shaded triangle usually requires unwelding of its vertices (making the triangle use vertices that are not used in any other triangle, can require cloning of vertices and modifying their normal).
Unlike in modelers, in OpenGL triangles store no data. They only contain the indices of the 3 vertices. Thus, without unwelding a vertex normal will be correct only for one of the triangles that use that vertex.
Smoothing groups may need to be separated/unwelded from the rest of the mesh, as in some cases they could overwrite another smoothing-group’s normals.
Nitpick:
It doesn’t seem like “Advanced OpenGL” topic. It’s not OpenGL at all, more like to be Math topic.
Nevertheless, the pseudo-code for the normal calculation from smoothing groups info is here:
vertex(i)_normal for face(j) = face(j).surface_normal
for each face(k) sharing vertex(i) with face(j):
if face(k).sm_groups intersect(&) face(j).sm_groups:
vertex(i)_normal += face(k).surface_normal
vertex(i)_normal.normalize()
I hope I wrote it correctly