ObjReader - load .obj files at runtime

This has been around a while, but I didn’t have a separate topic for it. Version 2.0 is out now! ObjReader loads arbitrary .obj files at runtime…great for modding and other user-created content. It works on all platforms, and with all languages. Includes source code. Available on my site and the Unity asset store.

Yes, the ridiculously-overdue version 2.0 is out, with MTL support. Feature highlights:

  • Loads .obj files at runtime with a high degree of compatibility, quickly.
  • Can load .mtl files to use for materials, including texture loading (png and jpg format only).
  • Support for transparent and opaque materials.
  • Can override ambient, diffuse, and specular colors from the .mtl file with your own material.
  • Can have different groups in the same .obj file be separate GameObjects, or combined into one.
  • If combined into one GameObject, different groups can be submeshes or not.
  • Can compute tangents for use with bumpmapped shaders.
  • Can use supplied normals from the .obj file, or have them computed.
  • Can apply arbitrary scaling, rotation, and position to the imported mesh.

There are two functions, ConvertString and ConvertFile. With ConvertString, you can provide strings for the .obj and .mtl files that you can load from arbitrary sources, including the web. With ConvertFile, you provide a complete file path, and ObjReader will load that, and optionally look for the appropriate .mtl and texture files. Note that ConvertFile won’t work in a webplayer due to Unity restrictions on accessing external files.

If you have any questions, find any bugs, or have any feature suggestions, post them here. If you bought from my site and don’t have the latest version (currently 2.0), send me a PM with the address you used when buying. Update notices are sent out automatically for new versions, but you need to make sure you opt in to that (if you don’t, then I can’t send any update notices to you), and you might also want to check your spam folder.

–Eric

1 Like

Hi,

I’d like to buy this asset but i have some questions:

  1. Is this asset compatible with Android
  2. Is the loading time faster then Resources.load()?

We are using resources.load now but on Android it takes way too long to load the 3D model.

Thx!

Thanks, this is a great asset.

I haven’t tested it personally, but it works on iOS so there’s no reason it wouldn’t work on Android.

Resources.Load is very fast since it’s stored in native format and requires no conversion. I don’t think you’re having issues with Resources.Load per se; probably it’s something else like applying a mesh collider.

Thank you!

–Eric

I think the problem is that the model is around 18MB, which is a bit big for mobile.

Cool.

there is compiled dll :frowning: will not work on some platforms, can you include source code?

Managed dll files work on all platforms.

Managed dll files will not work on all platforms, not work on flash for example,

If all operations in the dll are supported by Unity’s flash platform, it will work. But as its api is far from complete, you are right and it is likely that it doesn’t work.

All of my utilities include source code; the description on the asset store specifically mentions this. If the DLL doesn’t work in Flash then I don’t think the source code would either, but Unity Flash publishing is discontinued anyway so it’s not really feasible to provide support for it.

–Eric

Thanks for reply,
why there is dll then? does source code of this dll included?

if not, i can’t modify or extend it, and if there any bugs i can’t fix them

As I already stated (and as the Asset Store description says), the source code is included. The DLL is also included for convenience; you use one other the other.

–Eric

1 Like

Hi~ I’m korean develoment for android unity3d wpf

It is very interesting to me, this is an asset.

Want to ask you a few questions to apologize

  1. Web Player platform support available?

  2. Do you require Unity Pro Version?

  3. Animation, texture features, such as methane real support?

  4. It is availabel that load .FBX object at runtime?

If possible, try to buy the contents of the above idea.

Have a nice day~

  1. It will work in a webplayer, although loading .obj files from a website currently doesn’t automatically load .mtl files. (Edit: it does now.)
  2. No.
  3. The .obj format doesn’t support animation. I was not able to understand the rest of this question.
  4. Only .obj files are supported.

–Eric

yesss! finally .mtl support!! thank you! :slight_smile:

Thank’s for your answer!!

The reason for the question of my third, because it import to the fbx object.

We just purchased from the Asset Store. Seems too work great and we like the ease of use. We tried importing an obj with multiple textures (three) and the importer seems to only import the first texture. We are exporting out of Blender 3D. Should the importer work with models using more than one texture? If so, Are there particular setting that we should be using during export?

Our .mtl file seems to be pointing to the correct textures. The .mtl file is as follows:

# Blender MTL File: 'None'
# Material Count: 3

newmtl Material
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd IMG_4071.JPG

newmtl Material.001
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd SH.jpg

newmtl Material.002
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd Image_2.jpg

The importer works with multiple textures. Are you using “combine multiple groups”? If so, you’d need to also use “use submeshes when combining” in order to have multiple textures. Otherwise the first material would be used for the entire object.

–Eric

Version 2.1 is out now; buyers from my website with update notifications turned on will have gotten an email, and I’ll be uploading it to the Asset Store next. Updated stuff:

Additions:
• ConvertFileAsync function, which automatically loads OBJ files from the internet, including MTL and texture files where appropriate. This includes a progress variable for the entire combined download. It’s also possible to download multiple OBJ files simultaneously.

Changes:
• Changed group detection, so more OBJ files are imported correctly (specifically, OBJ files generated by Sketchup, which are kind of weird, and possibly others).
• A few speedups, so OBJ parsing is ~10% faster.
• Better handling for files that aren’t actually OBJ files.

Fixes:
• Lines that start with whitespace are parsed correctly.

–Eric