Forum: Poser - OFFICIAL


Subject: Those Messy, Messy .OBJ Files ...

bushi opened this issue on Sep 24, 2005 ยท 7 posts


bushi posted Sat, 24 September 2005 at 6:15 PM

Attached Link: ObjCleanup Script

From time to time, I've had problems with hand-editing .obj files. The editing is usually changing usemtls to g-type lines for creating groups. Most of the time, this is a pretty straight forward process except when the .obj is 'messy'. Instead of having the v-type lines, vn-type lines, etc. aggregated together, the .obj file has the different line-types spread out through the entire file. 'Messy' .obj files are much more difficult to successfully hand-edit simple because it's hard to keeo track of what has been done. This hasn't been that big a problem in the past since the 3D modelers I've used where pretty good about aggregating the line-types. That is until I started using Silo. Silo is relatively new and still has a few rough edges to work out. One of these rough edges is it outputs really 'messy' .obj files. As a solution I built a MacPython script that aggregates the line-types and does it very well. Though it is written in MacPython, it should work fine on any 2.3 Python platform. (I'd like to get some feedback on this if anyone tries it on a PC.)

Now as I was building the script, it occurred to me that I could include some functionality that would take care of my standard hand-editing task. Having it automatically change the usemtls to g-type lines would save a bunch of time as opposed to hand-editing. It also occurred to me that I could expand on this and end up with a script that did something very unique and useful.

Here's how it works. When you assign materials in a modeler, you get to assign a name for the material that is then written to the .obj as a usemtl statement. The script can recognize a specific format for the material name and split the name into a g-type line and a usemtl statement. The format looks like this:

usemtl /group_name/material_name/

And the output from the script when seeing the above line would look like this:

g group_name
usemtl material_name

What this does is give you the ability to assign multiple materials in a .obj group from the modeler's material editor rather then having to open the .obj in another program to do the assignments.

The image is an example of making these multiple material assignments. In Silo, I've opened the Materials Editor and assigned a material to the chest group of the model. I also have some piping around the edge that has been given a different material but will be included in the chest group. You'll notice that there are several groups but only two materials shared by all of the groups all of which are defined by the names in the material assignments. After exporting the .obj file and running it through the script, the g-type lines defining the groups and usemtl statements defining the materials are correctly placed in the .obj file. With no hand-editing of the .obj file! =)

I've tried this script with .obj files from both Silo and Wings3D and it works fine so I'd think it would work fine with any .obj file. Wings3D had no problem handling the embedded '/' characters when defining the material names. The split function is an option that is selectable when running the script so you can still aggregate the line-types in files that don't have the split usemtl lines. The resulting files are compatible with UVMapper.

You can download the script at the link. Please let me know how it works (or doesn't work) for you.


bushi posted Sat, 24 September 2005 at 6:21 PM

As an example result, here is Sylfie wearing the top from the first image. All of the piping on the shirt was from a single 'Piping' materials selection in Poser6 and setup in the .obj file using the split usemtls.

nruddock posted Sat, 24 September 2005 at 7:43 PM

EasyDialogs is a Mac only module.
On Windows the only dialog that doesn't have a direct tkInter equivalent is ProgressBar.


PabloS posted Sun, 25 September 2005 at 8:16 AM

bookmark


shogakusha posted Sun, 25 September 2005 at 10:27 AM

Bookmark!


bushi posted Sun, 25 September 2005 at 12:30 PM

Attached Link: EasyDialogs for Windows

@nruddock - Right you are about the EasyDialogs being native to MacPython. I knew I had seen some references to using EasyDialogs on Windows though so I did some checking. I've included a link to a page that has an EasyDialog module for Windows. I can't check how compatable it is with this script but it may be worth a try.

nruddock posted Sun, 25 September 2005 at 2:45 PM

Attached Link: http://sourceforge.net/projects/ctypes/

Just for completeness, EasyDialogs for windows need another module "ctypes" (see attached link). This appears to be for Python 2.3 and above, which would mean that it would be usable with a full Python install or Shade 7+ but not Poser.