1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    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.