An .OBJ file without normal information is painful: you cannot do any material stuff with it. In this situation, we need to calculate the normals by hand. This article shows a extremely straightforward method. And what happens when the object does not consists of triangles but quads ( > 3 vertices per face)? If we assume (and it always is) that the vertices are coplanar, we could simply calculate the normal of any triangle on the plane and regard it as the normal of the face.

Above is the theory of calculating normals. Practically, there are two steps:

1. Calculate the normals of each face (as indicated above in that article)

2. Calculate the normals of each vertex

This would be a little tricky. What I did was adding up each face normal to its vertices so that after calculating the face normals any vertex would have a sum of the normals belonging to faces that share this very vertex. And that is the normal of the vertex.

What’s even more tricky is: usually the normals calculated are not normalized and if you don’t want to do the normalization you need to specify:

glEnable(GL_NORMALIZE);

Otherwise it would be like … who knows?

### Like this:

Like Loading...

*Related*

## About Xiang 'Anthony' Chen

Making an Impact in Your Life

## Discussion

## No comments yet.