1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Are you an artist or level designer going to Unite Europe? Join our roundtables there to discuss artist features.
    Dismiss Notice
  6. Unity 5.6 is now released.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

OBJ Loader

Discussion in 'Works In Progress' started by wccrawford, Dec 3, 2012.

  1. wccrawford


    Sep 30, 2011
    I recently saw a need for an OBJ loader that had a very permissive open source license. So I wrote one and put it under the MIT license.


    It's still pretty shaky and can use some error checking. And there are probably some features of OBJ format that I haven't implemented yet. But it should handle normals, UVs, and polys with more than 3 sides, so long as the poly is convex. (Concave polys are a lot harder to turn into triangles.)

    I was inspired to create this by the folks working on modding Desperate Gods to handle any board game, but I didn't want to have the code end up locked into their non-OS license. This way, those modders can use it, and so can anyone else that wants to.

    I've tried to structure it in such a way that it doesn't matter where the OBJ file comes from, it'll parse it. To that end, you simply pass it a string with the contents of the file. That way you can load it from disk or WWW, and it's all the same.

    MTL support isn't implemented, and neither are groups. I will probably add group support later. But MTL support is another issue. If I support that, I'll likely do it by implementing another separate parser, and making some Unity scripts that will help them work together.

    Oh, and it isn't optimized. It creates a new vertex for every point on every triangle. It should be sharing at least some of them. I'll look into this later.

    I'd love to hear of uses that people find for this, and any features that are missing that are needed. And bug reports, of course.