My new plugin is nearing completion and I thought I’d show a little preview of it here…
Below are some excerpts from the included Readme file [Long/Wordy post warning!]:
------------------- S N I P ----------------------
I got frustrated by the inflexible way that C4D handles .obj files and decided that I could do a better job of it - this plugin package is the result…
Included in this package is a “Wavefront .obj File Format Import/Export Filter Plugin”. The current plugin consists of 2 new tags - a “Group Tag” and a “Region Tag” used to (optionally) specify ‘Groups’ and ‘UVMapper Regions’, along with the Import and Export filters with extensive output/formatting options. The plugin was written for/using the v7.303 and v8.5 C++ SDKs (PC ONLY - sorry) and has been tested in C4D v7.303, v8.207 and v8.503.
I guess I should start by describing some of the reasoning/issues behind writing this plugin… I primarily use C4D to produce clothing/props/models to be used in Poser. Poser supports several 3D formats, but I’m very familiar with the Wavefront .obj format, it’s very flexible, it’s ASCII (easily accessible) and it’s become the somewhat de facto standard among Poser artists. However, C4D’s implementation of the format leaves some things to be desired…
C4D .obj Export Issues:
all ‘materials’ from a particular mesh are condensed and combined into the first material listed on the mesh. This is probably the biggest problem I continually ran into. I might have a dozen or more material selections defined on a single mesh (skinhead, lips, nostrils, eyesockets, innermouth, gums, skinbody, fingernails, toenails, nipples, etc), but when I export the model, I was LOSING all of those material selections and had to recreate them using some external application (UVMapper, for example). It’s very easy to define these selections within C4D and can be quite a pain to do in other applications… so losing them all on export sucks.
no real ‘group’ support and/or inflexible group support, where it exists. Basically, C4D creates ONE group record for each ‘mesh’ (a separate group of polygons) contained in the document and the group name is basically made up from all of the grouping hierarchy used within the C4D tree, so you might end up with something like:
…as a group name in the .obj file (note that the ':'s are added by C4D on import - they are spaces in the .obj file). This is perfectly valid and probably a reasonable approach (C4D is a general-purpose 3D editor and not designed around the .obj file format), but the file format allows for MULTIPLE groups per mesh, which can all share the same set of vertices (see the import section below for additional issues related to this).
Anyway, a typical Poser humanoid character might have dozens of groups within the same ‘mesh’ (head, neck, chest, abdomen, hip, left collar, right collar, left shoulder, right shoulder, left forearm, right forearm, lots-o-finger-segments, you get the idea…). Short of creating separate ‘meshes’ for each of these ‘groups’, there’s no way of defining them within
normals are ‘reversed’. This one is no big deal really… they had to pick a direction, but the one they picked doesn’t happen to coincide with Poser’s idea of which way they should face (or even C4D’s, for that matter, so I guess they get a ‘bonk’ for this one as well ;). Anyway, the normals can be flipped around on import to Poser, export from UVMapper or prior to export in C4D, but the new plugin makes it easy to get it right to start with.
no support for UVMapper ‘regions’. As far as I know, ‘regions’ are something Steve Cox (author of UVMapper) came up with and implemented as an extension to the .obj format (using comment fields), so this issue is clearly not an omission with the C4D code, but I thought it would be handy to be able to define these while modelling, to help with UV Mapping and layout later on (these ‘regions’ are just another way of grouping polygons together, but they are separate from and can ‘span’ across group boundaries, which makes them very useful).
C4D .obj Import Issues:
Material import… while C4D drops the ball on exporting materials, it actually does retain/recreate the proper polygon selections on import. I guess my only real issues/complaints here is the choice of naming of those selections (“Selection 1” … “Selection 2” … “Selection 3”, etc.). Why not just use the material name(s)? And the fact that it makes no attempt to actually read the .mtl file and reproduce any of the desired material settings.
Groups. This is a tough one and I can’t really cast to much blame for this one. Programmatically, it’s very difficult (very time-comsuming, at the least) to determine the ‘intent’ of how a .obj file should be broken up upon import into separate meshes. There are a couple of obvious choices…
a) create one big mesh, and create polygon selection tags for each ‘group’ record.
b) create a separate mesh for each group record.
…C4D chose option ‘b’. Unfortunately, neither of those options is optimal in all situations, though option ‘a’ would have been less ‘destructive’. By that, I’m referring to the fact that implementing option ‘b’ means creating new vertices at the seams between what used to be group selections of the same mesh. This can screw up vertex ordering, for things like morph files.
Loss of UVMapper regions. Again, I’m not casting blame on this one, but an import filter could preserve (recreate) these as polygon selections.
Lack of additional import options. There are no options to flip normals or textures or… well, any options, aside from the scaling factor.
Ok, so now you know some of the issues I was trying to address and while I was at it, I came up with some additional features to add flexibility. The plugin itself is made up of two new Tags, as well as an Import and Export plugins. Below I will describe the role and function of each.
This is a new tag that can be attached to your polygonal mesh objects (Editable Meshes). To add one, right-click on the mesh name in the Objects Tab, then select “New Tag->Plugin Tags->Group Tag” (or just “New Tag->Group Tag” in v8.x) from the menu. A dialog will open, displaying all available/current (and named, btw) ‘Polygon Selection Tags’. You can move these from the ‘Available’ to the ‘Selected’ list (and back) by highlighting them with the mouse and clicking on the appropriate arrow gadgets.
By moving a selection to the ‘Selected’ list, you are basically defining that polygon selection as a ‘Group’. The export filter will scan this list of selections and create the appropriate group records within the .obj file. The tag itself will be saved/loaded with your .c4d file.
This new tag functions identically to the Group Tag outlined above. To add one, right-click on the mesh name in the Objects Tab, then select “New Tag->Plugin Tags->UVM Region Tag” (or just “New Tag->UVM Region Tag” in v8.x) from the menu.
By moving a selection to the ‘Selected’ list, you are basically defining that polygon selection as a ‘UVMapper Region’. The export filter will scan this list of selections and create the appropriate region records within the .obj file.
.obj Export Plugin
Once the plugin is installed, a new option shows up in the Plugins menu, named “Riptide”. One of it’s sub-menus is named “.Obj Exporter”. After selecting a filename, an export options dialog will appear. Below is a description of each option…
o Scale Factor:
This is used for scaling the output mesh and should be set to the same value as the C4D .obj import/export value.
o Export Faces
You can choose to export the polygon faces or not (morph files don’t need faces, just vertices, for example). Also enables the additional Face Sorting options…
o C4D Ordering
Writes out the facet (polygon) records in the order encountered in the C4D in-memory image.
o Sort By Material
Sorts facets (within each mesh) based on the material groups.
o Sort By Group
Sorts facets (within each mesh) based on the Group Tag selections.
o Sort By Region
Sorts facets (within each mesh) based on the Region Tag selections.
…just as background, it doesn’t adversely affect anything to change the ‘order’ facets are listed in the .obj file (unlike vertex ordering, which can redefine things to the extent that may break things like morph files). There are a couple of reasons that you might want to sort them differently, and most of them have to do with aesthetics (.obj files are human-readable ASCII text files) or file-size, but may also be relevant for application implementers who prefer a particular ordering.
o Reverse Faces
This reverses the winding order of the polygons (in effect, changing the direction that the ‘Normals’ point), which changes the direction that the polygons face. Since C4D itself uses the opposite face direction for determining backface culling, you should pretty much always leave this option selected.
o Export UV Coords
UV (sometimes called UVW) Coordinates are basically the texture coordinates… you can choose to export these or not.
o Flip UV Horizontally/Vertically
If your textures show up upside-down or flipped left->right in whatever external application you use, you can use these options to flip them around.
o Export Materials
Enable/Disable saving material groups. Note that these groups are saved based on the materials/selections you have set up in C4D. To get the expected results, you really should use the ‘Restrict to Selection’ feature of the material dialog. As implemented, a “default” material record will be written to hold any polygons that don’t belong to any other material group.
o Export Groups
This option determines whether any group records are written to the exported file and also enables the additional group options on the dialog…
o Mesh Names
determines whether the mesh names are written to the file (default C4D behavior is to write out the mesh names as groups).
o As groups
mimic C4D .obj export functionality
o As UVMapper Regions
write the mesh names out as UVMapper Regions instead of Groups (without using any Region tags, you can still create ‘region wrappers’ around the separate meshes being saved).
o Group Tag Names
determines whether the list of selections in the Group Tag(s) are saved as group records. As implemented, a “default” group record will be written to hold any polygons that don’t belong to any other group.
o Preserve Hierarchy
using the example given earlier, would produce “Hyper_NURBS:Symmetry:Eye_Base:Left_Eye” when enabled or just “Left_Eye” as a group name if disabled.
o Export Regions
determines whether the list of selections in the Region Tag(s) are saved in the output file. As implemented, a “default” region record will be written to hold any polygons that don’t belong to any other region.
.obj Import Plugin
The other sub-menu of the new “Plugins->Riptide” menu is “.Obj Importer”. This feature will allow you to import either a Wavefront format “.obj” mesh file or a Wavefront format “.mtl” material file (importing a .obj file can also import the specified .mtl file… see below for details).
If a .mtl file is selected, that file is read any existing materials in the active document that are named the same are updated with the new information. New materials are created for any uniquely named materials found in the file. If a .obj file is selected, an Import Options dialog will open, with the following options…
o Scale Factor:
This is used for scaling the input mesh and should normally be set to the same value as the C4D .obj import/export value.
o Import Groups
- Selection tags are created for any Groups within the mesh and a ‘Group Tag’ is created and set up to track them.
- If disabled, no Group Selections or Group Tags will be created (note that even if this option is disabled, you can still “Split by Group” and get separate meshes, who’s names are the group names).
o Import Regions
- Selection tags are created for any UVMapper regions found and a ‘Region Tag’ is created and set up to track them.
- If disabled, no UVMapper Region Selections or Region Tags will be created (note that even if this option is disabled, you can still “Split by Region” and get separate meshes, who’s names are the region names).
o Import Materials
- If the .obj file lists a mtllib and it can be found and read, Materials are created (or updated) using that information, otherwise they are created using some default settings (see information below about some re-mapping that takes place).
- Selection tags are created for any Material groupings and the selections use the material names (no more “Selection 1”, “Selection 2” … “Selection 34”, etc. (yay!)).
- Texture Tags are created for every material grouping.
- If disabled, no Material Selections, Texture Tags or Materials will be created (note that even if this option is disabled, you can still “Split by Material” and get separate meshes, who’s names are the material names).
o Import UV Coords
- If the mesh has UV (texture) coordinates, a UVW Coordinates tag(s) is created and added.
- If disabled, no UV Coordinate Tags will be created.
o Flip UV Horizontally/Vertically
These can be used to flip textures left->right or top->bottom.
o Reverse Faces
This option can be used to reverse the facets of the imported mesh.
o Don’t Split
The mesh is set up as one big Polygon Object (editable mesh).
o Split by Group
The mesh being loaded is split up into one Polygon Object per group record found in the file (ala C4D’s importer).
o Split by Region
The mesh being loaded is split up into one Polygon Object per UVMapper Region record found in the file.
o Split by Material
The mesh being loaded is split up into one Polygon Object per Material selection found in the file.
o Create New Document
When selected, the mesh being loaded is loaded into a fresh/new document.
o Merge Into Current Document
When selected, the mesh being loaded is merged into the current/active document.
------------------- S N I P ----------------------
Pricing and Availabilty:
At this time, pricing has not been established, though my intent is to keep it affordable (sub-$30.00 range). As for ‘when’, the best answer is “RSN” (Real Soon Now), or my other favorite “Two Weeks”. I’ll post here again once it’s available.
Thanks for your time… I’m happy to answer any qestions.