Blender Fluids in Cinema 4D : The next Step

article_blender_fluids_new

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:
file.write(‘usemtl
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.

Download the xref object here.

The xref has 3 user settings.

1. filename:

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.

Blender Fluids Example from bernd salewski on Vimeo.

16 thoughts on “Blender Fluids in Cinema 4D : The next Step”

  1. This looks very interesting!!!
    But the link to the enhanced Xref is dead.
    I hope You’ll relaod the file.
    Thanks

  2. sorry for my late reply. What animation? the fluids from Blender? Try using the .obj format as I described here.

  3. Hi Otomo,

    Thanks a lot for your help and for this great tutorial. I have a question. How do you change the material of the fluid Container(Xref)?

    Thanks again,

    Enric

  4. hi, thanks a lot for your job
    a little precision concerning the step 5, I looked for the blender directory script for hours !!! I finally found it (macOS):

    In Finder.app navigate to the Blender.app
    Select Blender.app and from the Finder.app menu select “Show Package Content”
    “Contents” folder open in a new Finder window
    in this new window navigate to “MacOS” folder
    once in “MacOS” folder press “Command+shift+g” and in the popup write “.blender” [it’s a hidden folder; the DOT in the beginning is very important, don’t forget it]
    Now you should be able to see the “Scripts” folder

    just another thing, I suceeded just once to import well in C4D, could we have more precision for the export settings on blender?

    thanks a lot

    greengiant

  5. hi greengiant,

    thanks four your tips regarding the scripts folder on Mac OS. I am working on Win OS so I dont know anything about obstacles on the Apple platform.

    Concerning your question about Export Settings for Blender: I think I mentioned every setting I changed from the default settings. Maybe they changed in the last months. Blender is always changing, you know? And I didnt look it up quite a while. If you can share some news I am happy to include them here in the blog.

  6. When I export animation sequence with .obj… it only gives me 1 object. WHAT AM I DOING WRONG!!! I’ve been scouring the net for hours trying to figure this out.

  7. Hi
    I finally found the good setting for export, it’s working perfectly.
    Make sure you’ve selected “animation” first of all (I think this is your problem D3)
    Then select “apply deformer”, unselect “material”, as said by Otomo ans finally select “group” in the final part of settings.
    It should work like this.
    I think that settings like “apply deformer” and “group” are an obligation for a good export.

    Thanks again Otomo for your job

  8. the line on the script come with # , so i put another one o suprime it?
    thanks

  9. Thanks a lot for die Xpresso/COFFEE File.
    But how kann i expansion the Animation-Offset to 3000 frames?

  10. Hi,

    right click on userdata->animation offset->edit

    in the next window you can adjust the limits of the user data field to your needs.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

Comment moderation is enabled. Your comment may take some time to appear.