Volume Split Plane
I recently needed to visualise water in a transparent container, as the container rotated, using Blender. I couldn't get either of the two water simulations to work (Domain based one could be hacked to work, but it always crashed before the several minutes of animation needed was baked. Particle based one leaked like a sieve when the container moved, and getting it to render right was rather unstable.)
Given that I didn't need a full blown water simulation - a simple plane at the correct height would do, I wrote a script to achieve this precise effect. Quite simply, it puts a plane so the volume of a mesh underneath said plane remains constant, moving the plane as needed to maintain this invariant. It also has a bunch of other functions, as they were just composite parts of this system, so I thought I might as well expose them. It includes calculating the volume of a mesh, which is quite useful as I own a RepRap, and use blender to generate meshes to print with it - knowing the volume gives me an idea of how much plastic is needed.
Anyway, its a standard Blender plugin for 2.63 onwards - just download the zip file and install in the Addons tab of the user preferences menu option:
split_volume.zip
It provides four operators, which may be accessed via the 'space' menu:
Volume:
Calculates the volume of a well defined mesh - the output appears momentarily on the top bar, but is also written to the custom property of the selected object, in the variable 'volume'. A well defined mesh is one with no holes, and no stray vertices/edges where the normals all point outwards and the geometry does not intersect with itself. Multiple separate chunks are acceptable as long as they do not intersect. This is not really the focus of this plugin, but as it was simple to add and might be of use to some people, e.g. people who use Blender to create meshes for 3D printers, it seemed sensible to provide it.
Record Volume:
Does exactly what volume does, but calculates it for every frame in the animation, and creates an animated custom property on the object with the name 'volume' - you can then see how the property changes as the animation is run, or use it to drive something. Added this because I could - not really sure what it could be used for. Possibly useful to drive a gauge on some complex machine? Might have a debugging use when animating an object that should not change volume (All modifiers are taken into account - it will factor in everything including armatures and shape keys, plus all other deformations.)
Split Volume: You select two objects - first a well defined mesh, then an arbitrary object that represents a plane. The plane can be any actual object - it assumes a plane in the x-y axes, which happens to match up with the plane provided by Blender. Note however that this is a true plane, i.e. infinite. The plane can then split the mesh in half, defining a volume above and a volume below the mesh (above is the positive z direction, below the negative z direction.). You define one of 3 custom properties on the plane object:
below - Contains your desired volume below the plane.
above - Contains your desired volume above the plane.
ratio - Defines how much of the volume should be below the plane in terms of the total volume, i.e. below = ratio * total_volume.
This operator then moves the plane the shortest distance to satisfy the constraint. In the event it is not possible to satisfy it the plane will end up at the extremity of the object that is closest to satisfying it. Main use is in testing values to find good ones to use for the below operator on the current frame.
Record Split Volume:
Does the exact same thing as split volume, except it makes the adjustment for every frame of the animation range and records the objects location in each position. Note that if you animate the custom properties of the plane (below, above or ratio.) it will satisfy the constraint for the correct animated term. Basically good if you want to model something related to volume, typically where the volume is held constant as something deforms. Most obvious example is water in a deforming container (Which can simply be a rotating container.). Deformations can be armature or shape key based, or form any modifier. The animation means you could fill an object with water at a constant rate accounting for the strange shape of the object - not the same as a real water simulation, but potentially useful in cases when that would be overkill.
Given that I didn't need a full blown water simulation - a simple plane at the correct height would do, I wrote a script to achieve this precise effect. Quite simply, it puts a plane so the volume of a mesh underneath said plane remains constant, moving the plane as needed to maintain this invariant. It also has a bunch of other functions, as they were just composite parts of this system, so I thought I might as well expose them. It includes calculating the volume of a mesh, which is quite useful as I own a RepRap, and use blender to generate meshes to print with it - knowing the volume gives me an idea of how much plastic is needed.
Anyway, its a standard Blender plugin for 2.63 onwards - just download the zip file and install in the Addons tab of the user preferences menu option:
split_volume.zip
It provides four operators, which may be accessed via the 'space' menu:
Volume:
Calculates the volume of a well defined mesh - the output appears momentarily on the top bar, but is also written to the custom property of the selected object, in the variable 'volume'. A well defined mesh is one with no holes, and no stray vertices/edges where the normals all point outwards and the geometry does not intersect with itself. Multiple separate chunks are acceptable as long as they do not intersect. This is not really the focus of this plugin, but as it was simple to add and might be of use to some people, e.g. people who use Blender to create meshes for 3D printers, it seemed sensible to provide it.
Record Volume:
Does exactly what volume does, but calculates it for every frame in the animation, and creates an animated custom property on the object with the name 'volume' - you can then see how the property changes as the animation is run, or use it to drive something. Added this because I could - not really sure what it could be used for. Possibly useful to drive a gauge on some complex machine? Might have a debugging use when animating an object that should not change volume (All modifiers are taken into account - it will factor in everything including armatures and shape keys, plus all other deformations.)
Split Volume: You select two objects - first a well defined mesh, then an arbitrary object that represents a plane. The plane can be any actual object - it assumes a plane in the x-y axes, which happens to match up with the plane provided by Blender. Note however that this is a true plane, i.e. infinite. The plane can then split the mesh in half, defining a volume above and a volume below the mesh (above is the positive z direction, below the negative z direction.). You define one of 3 custom properties on the plane object:
below - Contains your desired volume below the plane.
above - Contains your desired volume above the plane.
ratio - Defines how much of the volume should be below the plane in terms of the total volume, i.e. below = ratio * total_volume.
This operator then moves the plane the shortest distance to satisfy the constraint. In the event it is not possible to satisfy it the plane will end up at the extremity of the object that is closest to satisfying it. Main use is in testing values to find good ones to use for the below operator on the current frame.
Record Split Volume:
Does the exact same thing as split volume, except it makes the adjustment for every frame of the animation range and records the objects location in each position. Note that if you animate the custom properties of the plane (below, above or ratio.) it will satisfy the constraint for the correct animated term. Basically good if you want to model something related to volume, typically where the volume is held constant as something deforms. Most obvious example is water in a deforming container (Which can simply be a rotating container.). Deformations can be armature or shape key based, or form any modifier. The animation means you could fill an object with water at a constant rate accounting for the strange shape of the object - not the same as a real water simulation, but potentially useful in cases when that would be overkill.