From BlenderWiki

Jump to: navigation, search

Transformation Constraint

Mode: Object and Pose modes

Panel: Constraints (Object context and sub-context, F7, or Editing context, F9, when in Pose mode)

Description

This constraint is more complex and versatile than the other “transform” ones. It allows you to map one type of transform properties (i.e. location, rotation or scale) of the target, to the same or another type of transform properties of the owner, within a given range of values (which might be different for each target and owner property). You can also switch between axes, and use the range values no more as limits, but rather as “markers” to define a mapping between input (target) and output (owner) values.

So e.g. you can use the position of the target along the X axis to control the rotation of the owner around the Z axis, stating that 1 BU along the target X axis corresponds to 10° around the owner Z axis. Typical uses for this include gears (see note below), and rotation based on location setups.

About Gears
Unfortunately, this will not work for gears, as there are some underlying problems related to the math, which means that this cannot work nicely…


Options

The Transformation constraint panel.
Target
This constraint uses one target, and is not functional (red state) when it has none.
Extrapolate
By default, the min and max values bound the input and output values, all values outside these ranges are clipped to them. When you enable this button, the min and max values are no more strict limits, but rather “markers” defining a proportional (linear) mapping between input and corresponding output values.
Let’s illustrate that with two graphs (The Extrapolate principles). In these pictures, the input range (in abscissa) is set to [1.0, 4.0], and its corresponding output range (in ordinate), to [1.0, 2.0]. The yellow curve represents the mapping between input and output.
The Extrapolate principles.
Extrapolate disabled: the output values are bounded inside the [1.0, 2.0] range.
Extrapolate enabled: the output values are “free” to proportionally follow the input ones.
Exclamation mark.png
Note that:
  • When mapping transform properties to location (i.e. Loc Destination button is enabled), the owner’s existing location is added to the result of evaluating this constraint (exactly as when the Offset button of the Copy Location constraint is enabled…).
  • Conversely, when mapping transform properties to rotation or scale, the owner’s existing rotation or scale is overridden by the result of evaluating this constraint.
  • When using the rotation transform properties of the target as input, whatever are the real values, the constraint will always “take them back” into the [-180°, 180°[ range (e.g. if the target has a rotation of 420° around its X axis, the values used as X input by the constraint will be ((420 + 180) modulo 360) - 180 = 60°…). This is why this constraint is not really suited for gears!
  • Similarly, when using the scale transform properties of the target as input, whatever are the real values, the constraint will always take their absolute values (i.e. invert negative ones).
  • When a min value is higher than its corresponding max one, both are considered equal to the max one. This implies you cannot create “reversed” mappings…
Sourc (on the left)
It contains the input (from target) settings.
  • The three Loc, Rot and Scale toggle buttons, mutually exclusive, allow you to select which type of property to use.
  • The X :, Y : and Z : min and max numeric fields control the lower and upper bounds of the input value range, independently for each axis. Note that if a min value is higher than its corresponding max value, the constraint behaves as if it had the same value as the max one.
Destination (on the right)
It contains the output (to owner) settings.
  • The three Loc, Rot and Scale toggle buttons, mutually exclusive, allow you to select which type of property to control.
  • The three Axis Mapping drop-down lists allow you to select which input axis to map to respectively (from top to bottom) the X, Y and Z output (owner) axes.
  • The min and max numeric fields control the lower and upper bounds of the output value range, independently for each mapped axis. Note that if a min value is higher than its corresponding max value, the constraint behaves as if it had the same value as the max one.
CSpace
This constraint allows you to chose in which space evaluate its owner’s and target’s transform properties.


Example

Let’s illustrate this constraint with a small “cog and rack” setup. We are going to use the translation of the rack to rotate the cog.

Setup and blend file

The cog_def and rack objects in the 3D view.

Modeling both objects is not the topic here, but for those interested, they were created by modeling one tooth, and then using the Array modifier.

Now, we have a rack of 20 teeth, and 10 BU long. The cog also has 20 teeth, which means one tooth corresponds to 360° / 20 = 18° of rotation. We are going to use the translation of the rack along the X axis, to rotate the cog around the Z axis.


You can download the blend file of this example at here: File:ManConstraintsTransformationEx.blend.


Cog constraint

We add a Transformation constraint to the cog, obviously using the track as target.

The Trasnformation constraint on the cog_def object.

In the Sourc settings, we enable Loc (we use the position of the rack), and set the input range needed along the X axis. As we can’t use the full length of the rack (else, at its end positions, its teeth will be no more in contact with the cog’s ones…), we will limit its translation to 8.0 BU, or 16 teeth. As its current position is “to the right”, the wanted range is [-8.0, 0.0].

Now, in the Destination settings, we enable Rot (we want to rotate the cog!). As we use the X value of the target to control the Z value of the owner, select X->Z in the Axis Mapping drop-down menu of the Z axis. Now, we limited the target translation to 8.0 BU, i.e. 16 teeth. Hence, our cog should only be allowed to rotate on 18° × 16 = 288°. Given the default rack position and cog rotation, the wanted range is [-288.0, 0.0].


Rack constraint

The Limit Location constraint on the rack object.

As we don’t want the rack to go beyond its allowed translation, we add to it a Limit Location constraint, with the same ranges as in the Sourc fields of the Transformation constraint.

Et voilà! You can move left or right the track, the cog rotates accordingly, as shown in the small video in (Transformation constraint example).


Reverse setup

Unfortunately, given the (quite strange…) behavior of this constraint when using rotation values as input, the reverse setup is not really possible. You could manage to translate the rack using the cog rotation, but only as long as this rotation remains in the [-180.0°, 180.0°[ range, else the rack will “spring back” to its original position each time you “crosses” the “180° border” (or 180° + n × 360° border to be precise...).