Q: I need an expression for moving planar-mapped cartoon eyes using a Dummy.


A: The first thing to keep in mind when solving this problem is that there are 2 different ways for controlling the position of a texture on the mesh:
  • The first is the UVW-Gizmo Position
  • The second is the Texture Map Offset (U and V) in the Material Editor.
    Both methods are very well-suited for Expression animation. Let's take a look at each one of them...

    ANIMATING THE UVW GIZMO

  • Create a sphere.
  • Change the name to "Eye-Right".
  • Turn Hemi option on and enter 0,5 to get a Hemisphere.
  • Using Non-uniform scale deform it to become almost flat.
  • Apply an UVW Map Modifier, set to Flat.
  • Make sure the slash on the gizmo points up.
  • Create an Eye Material and assign to the Sphere.
  • Click on "Show Map in Viewport".
  • Use Bitmap Fit and Sub-Object Gizmo scale to fit the Bitmap to the Eyeball.
  • Create two Dummies in front of the Eyeball.
  • Align them to share the same Pivot position (Align/Center-Center/X,Y,Z)
  • Select and freeze Dummy01.
  • Create a Star Shape somewhere in the scene.

    Now it is time to animate.

  • Open Track View.
  • Expand the tracks
  • Find the Star Shape and select the Star Points track.
  • Click on "Assign Controller" and assign a Linear Float.
  • Find the UVW Map track, select the Gizmo/Position controller.
  • Click on "Assign Controller" and assign an Expression Float controller.
  • Click on "Properties" to open the Expression Floater.
  • In the "Create Variables" field select "Vector" and enter "Dummy01"
  • Click on Create.
  • Enter "Dummy02" and click on Create again.
  • Select "Scalar", enter "Star" and click on Create.
  • Select the Variable "Dummy01" and click on "Assign to Controller"
  • From the list, select the Position track of object "Dummy01"
  • Select the Variable "Dummy02" and click on "Assign to Controller"
  • From the list, select the Position track of object "Dummy02"
  • Select the Variable "Star" and click on "Assign to Controller"
  • From the list, select the Points Track of the Star Shape.
  • In the Expression filed, enter the following Expression:

    [ 0, (Dummy01.x-Dummy02.x)/Star, 0 ]

  • Click on "Evaluate" - nothing should change...
  • Now you can minimize TrackView.
  • Select the unfreezed Dummy02, click on "Select and Move", then on "X".
  • If you move Dummy02 left-right, the Eye should follow.
  • Create an Instance "Eye-Left".

    How does it work?
    The Expression evaluates the relative position between Dummy01 and Dummy02 along X. The result is being divided by the Number of Points in the Star Shape. The higher the value, the slower the eye motion. You can set this number to any value to adjust the "magnification" of the motion translation from the Dummy to the Texture.

    This concept works because the default coordinates of the Mapping Gizmo are [0,0,0] relativelly to the Local Object Coordinates of the master object.

    You can improve the expression by entering a similar formula for the Y motion - replace the expression above with the following one:

    [ (Dummy02.z-Dummy01.z)/Star, (Dummy01.x-Dummy02.x)/Star, 0 ]


    ANIMATING THE UV TEXTURE OFFSET

  • Make sure you have the basic objects created as in Part one.
  • In Track View, assign an Expression Float controller to Eye Material/Maps/Diffuse/U-Offset.
  • Click on Properties.
  • Create the same Variables as in Part one.
  • Enter the expression:

    (Dummy02.x-Dummy01.x)/(Star*500)

    How does it work?

    A value of 1 or -1 moves the Texture at its full width along U/V.
    In our case it should be somewhere between -0.3 and +0.3, or you might see two halves of the eye at both sides of the sphere.
    In the Material Editor, you can watch the changing value of the U-Offset field while you move the Dummy. Because this method animates the Texture in the Material itself, you don't have to Instance the eye. You can Copy and modify it as you wish.
    The second method is suitable for ANY kind of UVW Mapping, because it doesn't animate the Map Gizmo, but the Texture itself. In the first case, you would have to change the Expression from Position to Rotation if you would decide to use Cylindrical or Spherical Mapping coordinates instead...

    You can download two Max scenes to play with...

    Have fun!...


    Flat Cartoon Eyes Animation
    (c) 1997 by Borislav "3DJ Bobo" Petrov