I’m working on an animation of a curved piano keyboard, and I’ve been trying to write a python script to generate the IPO curves for the keystrokes, but with no success so far. The problem is the following: because the keyboard is curved, I have to rotate the keys using their local axes (which follow the keyboard curvature). Doing this from the GUI, key by key, works fine, but it would be much easier with a script, given the large number of keys (and music synchronization issues). The thing is that when I create the IPO curves procedurally, the local axes of the keys get automatically aligned to the global axes, which completely screws up the animation. Is this a bug (my impression is that it is, since the GUI works ok), or am I just doing something wrong?
I guess that you have some model piano key
with a fixed “local” axes = “global” axes
for which you edit the ipo then you link
the ipo to one of the other keys on the keyboard
right?
The ipo just overwrites the rotation matrix of the object
you want it to be composed with a matrix that carries
the new “local” axis rotation.
Here is a solution (without scripts)
1/ create an empty for each piano key.
2/ rotate/translate
the empty so that its axis is the desired
“local” axis of the key.
You can do this using the copy menu ctrl C
3/ parent the key to the empty.
When you link the ipos Blender now multiplies
2 matrices - the “local” transformation matrix of the empty
and the “global” matrix from the ipo.
… and here’s another solution
Otherwise you could write a script that
does the matrix calculation above
(using the Mathutils module) but
I hate thinking about algebra before breakfast.
> You don’t have a script that can convert musical partitions
> into keyboard IPO’s which is beyond me ?
I wish I do! Right now I’m doing the sync manually (it is a pain in the neck, of course). I’d like to work on a more complex script to convert partitions into IPOs directly, but right now is beyond me as well.
The idea was to use 2), but ended up doing 1) (with no much success). In any case, here you can grab the python scripts and blend files I used in my project: