Skip to content

obj files: usemtl before every face line #707

Closed

Description

@ov

I've got an OBJ file that has faces described like that:

# XSI Wavefront OBJ Export v3.0
# XSI Version: 12.0.921.0

...

usemtl base_label_sh
f 115/131/2 136/153/1 191/209/458 252/281/457 
usemtl base_label_sh
f 116/132/6 115/131/5 252/281/4 99/115/3 
usemtl base_label_sh
f 177/195/10 116/132/9 99/115/8 96/112/7 
usemtl base_label_sh
f 152/170/14 154/172/13 97/113/12 105/121/11 
usemtl base_label_sh
f 58/68/18 177/195/17 96/112/16 95/111/15 
usemtl base_label_sh
f 163/181/22 166/184/21 171/189/20 100/116/19 
usemtl base_label_sh
f 162/180/26 161/179/25 101/117/24 106/122/23 
usemtl base_label_sh
f 108/124/30 103/119/29 102/118/28 107/123/27 
usemtl base_label_sh
f 113/129/34 152/170/33 105/121/32 364/405/31 

So basically each new face has its own usemtl line with the same material. According to ObjFileParser::getMaterialDesc() you create a new object even if the material is still the same. I believe this only should be done if the new material name is different.

I can make changes to the code and submit a pull request, but need your approval first, as if this is against your design and will not be merged, I'll probably find another way to sort this out.

Activity

  1. acgessler commented on Dec 11, 2015

    @acgessler
    Member

    Please go ahead and submit a PR for this! Thanks

  2. ov commented on Dec 13, 2015

    @ov
    ContributorAuthor

    here you are: #709 - it builds well, but fails the regression test as I neither white-listed the file, nor re-generated the database, as the build system is too complex for that small fix.

  3. kimkulling commented on Dec 13, 2015

    @kimkulling
    Member

    Special for stuff like that: you are right. I will take care of your fix and thanks a lot for your pull-request,

  4. ov commented on Dec 13, 2015

    @ov
    ContributorAuthor

    @kimkulling cheers :) I've just added one more commit that trims whitespaces around material names. There is a similar code in another format reader, but as it is private I decided to make my own function. It is worth moving it out to a common file, I suppose.

  5. ov commented on Dec 13, 2015

    @ov
    ContributorAuthor

    @kimkulling I'm pretty happy with the latest fix test results and believe that the database needs to be updated for the failed files. It would be nice if you have a second look too, though.

  6. kimkulling commented on Dec 27, 2015

    @kimkulling
    Member

    I did, should be fixed now.

  7. added a commit that references this issue on Dec 11, 2023
  8. added a commit that references this issue on Feb 5, 2024
  9. added
    Wavefront-Obj
    on Apr 17, 2025
  10. added a commit that references this issue on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Wavefront-Obj

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions