In my post from last year I have described in a summarized way how to use the fluid simulation of Blender with Cinema 4D. My conclusion at that time was that it is doable but you run into limits every way you turn, mainly because of the huge memory consumption caused by loading all frames of the animation into a c4d scene at once.
In the last weeks I had some time to play with Blender Fluids again.
This time my main interest was if the new xRef objects can be used to reduce the memory load by only referencing one fluidmesh per frame. A guy in a german Cinema 4D forum told me that of course it’s possible: Just reference the old, big, fat c4d-file (the one with the visibility flip switch, see my previous article) in a new file with an xRef object. Hit the button “Take Animation” and the fluid container file will play through the xRef. That sounded promising and I tried that way. But it still needs a lot of ram because when the xRef takes the animation from the referenced object, it doesnt only take the current frame. It loads much more. I can’t say what exactly. The memory load is smaller than as having the container file itself opened, but its still very high and you can imagine that with a more complex setup you will run into walls a bit later. But they are still solid.
So I experimented a while with my limited coffee skills and finaly my wasted hours where rewarded. I created an enhanced xRef object which will reference the fluid simulation and only loads one mesh at a time into memory. I feel very happy about this, because it allows for much bigger fluid simulations in Cinema 4D.
Here’s an overview of how it currently works. This is not a Blender Tutorial. 😉
1. Export your scene into .obj format.
Scaling factor = 1; Only the objects which are part of the fluid simulation.
This is for non-animated objects. Windows users can try the animesh-plugin for exporting animated objects via the .md2 format. m2d allows for position/scale/rotate animation as well as PLA Animation. Or try Collada, which is available in the new C4D 11 Release. Collada doesnt allow PLA as far as I know.
2. Import your scene into Blender with the wavefront importer.
This should work pretty much without running into problems.
3. Set up and run the Fluid Simulation
There is a comprehensive reference on all the settings on the blender site.
4. Export the Fluid Mesh as an animated Mesh via wavefront obj.
You will get one .obj file for every frame of the simulation. Deactivate “Material” in the export options, because you don’t want to export Materials. Activate “Animation” and “Selected”. Make sure that the Domain Object of the Simulation is selected while exporting.
5. Run a batch search/replace tool on the sequence of obj files.
You can use the freeware Replace in Files for that. Replace the line “usemtl(null)” with an empty string. This is done because it avoids having a default material sitting on every fluidmesh in the obj files. Which is a problem if you wanna define your own water material later on.
Update 8.12.2008: There is another way to get rid of the default materials in the obj files which is less hassle. Open the file “export_obj.py” from the Blender script directory in a text-editor. Search for the 2 lines starting with:
Put a # in front of the lines to comment them, so that they dont get executed.
This should get rid of the hassle to batch replace the materials in the obj files.
6. Use my provided enhanced xRef to reference the fluidmeshes in your scene.
The xref has 3 user settings.
reference the first file of the sequence here.
2. counter length :
this refers to the number of digits in the filenames. like”filename_0001.obj”. Adjust the numbers of digits in the filecounter here. In this example it would be 4.
3. animation offset:
adjust with which frame the animation should start. negative values allowed. A value of 25 would start at frame zero in the cinema timeline with the 25th fluidmesh in the sequence. A value of -25 would start with the first fluidmesh at frame 25 of the cinema timeline.
Probably you have to scale up the xref by 100 to get size of the fluids fit into your scene.
7. render your animation
and feel happy about the very low memory load of the fluidmesh.
This short article is NOT a comprehensive tutorial about using Blender together with Cinema 4D. It’s targeted at people who know how to setup Blender fluids. And who just wanna know how to use the fluids together with Cinema 4D in a memory friendly way.
I have already produced a video tutorial in german language where I speak about all this in a more detailed way. I am planning to release one in english, too. When I find the time to do so.
I hope this article will help some people to manage Blender Fluids and come up with some decent renderings of fluids in Cinema 4d.
Update: I added this short test animation where the above image was taken from.