phatcoreportfolioprojects

Warning: Don't use this script. A bug causes it to render incorrectly.

Zoom inScreenshot of the script in action.
Screenshot of the script in action.

Track And Transform

This is a Python script for Blender that allows non-spherical eyes to track an object. It's useful for cartoony characters with flat eyes.

Requirements

Tested with Blender 2.42. No external Python libraries are required.

Usage

See this example scene.

Setting up:

  1. Model your character. The pupil of the eye must be on the Y-axis, facing the negative direction (see Known Issues). You may scale the eye object to fit your model, but the mesh data must be spherical. Parent the eyes to the head [bone], if it suits your purpose.
  2. Download the script, and open it in the Text view in Blender.
  3. Select an eye and the object that it should track (in that order).
  4. Run the script (Alt-P when your cursor is in the Text window). Choose "Set up tracker".

The script creates three helper objects to transform the eye:

Screenshot of the Location / Rotation ControlLocation / Rotation Control

Used by the animator to adjust the position and rotation of the eye when it is at rest.

This control is the parent of the eye and the following controls. Its transform defines the reference space.

Screenshot of the Tracker widgetTracker

Indicates the direction that the eye is pointing. The animator may use it to adjust the tracking influence with the regular Blender tracking interface.

You'll probably want to set the influence to about 0.5, because an influence of 1.0 looks a bit unnatural.

Screenshot of the Scale ControlScale Control

Used by the animator to squash the eye. Actually, this can be used to apply any secondary transformation.

Removing:

  1. Select the eye, or any of the helper controls.
  2. Run the script (Alt-P with your cursor in the Text window). Choose "Tear down tracker".

How It Works

The script works by transforming the eye twice:

  1. It applies the local rotation of the Tracker. Since the eye and the tracker share the same parent, this makes the un-scaled eye look directly at the target.
  2. It applies the global transform of the Scale Control. This squashes the eye to fit the Scale Control without altering its rotation.

Effectively, the eye inherits the rotation of the Tracker, but the scale of the Scale Control.

Known Issues (Bugs)

  1. Only the negative Y-axis can be used to track.
  2. The tracking object (arrow) must be on a visible layer.
  3. The transform doesn't work during a render!