Research & Development
Python Script: Pose space deformation handling in Blender
Tested with Blender 2.43 and 2.44
Author: Tal Trachtman
Date: May 2007
Version:1.0

Motivation:
Sculpt corrective deformations without the "crazy space" problem

Instructions:
(1) Select a mesh and its armature
(2) Run the script (alt-p while your mouse pointer is in the text window)
(3) Move vertices around to make a better deformed shape, making sure that you
don't close the GUI (if you do, the original mesh can be found in layer 19)
don't add or delete vertices as these changes will not get copied into the shape key
(you are working on a temporary copy of the original mesh you selected)
(4) When happy with the corrective deformation, click "Save PSD"
The corrective deformation will now be the last shape key in your mesh

Limitations:
(1) This script cannot alter existing shape keys in the mesh, instead it adds a new shape key
This is because existing shape keys are currently exposed through Python API as read only
(2) Bone envelopes and bbones (bones with multiple segments) are not supported

How It Works:
When you press alt-p:
1. a duplicate of the mesh is created and the armature pose is applied to it
2. the original mesh is sent to layer 19 so you don't model on it by mistake
3. you model the corrective deformation on the mesh copy

When you click on "Save PSD"
1. the mesh copy is "unposed" back into the armature's rest position
2. the unposed mesh copy is used to create a new shape key in the original mesh
3. the mesh copy is deleted
4. the original mesh is returned to its original layer
5. the illusion of working on the same mesh throughout has been maintained :)

When you click "Cancel" or press ESC while in the GUI
1. the mesh copy is deleted
2. the original mesh is returned to its original layer

Developing This Further: Next Steps For Any Coders Out There
  • Implement this solution into the Blender source code
  • Create a transparent workflow where the user rotates a bone (eg q degrees around axis p), goes into PSD mode, models a correction, exits PSD mode and the system has automatically created a driven shape key that blends between the basis shape and the new corrective shape key set key as the bone rotates from its rest state to angle q.
  • Add the inverse transform solution for bbones
  • Dynamic envelopes have no solutions for the inverse transform unless the envelope weights are baked into the vertices - so there could be a 'sticky envelopes' button somewhere in the Blender GUI.
  • Add PSD capability to lattices and curves if applicable

  • Disclaimer:
    Use this script at your own risk and back up your work before using the script! I do not accept liabilty for any loss of data or damage to your computer that may result in the running of the script.

    License:
    This script is completely free for commercial and non-commercial use. If you improve on the script and redistribute the improved script, or if you use the script as a component of your script, please give me credit for my contribution.

    Acknowledgements:
    rvk copying code obtained from an attachment to a post post made by Chris Barton at "http://projects.blender.org/pipermail/bf-python/2007-January/004530.html" (url no longer valid)
    I originally downloaded the code from the url below, but it is also no longer active.
    http://projects.blender.org/pipermail/bf-python/attachments/20070130/056a7fcc/rvk1_torvk2.py
    GUI code adopted from "Blender 3D: Noob to Pro" specifically the GUI creation section.


    Download script
    Download test .blend for this script


    This website and all its contents are copyright © Tal Trachtman 2007 unless otherwise stated. No material herein may be copied or reproduced for any purpose without written consent.