Flux de travail et exemples

Voici quelques exemples de contrôleurs et de flux de travail.

Flux de travail

Transform Driver

Cet exemple vous montre la manière d’installer un contrôleur de transformation. D’abord, assurez-vous que vous êtes devant la vue Front Ortho. Numpad5, Numpad1.

  1. En Mode objet, sélectionnez puis dupliquez le Cube par défaut. Maj-D. Déplacez “Cube.001” à une nouvelle position.

  2. Avec “Cube.001” sélectionné, ajoutez un contrôleur à la propriété Rotation Y.

  3. Ouvrez le Graph Editor, mettez le Mode à Drivers.

  4. Show Only Selected is useful disabled for drivers, marked green in the picture.
  5. Dans la région des canaux, sélectionnez la propriété Y Euler Rotation.

  6. Pressez N pour ouvrir la région des propriétés, déroulez le panneau Drivers.

  7. Modifiez le Type en Averaged Value, ceci va retourner la valeur moyenne des variables de contrôleur.

  8. Modifiez les réglages de variable de contrôleur :

    • Type – Transform Channel
    • Ob/Bone – Cube
    • Transform Type – X Location
    • Transform Space – World Space
../../_images/animation_drivers_transform.jpg

When finished, “Cube.001” should rotate on the Y axis when moving “Cube” left to right.

Exemples

Driver Expression

Voici quelques exemples utilisant l’expression scriptée Expr pour fixer la Driver Value.

../../_images/animation_driver_object_rotation.png

Rotation d’objet.

Orbiter autour d’un point

Ici deux contrôleurs ont été ajoutés au Cube : Position X et Position Y.

Les expressions scriptées sont utilisées pour fixer la position de l’objet.

X Location Expr
0 + (sin(frame / 8) * 4)

(frame/8) : est la frame courante de l’animation, divisé par 8 pour ralentir l’orbite. (sin( )*4) : ceci retourne le sinus de (frame/8), puis multiplie par 4 pour un cercle plus grand. 0 + : est utilisé pour contrôler le décalage de la position X de l’orbite.

Y Location Expr
0 + (cos(frame / 8) * 4)

(frame/8) : est la frame courante de l’animation, divisé par 8 pour ralentir l’orbite. (cos( )*4) : ceci retourne le cosinus de (frame/8), puis multiplie par 4 pour un cercle plus grand. 0 + : est utilisé pour contrôler le décalage de la position Y de l’orbite.

frame est le même que bpy.context.scene.frame_current.

Driver Namespace

There is a list of built-in driver functions and properties. These can be displayed via the Python Console

>>> bpy.app.driver_namespace['
                              __builtins__']
                              __doc__']
                              __loader__']
                              __name__']
                              __package__']
                              acos']
                              acosh']
                              asin']
                              asinh']
                              atan']
                              atan2']
                              atanh']
                              bpy']
                              ceil']
                              copysign']
                              cos']
                              cosh']
                              ..

This script will add a function to the driver namespace, which can then be used in the expression driver_func(frame)

import bpy

def driver_func(val):
    return val * val    # return val squared

# add function to driver_namespace
bpy.app.driver_namespace['driver_func'] = driver_func

Shape Key Driver

Ce exemple montre un contrôleur de forme clé. Le contrôleur a été ajouté à la valeur de la forme clé.

../../_images/animation_driver_shape_key.png

Contrôleur de Forme clé. Cliquer dessus pour agrandir.

Cet exemple utilise la Rotation Z de l’os “b” de l’armature pour contrôler la valeur d’une forme clé. Le mode de rotation de l’os est mis à XYZ Euler.

The Driver F-Curve is mapped like so:

  • Bone Z Rotation 0.0 (0.0): Shape Key value 0.0
  • Bone Z Rotation -2.09 (-120.0): Shape Key value 1.0

Cette sorte de contrôleur peut aussi être installé avec le type de variable Rotational Difference.

Voir Formes clés pour plus d’informations.

Drivers And Multiple Relative Shape Keys

Les captures d’écran suivantes illustrent la combinaison de formes clés, d’os, et de contrôleurs pour construire des formes clés chaînées partageant une simple racine. Bien que cela n’ait pas l’avantage du Evaluation Time d’une forme clé absolue, cela vous permet d’avoir des relations plus complexes entre vos formes clés.

../../_images/animation_driver_workflow_for-multiple-shape-keys-key1.png

Key1 must handle conflicting values from the two bones.

../../_images/animation_driver_workflow_for-multiple-shape-keys-key2a.png

Key2A has different generator coefficients so it is activated in a different range of the bone’s position.

../../_images/animation_driver_workflow_for-multiple-shape-keys-key2b.png

Key2B est le même que Key2A, mais est contrôlé par le second os.

../../_images/animation_driver_workflow_for-multiple-shape-keys-retracted.png

When both bones are low, Key2B and Key2A are deactivated and Key1 is at low influence.

../../_images/animation_driver_workflow_for-multiple-shape-keys-extended.png

The Basis shape key has the stacks fully retracted. Key1 has the base fully extended. Key2A has the left stack fully extended. Key2B has the right stack fully extended. Key2A and Key2B are both relative to Key1 (as you can see in the field in the bottom right of the Shape Keys panel.

The value of Key1 is bound to the position of bones by a driver with two variables. Each variable uses the world Z coordinate of a bone and uses the maximum value to determine how much the base should be extended. The generator polynomial is crafted such that the top of the dominant stack should line up with the bone for that stack.

The value of Key2A is bound to the position of “Bone.L”. Its generator parameters are crafted such that when Key1’s value reaches 1, the value of Key2A starts increasing beyond zero. In this way, the top of the left stack will move with bone.L (mostly).

The value of Key2B is bound to the position of “Bone.R”. Its generator parameters are similar to Key2A so that the top of the right stack will move with bone.R (mostly).

Since it is quite easy for bone.L and bone.R to be in positions that indicate conflicting values for Key1 there will be times when the bones do not line up with the tops of their respective stacks. If the driver for Key1 was to use Average or Minimum instead of Maximum to determine the value of the shape key then “conflicts” between bone.L and bone.R would be resolved differently. You will choose according to the needs of your animation.