obj file - smoothing groups

I have an obj file which looks like this:

mtllib file1.mtl

# object f_00

v   x  y  z
vn x  y  z
vt  x  y

g g_00
usemtl mat1
s 1
f 1/1/1 2/2/2 3/3/3 
s 2
f 96/51/96 97/52/97 98/53/98 99/54/99 
s 1
f 104/55/104 105/56/105 106/57/106 107/58/107 

I know how to read a data when "f " record contains more than 3 group of indices. For processing a data I use following algorithm:

  • If that set of indices has not been seen before:
    ** Add the vertex attributes referenced by that index to the attribute arrays.
    ** Add the index of the new vertex to the index buffer.
    ** Store the fact that this particular set of indices has been seen before, and which index you used in the index buffer with it.
  • If that set of indices has been seen before:
    ** Retrieve the index for the index buffer that was stored for this set of indices.
    ** Add that index to the index buffer.
    ** Do not add any vertex attributes to the attribute arrays

The above obj file contains vn records and the algorithm process them properly so how should I interpret smoothing groups ? Are they necessary in that case ?

You don’t need to handle smoothing-groups.
The modelling app initially uses them to generate normals per face-vertex; later to subdivide (tesselate) just before raytracing.

You only need to handle the “vn”, and ignore “s”.

Normal groups are very useful. Say if you render a cube you don’t want to normals to be smoothed on the shared vertices for example. You would want it to look like flat shading and so have 6 normal groups …

as for parsing OBJ, good luck with that. It’s a horrible format.

The modeler already gives you the normals per face-vertex exactly the way you want them. No need to parse “s” yourself…