Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: obj file - smoothing groups

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    24

    obj file - smoothing groups

    I have an obj file which looks like this:
    Code :
    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 ?

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,290
    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".

  3. #3
    Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    253
    err
    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.

  4. #4
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,290
    The modeler already gives you the normals per face-vertex exactly the way you want them. No need to parse "s" yourself.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •