I wrote this plug in purely for myself, to solve some very specific problems that have always bugged the heck out of me, so I’m not entirely sure how much relevance/help it will be for others, but I’m publishing it just in case there are other folks out there who might make use of it.
I use Cinema 4D for most of my modelling and texturing, and when I first started out I quickly found out that there were some problems with my workflow:
(1) Not all objects were imported from C4D files. Parametric objects in Cinema had to be converted to polygon meshes.
(2) The symmetry helper in Cinema would not be imported correctly, so I would only get one half of my mesh
(3) The HyperNURBS object was not handled, so I would not get the smoothed mesh I wanted but only the low res cage
These problems meant that my workflow would consist of a cycle of make changes, save, convert all to polygons, resave under a different file, etc etc.
(I should add here that things have improved with time, and now using when Cinema R12 with Unity 3.1/3.2 points 1 and 2 above no longer appear to be an issue. But as far as I can work out, 3 is still a problem. I realise that these things are not the fault of Unity itself, but limitations in Cinema/FBX export.)
And last but not least …
(4) Whilst it is sometimes convenient to model/texture multiple models in one Cinema 4D file, I often then find myself saving off bits and pieces of models into separate files for import into Unity. This quickly gets tedious. I wanted to automate the process.
(5) I might have objects in my modelling file that I did not want exported, for instance intermediate steps, guide objects or alternative ideas.
This very simple plug in helps me with all the above. In summary, it:
(1) Creates meshes of everything
(2) Allows saving of separate objects/hierarchies into separate Cinema 4D files
(3) Allows only specific objects/hierarchies to be exported, allowing me to keep other stuff in the C4D file and not worry about it getting into Unity.
(4) Leaves the original master file unaltered
(As regards (4), this is not quite true, as there is a “Keep” option which leaves the mesh versions in the original file. This was always more for debugging purposes than anything else.)
The version here is a Cinema R12 Python plug in, but I started with this years ago, so there is a version for older versions (R11.5 and earlier). If you need that version please let me know and I’ll clean it up for posting here.
The ZIP file contains the plug in, and a scene (export_helper_object.c4d) which is empty apart from the ExportHelper object, which is required for the plug in to function.
There’s also a sample scene (sample_scene.c4d), with some objects already linked to the relevant fields on the ExportHelper object. You still have to provide some file paths, though.
INSTALL:
To install the plug in, put the ExportToUnity folder into your Cinema 4D plug ins directory. I work on a Mac, and I put mine in:
/Applications/MAXON/CINEMA 4D R12/plugins/
(There is also a “user’s local” plug ins directory. I’ve not tested putting this in there, but there’s no reason why it wouldn’t work the same.)
On Windows there is a plug in directory at:
C:\Program Files\MAXON\CINEMA 4D R12\plugins
You need to quit and relaunch Cinema for the plug in to register. It will then appear under the Python menu → Plug ins submenu.
OPTIONAL:
It helps to create a toolbar button that calls the plug in. If you do this the button should display a Unity logo on it. (Hint: Use the Command Manager, to be found under the Window menu → Layout submenu.)
USAGE:
Copy and paste the ExportHelper object into your scene. It’s simply a Cinema 4D Null object with a load of User Data fields attached to it. (Yes, clunky, I know.)
There are ten “slots” which you can use to define which objects/object hierarchies get exported. For each you specify a directory to export to. (Either by typing it in or using the select directory button to the right of the path field.) If you just specify a path, the filename of the exported file is derived from the specified object/hierarchy. If you prefer you can specify your own filename by adding it on to the end of the displayed path.
There is an “Active?” checkbox for each item, so you can turn exporting on/off on an item by item basis.
There is also an “Active?” checkbox for the whole ExportHelper object, I’m not sure what I was thinking when I did this, so it will probably be deleted eventually.
There is also “Keep” option. Checking this leaves the polygon meshes that were exported in your scene. This was more for my debugging than for anything else, but it does give you a way to check up on what is being created when you use the plug in.
With the “Keep” option checked, each exported mesh object appears immediately below the original object in the Object Manager.
The “Dynamic” option is a throwback to when I was tinkering with making the plug in so that it constantly updated the export files every time changes were made to any of the specified hierarchies. In this version it doesn’t do anything, so, like the “Active?” checkbox for the whole ExportHelper object it will probably end up getting deleted.
There is a report field at the bottom of the ExportHelper object’s data fields, where the plug in provides some feedback about what it has done. (It frequently does not update unless you collapse it down and then expand it up again. I’m guessing I’m missing a UI refresh call somewhere. It’s on the list of things to look at and fix.)
KNOWN ISSUES/GOTCHAS:
There is some basic error checking going on, but not a whole load. For instance, the plug in does check if the directory path exists, but some other situations are not checked for. I hope to improve this over time.
At the moment if you are editing an object in points, edges or faces mode, the plug in doesn’t clean up after itself very neatly (although you don’t lose any work, you just have to change tools and do some deletion of objects yourself as opposed to have the plug in do it all for you). So it’s best to only call the plug in whilst in the “Use Model Tool” or the “Use Object Tool”.
Textures: the plug in does not handle texture bitmaps, although any materials that are used are copied across into the export files without a hitch. This means that at the moment you have to move across any linked bitmaps into the appropriate Unity assets directory yourself. (Making this seamless and automatic is my number one priority when I get a moment.)
Saving: at the moment you run the plug in every time you want to export. Eventually I’d like to hook this in to Cinema 4D so that it automatically executes every time you hit command S or select “Save” from the File menu.
When I get a moment I intend to revise the old Cinema 4D SDK version so that users of Cinema 4D 11.5 and earlier can benefit too.
TESTING:
I’ve tested this with Cinema R12 on my Mac and with a time limited activated version of the R12 demo on Windows 7. I don’t have the resources at the moment to carry out more extensive testing.
If you find errors, have constructive criticism, suggestions, etc, please feel free to post/contact me.
HOW I USE IT …
I guess if people find this useful they will find their own way with it, but this is how I tend to use it:
UserHomeDirectory
→ MyGameProjectDirectory
→ -> UnityProjectDirectory
→ -> → Assets
I keep all my “master” Cinema 4D files in the “MyGameProjectDirectory” (or in their own folders within that directory), and then use this plug in to export to the Unity project’s “Assets” directory.
I find that with some judicious organisation of the master models I can avoid fiddling in the “Assets” directory with constant cycles of saving and/or exporting as FBX. I’m not very good at finalising models but like to constantly tinker and improve, and I personally find that using this plug in makes that process far less painful.
496931–17529–$ExportToUnity_v0.9.zip (48.9 KB)