I would like to be able to constrain the possible X,Y and Z locations of an armature bone to within the 3D space inside a specified mesh object, such as a cube or sphere (and eventually a custom shape). I want to be able to move the bone anywhere inside the object, but not past the walls of the mesh. This would allow complex limits of a bone's location to be added in such a way that would erase the need for an animator to pay attention to the range of motion of a bone chain - they would simply be unable to exceed the realistic boundaries of the bone's location.
I have tried a few approaches, using a sphere as a basic example, which have so far been unsuccessful:
- Limit Location Transform Constraint = This works fine for setting cuboid limits on location (and so would work perfectly for setting bounds on a bone's movement within a cuboid space) however with spherical objects (or any objects which have a hole in them/don't fill their complete bounding box) this approach doesn't work such as the example below, where the selected bone is outside the sphere but still within the set maximum Z location of 1 and X location of -1. Therefore this method doesn't work with more complicated objects.
- Shrink Wrap Relationship Constraint = this is almost there as it limits the location of the bone (shown here in four different positions) to the surface of the sphere, so the bone cannot exceed the bounds of the object. however the bone cannot be moved anywhere inside the object (such as the selected bone in the centre), meaning that the bone isn't restricted to the entire volume of the object (and so able to be in any position within the object) but to its exact surface.
I've also tried using the Floor Relationship Constraint a bit but haven't been able to get this to work at all. It limits bone movement up to a specific plane rather than within a custom segment of 3D space.
EDIT.1: I've now tried using the Limit Distance Transform Constraint, but this only limits distance in a sphere around a point. therefore it won't work for limiting bone movement to within custom shapes or cuboids.
EDIT.2: I've been tinkering a bit more with the Limit Location Transform Constraint. I feel as if this is the most promising option as constraining a bone's movement within a specified bounding box is its entire purpose, however it only works for a cuboid shape and not a spheroid or more complex custom shape. I wonder if there's a way to adapt the code of the Limit Location Constraint to change it so that a target object can be selected that acts as the bounds within which the bone can move?
I don't intend to use this with a simple shape such as a sphere or a cube (etc.) but instead a custom shape which will represent the volume in which an armature bone that controls a character's mandible can move, so that the jaw doesn't exceed a defined range of motion. However I want to get to grips with a method on a simple object before I try anything more advanced.
I would also like to have a solution to this issue which uses blender's inbuilt features instead of a custom python script, however if necessary I'm willing to give this a go as well...
I doubt this is something which has never been tried before as it seems like a really useful concept to me. Any help is greatly appreciated.