Warning: Don't use this script. A bug causes it to render incorrectly.
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.
Tested with Blender 2.42. No external Python libraries are required.
See this example scene.
- 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.
- Download the script, and open it in the Text view in Blender.
- Select an eye and the object that it should track (in that order).
- 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:
- Location / 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.
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.
- Scale Control
Used by the animator to squash the eye. Actually, this can be used to apply any secondary transformation.
- Select the eye, or any of the helper controls.
- Run the script (Alt-P with your cursor in the Text window). Choose "Tear down tracker".
The script works by transforming the eye twice:
- 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.
- 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.
- Only the negative Y-axis can be used to track.
- The tracking object (arrow) must be on a visible layer.
- The transform doesn't work during a render!