Blender Git Commit Log

Git Commits -> Revision c19baf8

Revision c19baf8 by Campbell Barton (master)
May 13, 2009, 00:20 (GMT)
[#18694] Added support for Wavefront OBJ groups for both the import and export scripts
from Paolo Ciccone (pciccone)

Im not that keen on this functionality since vertex groups in blender are for weight painting and OBJ's groups are more like sub-objects, The conversion between these is a poor approximation (one vertex group per face).
But this is still useful for using blender with poser so accepting these 2 patches.

Made some changes from the patch
*Export*
- vgroup off by default, since this is mainly useful for corner cases
- findVertexGroupName() - changed how exporting selects a vertex group for a face, use the highest combind weight for each group instead of the number of checking how many times the verts are in a group because they could have a zero weight.
- findVertexGroupName() - would fail if a faces verts were not in any groups, now return a (null) group
- Allow modifiers to export with vgroups

*Import*
- disable by default
- ignore (null) groups
- fixed a problem where the patch broke SPLIT_GROUPS
- move the group definition out of global namespace, breaks importing as a module.

--- Patch submission info
The import/export scripts included with Blender 2.48 don't save/preserve groups defined in OBJ file. This presents a
couple of issues: users loading an obj file with groups are not able to use a rather important set of data. When the
file is then saved the groups are lost bringing up both the issue of data loss and loss of functionality as groups are
used for rigging and morph target creation for Poser/DAZ Studio and all compatible applications. Of course other
animation/modeling packages that use OBJ files might be affected.

The solution that I present here simply patches the excellent python scripts written by Campbell Barton and Jiri Hnidek.
The new code implements the preservation of groups by creating Blender vertex groups during import and by re-writing
those groups in the OBJ file during export. Of course group ownership is idetermined at the face/polygon level and not
at the vertex level.

This rather simple solution makes Blender instantly one of the better tools to create Poser Morph targets (Full Body
Morphs) and conforming figures and clothing. Of course it's also adding a more complete support for the whole OBJ spec.

The patches are fitting well inside the established logic, have a minimal impact and are totally transparent to the
user. See the attached video (about 7 minutes long) for more details.

I noticed that the original scripts are formatted with tabs. I think it would be a good idea to follow the standard
Python recommendation and convert the scripts to use spaces. I didn't want to do it on my side as it would generate
a patch that replaces the whole file, not something that I wanted to do with my first submission :) But it would help
if people with access to SVN could do it.

Here is a short video that demonstrates the updates:
http://www.paolociccone.com/blender_obj_scripts.html

Cheers!
----

Commit Details:

Full Hash: c19baf85cca1ecdd0b07c35a61a4999bc27d1e6b
SVN Revision: 20179
Parent Commit: 9147124
Lines Changed: +133, -41

2 Modified Paths:

/release/scripts/export_obj.py (+79, -27) (Diff)
/release/scripts/import_obj.py (+54, -14) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021