Alik Kadum

Alik Kadum

About Me

Connect

LOCATION
Not Specified
ウェブサイト

Houdini Engine

Availability

Not Specified

Recent Forum Posts

houdini .obj and .mtl files 2023年6月2日12:39

maxpleaner
This is an old thread but hopefully this info is useful to someone.

I didn't even realize the Labs OBJ Importer had `.mtl` support because it so consistently failed to work. I was even starting to script my own solution before I decided it might be worth searching the web, and then I ended up here.

In regards to why you would need such a thing - Obj files are incredibly common and they very often have a bunch of different textures applied to different prims. Personally I have mainly been playing with models ripped from old games, but I'm sure there issue could arise with newer models, too. For example, see the OBJ here https://www.models-resource.com/nintendo_64/elmosnumberjourney/model/22344/ [www.models-resource.com] which fails to apply the textures upon import.

It took a bit of digging around but I eventually realized the issue was a mismatch between the actual `shop_materialpath` attribute name and the one referred to by the auto-generated Labs Quick Material node. If you open the Labs Obj Importer's "Type Properties" and then "scripts" tab, you can see this assignment happening on line 17. Specifically, in this case all the actual `shop_materialpath` attributes were prefixed with `/mat/`, e.g. `/mat/material_71` but the Labs Quick Material referred only to `material_71`.

The fix is actually quite simple here, just need to modify the `re.replace` in the `clean_materialpaths` node to get rid of the `/mat/`. Attached is my modified Labs Obj Importer node which fixes this:

BEFORE:

nodename = re.sub(r"+", "_", nodename)

AFTER:

nodename = re.sub(r"+", "_", nodename)
nodename = re.sub(r"^/mat/", "", nodename)


I downloaded your HDA, because I don't understand Python. I found that your Quick Material node was locked with your paths to textures, with your materials count, and had to change the paths myself. This could have confused beginners as it confused me.
So I created a blank OBJ Importer node and made changes following your guide. Now it's working out of the box.
I attached the new HDA down below.

Thank you for your guidance and instruction!