[Bf-python] Proposal: curveutil (or Ipo.getVectorCurve)

Anders Nilsson breakin at home.se
Sun Apr 4 12:32:39 CEST 2004


I just saw that a mathutils was added to the python-api and it got me
thinking. For exporters/importers there is a lot of data that needs to
be converted. Most of it's easy, especially now that mathutils has come
along, but IPO-curves poses a problem, mostly since they are separated
into one curve per component (ie. three float-curves describes a
position).

There is no easy way of just converting an triple-euler-value into an
quaternion because you never got a triple-euler-value. I was thinking
about a util class/module that provides the following features (here
I've been trying hard not to introduce any new types/classes, so
re-usage of IPO-curve etc):

1) A method that given an IPO and an identifier (position, size,
rotation, color, ...) returns three IPO-curves with their frame value at
exactly the same places. So curve point 4 of all three tracks has the
very same frame value. This means that all three values taken as a
vector can be regarded as a singel value that can be converted to
quaternion or another coordinate frame easily. This poses some problems
when different interpolation/extrapolation modes are set but they might
be solved. This would be a problem anyway for all formats that require
vectors to be stored with just one interpolation/extrapolation mode for
all three components. For linear and constant this is trivial, just
inserting keys to they've got keys at the same frames, making sure the
same curve is interpolated. For bezier it's trickier but I feel it's
doable.

2) A method that given an IPO-curve returns a TCB-curve
(tension/cont/bias). Maybe, by an approximation of a time-track, creates
easeTo/easeFrom values (don't know if this is possible).

3) A method that given a TCB-curve returns an IPO-curve. Here
easeTo/easeFrom would be troublesome since Blender has one time-curve
per IPO whereas easeTo/easeFrom is per curve.

4) Other things I can't think of but users might request later.

I'd volunteer doing (1) but I guess I'm not experiences enough to create
the module itself. Perhaps it could be part of some other module, like
Ipo and IpoCurve respectively. Then I could do (1) myself. Either way I
think this will make writing exporters/importers a lot easier,
everything else is pretty easy.

Questions: Is there some code inside blender that could be used? Maybe a
feature that when turned on locks the curves together, moving one key
moves the other as well (for pos, quat, ...). Then, when switching that
feature on this conversion of curves would be needed and hence it might
already be in there. Just don't wanna reinvent the wheel. For
QuatX,QuatY,QuatZ,QuatW-curves components seems to be separated but
still they are slerped but that requires component to interact, or?

Anders Nilsson (breakin)




More information about the Bf-python mailing list