Hi all,
I've got an obj file and the material definitions stored in a separate *.mtl file. Is there any way Houdini can import and separate the model based on above material information?
Another question, is Hoduini capable of exporting mtl files in any way? In fact I can build it myself, but I was wondering how do I include reference info in the exported obj file format?
Thanks
kuba
obj format and mtl files
10162 4 1- kuba
- Member
- 345 posts
- Joined:
- Offline
- Antoine Durr
- Member
- 321 posts
- Joined: 7月 2005
- Offline
kubaThe .obj file should in theory have material groups whose names match the contents of the .mtl files. So assuming that gwavefront properly does the conversion (gwavefront is what is run when you put a .obj filename into the file SOP's filename param), you can separate the various materials according to their groups.
Hi all,
I've got an obj file and the material definitions stored in a separate *.mtl file. Is there any way Houdini can import and separate the model based on above material information?
Another question, is Hoduini capable of exporting mtl files in any way? In fact I can build it myself, but I was wondering how do I include reference info in the exported obj file format?
Thanks
kuba
Going the other way, however, is not an option. Houdini does not store its materials in a way that is compatible with Wavefront material definitions.
However, given all this, you could write a program that gets called in the middle of a foreach on the material groups, extracts the correct material definition, stores it as a set of detail attributes, and then write a second program that gets run via the post render script, extracts the info from the detail attribs and rewrites .mtl files.
- kuba
- Member
- 345 posts
- Joined:
- Offline
Hey Antoine, Thanks for suggestions. I've come up with the easiest possible approach I could think of. My intention was not to reinvent a wheel again and write complete obj exporter from scratch. That's why all the repartitioning is done in the post-render script - after obj file is created. Based on groups saved in that file, I created material definitions and stored in the separate mtl file. These are currently just names - but it is enough. The obj file needed to be rewritten and the material definition line inserted just infront each geometry group declaration. Hope that makes sense.
The otl file is included.
Cheers,
kuba
The otl file is included.
Cheers,
kuba
- Antoine Durr
- Member
- 321 posts
- Joined: 7月 2005
- Offline
kubaYou might also want to check out the GEOio file. It defines what to do when you save a file called ‘.obj’ (instead of .geo or .bgeo). It sees the .obj, and calls gwavefront. It could also call an arbitrary additional list of scripts to do the post-munging of the .obj file
Hey Antoine, Thanks for suggestions. I've come up with the easiest possible approach I could think of. My intention was not to reinvent a wheel again and write complete obj exporter from scratch. That's why all the repartitioning is done in the post-render script - after obj file is created. Based on groups saved in that file, I created material definitions and stored in the separate mtl file. These are currently just names - but it is enough. The obj file needed to be rewritten and the material definition line inserted just infront each geometry group declaration. Hope that makes sense.
The otl file is included.
Cheers,
kuba
Me personally I'd end up doing a Perl one-liner, something along the lines of:
gwavefront stdin.geo foo.obj ; perl -i -pe ‘s/g (.*)/g $1\nusemtl material$1/’ foo.obj
in a unix SOP (code above not tested).
- twelveplusplus
- Member
- 194 posts
- Joined: 8月 2011
- Offline
kuba,
i don't really understand how to use your otl file..
First i'm using Houdini 11, which maybe is the problem?
Am i supposed to save an OBJ, and then specify that filename in the “Output File” field of your ouputmtl sop?
When i press “render” I just get 3 files…
one of them is the original *.OBJ which becomes a blank file.
next is one called *OUT.OBJ which has one line “mtllib *OUT.mtl”
last is called *OUT.MTL which has one line “newmtl material0”
Am i doing something wrong or is this just not gonna work in H11?
thanks.
~Maitland
i don't really understand how to use your otl file..
First i'm using Houdini 11, which maybe is the problem?
Am i supposed to save an OBJ, and then specify that filename in the “Output File” field of your ouputmtl sop?
When i press “render” I just get 3 files…
one of them is the original *.OBJ which becomes a blank file.
next is one called *OUT.OBJ which has one line “mtllib *OUT.mtl”
last is called *OUT.MTL which has one line “newmtl material0”
Am i doing something wrong or is this just not gonna work in H11?
thanks.
~Maitland
-
- Quick Links