8
$\begingroup$

I'm trying to make a "simple" accordion map in Blender 2.79, for animated and still render purposes. I will map graphics onto each face, and I don't want the faces to get stretched/distorted.

I do however, want to be able to create a hinge-type rig, to be able to fold open and close the map like an accordion without having to manually position each face edge (which would distort the faces anyways).

I looked into using an Armature, but the faces got distorted. I tried to use a Hinge constraint, but I if understand correctly, it would require each flap of the map to be a distinct element - I don't want that. I found solutions involving Weight painting, but I don't think I want any of the map's flaps to be anchored - also there is only one face per element and I don't know if Weight Painting is appropriate.

enter image description here

How can I rig this map properly to open it and close it without any distortion?

$\endgroup$
  • $\begingroup$ What you need here, above the answer from moonboots is a bit unclear to me. Could you develop about "move freely"? What is the overall context? $\endgroup$ – lemon Aug 13 at 6:28
  • $\begingroup$ I think I mean I want to fold/unfold the map, but I don't want a specific face of the map to be unmovable. It just needs to be (ideally) one single Object that can fold and unfold. I think it might be easier in a game engine but I want to do it in cycles. $\endgroup$ – MicroMachine Aug 13 at 17:38
  • $\begingroup$ What moonboots has proposed should meet your need (again). You'll have to pose the bones appropriately. Alternative could be placing the root bone at the center, but won't change so much the solution. If not enough, probably some specific python or AN would be a way, but if so you need to add more information editing your question. $\endgroup$ – lemon Aug 13 at 17:50
  • $\begingroup$ Ok thanks for the input. No harm in seeing if there are other suggestions coming along, is there? At the moment I'm rotating the flaps of the map in edit mode by moving the edges, and then scaling them back to the right length, until I can figure out Moonboots' solution which I'm not able to reproduce (for example in the first picture the edges of the map are visible but it's neither object mode + wireframe mode not edit mode since the bone isn't in wireframe mode?) $\endgroup$ – MicroMachine Aug 13 at 18:14
  • 1
    $\begingroup$ @MicroMachine, to display the wireframe for only one object, select it, go in the Properties panel > Data > Display, enable Draw All Edges and Maximum Draw Type > Wire. It allows to easily see the edges and therefore align the bones to them $\endgroup$ – moonboots Aug 16 at 12:16
8
+50
$\begingroup$

I guess the easiest way is to use hooks and constrains.

  1. Add Empties to the edges that should fold, and parent them to the first one (or the one that all others should fold to) Plane with empties

  2. Set a vertex-group for each empty (select edge) Vertexgroups

  3. Use the hook modifier to parent the vertex-groups to the emptys Hook modifier

  4. Add a limit distance constrain to each empty, use the next empty as target then reset distance and set clamp region to surface. Constrain kimit distance

Now you can scale the empty and the map is folding correctly Map unfolded Map folded

$\endgroup$
  • $\begingroup$ Much more clever than mine even if with the same ingredients! $\endgroup$ – lemon Aug 14 at 11:42
  • $\begingroup$ Using Keep Distance to effectively generate a rotation from a scale/translation is a very neat trick, which could be used in all sorts of places.. $\endgroup$ – Robin Betts Aug 14 at 15:15
  • 1
    $\begingroup$ Can you explain your steps more? I'm asking as someone who's used blender for 5 years. Blender crashes when I try to open your file. $\endgroup$ – MicroMachine Aug 16 at 21:33
  • $\begingroup$ Your answer is my favorite so far, but when I assign the Hook modifiers to the Empties and Vertex groups, the Map warps unexplicably. Also moving the Empties don't move the vertex groups so I must be missing something (even though the distance constraints work). Current workfile $\endgroup$ – MicroMachine Aug 19 at 22:00
  • 1
    $\begingroup$ I had a look at your blendfile, and there are 3 porblems. 1. Your distance-constrains are in the wrong direction. Your second empty should target the first one and so on (so the first doesnt have a constrain). 2. somehow your hook modifiers are buggy so just delete them and add them the same way. 3. your third vertexgroup has two edges selected. blendfile $\endgroup$ – VeloFX Aug 20 at 10:14
8
$\begingroup$

You could parent your map to an armature. I've set my own rigging, maybe there's a simpler one, someone will tell, it also depends on the animation you will need, but this is a start, and anyway the parentage With Empty Groups seems like the good solution to me:

  • First create a bone as long as the map, then subdivide it so that each bone has the length of a fold.

enter image description here

  • Now you need to organize your armature, i.e. the relations between the bones and the constraints. It all depends on how the map is supposed to fold. The most basic solution I've found would be this one: Select your 3 left bones and switch their direction with W > Switch Direction. Parent bone 3 to bone 4 or bone 4 to bone 3 (Keep Offset mode, and deactivate Inherit Rotation). After you've parented the map to the armature (see a bit further below), you'll just have to move the bones in Pose mode.

enter image description here

  • Another solution make it a bit more convenient to manipulate, but again, it all depends on your needs, so it may not fit: Switch some directions, parent the bones correctly. Bend the bones joints a bit. Create 3 vertical bones that will be you controllers, deparent them. Give them names. Switch to Pose mode. Give bones 1, 3 and 5 an IK constraint with the controllers as Target and a Chain Length of 1 (for controller 1) or 2 (for the other ones). Perhaps give the controller 2 a Copy Location constraint with controller 3 as Target, so that when you'll move controller 3 the controller 2 will follow. Give a Head/Tail of 0, a Space > Local Space / Local Space, and an Influence of 0.5.

enter image description here

  • Back to Object mode. Select the map, then shift select the armature, press ctrlP > With Empty Groups. It gives the object as many vertex groups as you have bones, but no vertex is assigned to any of these groups yet, consequently the bones can't control the object for the moment.

enter image description here

  • Now, whatever solution you choose, to assign each fold to its vertex group, switch the object to Edit mode / Face select. Select a face and in the Properties panel > Data > Vertex Group, select the vertex group it is supposed to be part of, i.e. the group with the name of the bone that is supposed to control it.

enter image description here

  • Once done, your mesh should bend when you move the controllers.

enter image description here

$\endgroup$
  • $\begingroup$ Really nicely done. Really clear. $\endgroup$ – Robin Betts Aug 10 at 15:02
  • $\begingroup$ thanks but I'm not sure about the armature organization, maybe there's a more optimal one, also, it really depends on what the map is supposed to do, I've explained this one because it allows to fold easily $\endgroup$ – moonboots Aug 10 at 15:15
  • $\begingroup$ Thanks, nice answer. I'm struggling to reproduce, starting at "parent the bones correctly" - it seems my subdivided bone is janky, when I parent bones they start moving or overlapping... $\endgroup$ – MicroMachine Aug 12 at 18:23
  • $\begingroup$ (2) I am also fairly confused by the edit mode/object mode/pose mode interactions and cannot find a clear explanation of them, in this case also, it's not clear what's a child and a parent object since all of them should be able to move? $\endgroup$ – MicroMachine Aug 12 at 19:03
  • 1
    $\begingroup$ no it is not supposed to show, but if you deselect all and press on the Select button, it will select the group. You can also switch to Weight Paint mode, then select the group, and it will be displayed in red. $\endgroup$ – moonboots Aug 20 at 5:31
4
$\begingroup$

Using hooks and constraints

enter image description here

The setting uses 5 empties for the hooks and an empty as controller (the one selected in yellow below):

enter image description here

The 5 empties are placed at the folds and parented each other.

Hooks are indicated in green and parentings are indicated in red:

enter image description here

So the leftmost empty hooks the vertices on its left and is parented to the empty on its right.

At the end, on the right, the fourth empty is parented to the one on top, and the one on top hooks the four rightmost vertices.

Then the last empty which is the controller is used as rotation constraints for the previous empties.

enter image description here

The constraints for the fifth empties are based on Y (axis of the fold):

The leftmost has -Y constraint (Y and invert), the one on its right +Y constraint, etc. alternatively -Y and +Y to the last one.

enter image description here

Finally, we can animate all rotating the controller empty around Y.

To avoid the fold to go to far, the controller empty has also a constraint which limits its rotation:

enter image description here


How to hook:

  • Select the empty
  • Shift select the map
  • Enter edit mode
  • Select the vertices you want to hook
  • CtrlH then 'hook to selected object'

enter image description here


Edit: 2.79 version

$\endgroup$
  • $\begingroup$ What benefit would hooks have over an armature? (As in realistic use cases.) $\endgroup$ – Leander Aug 14 at 11:07
  • $\begingroup$ @Leander, nothing, practically. Except that the OP appears a bit lost with bones, pose mode, etc. And in another hand, this is just a play with another approach. No more. $\endgroup$ – lemon Aug 14 at 11:11
  • $\begingroup$ (@Leander nothing else and not 'no more' I mean) $\endgroup$ – lemon Aug 14 at 11:19
  • $\begingroup$ I don't get how you use this solution to fold the map $\endgroup$ – MicroMachine Aug 16 at 21:41
  • $\begingroup$ @MicroMachine, when a map folds, that mean side parts are rotating around the fold. Empties here make so parts rotate. And to run them all, another empty parent them to drive their rotation. $\endgroup$ – lemon Aug 17 at 5:27
4
$\begingroup$

Corrective Shape keys.

enter image description here

In my setup here the the length of the edge between folds is 1. The folds are aligned to Y axis, the map sits on the xy plane..

  • Add a shape key, and enter edit mode
  • select every second fold edge and move them up GZ1 (1 being fold edge length)
  • Select all and scale to zero SX0.

As helpfully pointed out by @RobinBetts, via comment, The shapekeys give a linear transform. The fold angle goes from flat 180 to closed 0.

Let N be the number of panels and v be the value of the shape key. The dimension as we move the shapekey value slider is width N * (1 - v) and the height is v

To make sure each panel maintains its unit length, will set up a driver on the z scale of the object. Pythagorean trigonometric identity

import bpy
from math import sqrt
def scale(v):
    # end points Ok
    if v == 0 or v == 1:
        return 1
    else: 
        s = 1 - v # base length
        # scale such that hyp is 1
        return sqrt(1 - s ** 2) / v


bpy.app.driver_namespace["scale"] = scale

enter image description here

so, for example, instead of having dimension.z 0.5 at v = 0.5 it is scaled by 1.732 such that dimension.z = 0.866 making it an angle 60, 30 right angle triangle instead of 45, 45 maintaining hypotenuse 1.

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Perfectly good close approximation.. but it is one.. using translations in place of rotations (so edge lengths not constant while folding). But for most practical purposes, why not? $\endgroup$ – Robin Betts Aug 14 at 10:43
  • $\begingroup$ Oops, to the naked eye looks ok, but will need to drive the z scale to compensate $\endgroup$ – batFINGER Aug 14 at 11:49
  • $\begingroup$ @RobinBetts fixed?. $\endgroup$ – batFINGER Aug 17 at 10:26
  • $\begingroup$ .. and without trig.functions.. ;D .. if I could UV again, I would. $\endgroup$ – Robin Betts Aug 17 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.