1
$\begingroup$

(new to blender) i need to have an effect of the highlighted center object (softbody) to appear to "float" within the outer object (also softbody).

slime

i want to use this later to make animations so that the "core" is generally around the center of the outer membrane.

after reading a few things, it seems like "Goal" is the way to get this to work properly with softbody physics but i'm not sure how to set the vertex group properly. HELPMEPLZ

$\endgroup$

2 Answers 2

1
$\begingroup$

There are basically three different (scriptless) solutions to achieve your end goal, and they're all going to be subtly different.

The first option, which you've started thinking about, is to use two different soft body objects, and to use goal to limit the motion of the interior body. First, create a vertex group on your outer body (named "location"). Then, give your interior body a Copy Location constraint, targeting the outer body, and specify "location" as a vertex group. This will allow the inner body object to acquire the position of the outer body vertices (average). Then, simply enable goal on the inner object and tune parameters:

enter image description here

Note that there is no real collision, and strong motion can still override any goal of less than 1.0. You can consider adding collision to the outer body, although it can impact performance heavily, and you risk trapping the inner body outside of the outer body whenever collision fails.

There are alternatives to a copy location constraint, including vertex parenting. The main thing is, you need to follow the soft-body-deformed vertices, not the object.

The second way to do this is to use collision. When I'm doing interacting soft body simulations, I like to use a single soft body with self-collision-- I find it's more reliable:

enter image description here

The most important parameter there is "ball size". Soft body collision is actually collision between invisible spheres centered on each vertex. As you increase the ball size, collision will improve, but the interior ball will be constrained to a smaller and smaller interior area. As you decrease ball size, the interior ball will become more able to reach the outside surface, but some of the balls might be able to slip between gaps, causing your collision to fail. If you need higher quality collision, you need more verts, with small ball sizes, so that each vert can have a small sphere without leaving any gaps.

The third way to do this is by creating springs inside of your soft body to join the inner sphere to the outer sphere-- to hold it inside, and to transmit forces. For this, I'm going to have a single soft body object, and in addition, I'm going to make it non-rendering, with a viewport wireframe display-- I'll use surface deform modifiers to copy whatever the soft body does onto a rendering mesh. Why? Because we're going to massacre its topology.

Start editing the combined softbody. Create additional edges between the vertices of the inner sphere and the outer sphere. Not faces-- just edges. Soft body physics works by transmitting forces along edges, and so this will create forces between the inner and the outer sphere. In this pic, I've created 14 new edges:

enter image description here

There is one other solution I should mention, which is the simplest and fastest, but also the least physical. That would be to just use soft body physics on the outer sphere and to create the inner sphere by a post-physics Solidify modifier with a material offset.

$\endgroup$
1
$\begingroup$

If this enter image description here is what you want, read the following:

The goal property tells your softbody where (location) it should be and how it should look (shape resulting out of shapekeys or other modifiers). So, a good option is to just keyframe your inner mesh to be inside your outer mesh at every frame, after the outer mesh has an already baked softbody-simulation. Then, because of the keyframed locations and the goal property of your inner softbody, it should look like it tries to stay inside the outer softbody. However, because we value our sanity, we don't want to do this by hand. Blender has the option to automatically calculate a new point of origin (that small orange dot inside of every mesh) of an object based on its current shape or other properties (Object -> Set Origin), for instance trying to put it into the average middle-point of your object. So, for good results we can just have blender calculate a new point of origin for each frame based on the outer mesh's current shape and then keyframe the inner mesh to be at the location of that new point of origin. Because you can't keyframe the point of origin itself however (and because the calculation doesn't take the softbody-modifier into account), I had to create a script which does what we want:

#hello user
#please specify the desired framerange of your animation
first_frame = 1
last_frame = 250
#to run this script, have both the outer and inner mesh selected, with the outer mesh being the active object. (=> Select it last, it should have an yellow-orange outline instead of orange-red)
#then just press the "Run Script" Button in the top right corner of this text-editor.



import bpy

outer_mesh = bpy.context.object
outer_mesh.select_set(False)
inner_mesh = bpy.context.selected_objects[0]


for x in range(first_frame,last_frame+1):
    bpy.context.scene.frame_set(x)
    bpy.ops.object.select_all(action='DESELECT')
    outer_mesh.select_set(True)
    bpy.context.view_layer.objects.active = outer_mesh
    bpy.ops.object.object_duplicate_flatten_modifiers()
    t_m = bpy.context.object #(temporary_mesh)
    t_m.location        = outer_mesh.location
    t_m.rotation_euler  = outer_mesh.rotation_euler
    t_m.scale           = outer_mesh.scale
    bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_VOLUME')
    inner_mesh.location         = t_m.location
    inner_mesh.keyframe_insert(data_path = "location")
    bpy.ops.object.delete(use_global=False)

How to use:

  • First, you need to have an addon enabled - "Corrective Shape Keys". To do so, go into your blender preferences, and under the tab "Add-ons" search for its name, then just check the box left to it. enter image description here
  • Second, get the script into your blend-file. Get to the text-editor (one is in the "Scripting" workspace by default), click on "New" to create an empty script and just copy-paste my script in there.enter image description here

After that is done:

  1. Bake the softbody-simulation of your outer mesh
  2. If not done yet, create your inner mesh. The location of it doesn't really matter here
  3. Select your inner mesh and then your outer mesh as well (outer mesh last so it's the active object, shown by a yellow outline instead of red)
  4. In the first lines of the script, specify the frame-range of your softbody-animation and then press the fat "Run Script" button in the top right corner. Wait for the script to finish. Now your inner mesh has the individualy calculated point-of-origin-locations of your outer softbody keyframed.

(The script uses the "Origin to Center of Mass (volume)" option, but you should be able to edit it to use the other ones; in the script change 'ORIGIN_CENTER_OF_VOLUME' to one of the following: 'ORIGIN_CENTER_OF_MASS', 'ORIGIN_CURSOR','ORIGIN_GEOMETRY', 'GEOMETRY_ORIGIN'. I didn't test this myself though.)

  1. If not done already, give your inner mesh a softbody-modifier and bake it with your desired properties.

    • Obviously, in its properties check the "Goal" box to enable it, if it isn't already. You don't need to use a vertex group as a goal since that just changes how much certain vertices are affected by it.
    • You probably want to experiment with mass and gravity values of your mesh. Know that you can for instance set its mass to 0kg to not have it be influenced by gravity and show almost no inertia, or that you can set the gravity to 0 in the Field-Weights section, then however being able to keep the mass of your object above 0 to see effects of inertia without it falling down.
    • You can significantly increase the object Friction (found above its Mass) to make it look like it's in jelly instead of thin air.

Optional addition: Preventing the inner mesh to clip outside of your outer mesh. Done by using the outer mesh as a collision object:

  1. Select your outer mesh and go into edit mode
  2. In the Viewport Overlays dropdown menu enable "Face Orientation" (in the geometry tab). Now your meshes look all blue on the outside, and red on the inside.
  3. Select all faces of your mesh, and then flip their normals (Mesh ->Normals ->Flip). Now the mesh should be red on the outside and blue on the inside.
  4. Go back to object mode and give your outer mesh a collision modifier.
  5. Bake the softbody-simulation of your inner mesh again. It should now not clip through your outer mesh in most cases. Also experiment with the "Thickness Outer" property of your collision-outer-mesh. A value of 0.1 is equal to 0.1 meters. A small value means your Softbody can in some cases actually look like it touches the surface of your outer mesh, which you probably don't want.
  6. Once satisfied with the result, flip the normals of your outer mesh again to prevent shading- and other issues.
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .