[Bf-python] going form head/tail/roll to matrix formula?
Bassam Kurdali
bkurdali at freefac.org
Tue Feb 15 03:21:28 CET 2011
Thanks Martin
I actually found that function just now, but your explanation makes
sense, since I didn't quite follow what it was doing.
In a related note: I found editbone.transform() that takes a
tranformtion matrix as an argument, and hoped it would remove the need
to do a bunch of matrix math in python. However, it seems to mess up in
two ways, minor and major:
1-minor: it's in armature space, so a little work is needed to e.g.
rotate the bone around it's own original matrix.
2-major: somehow it messes up the roll; transforming with e.g. a copy of
the bone's own matrix (inverted) and then transforming with a non
inverse copy should lead to an almost identical bone, instead, head and
tail are right, but roll is off.
I may end up implementing my own based on the code in armature.c as you
suggest, but I wonder if that behavior in editbone.transform() is a bug?
cheers
Bassam
On Mon, 2011-02-14 at 16:09 -0800, Martin Poirier wrote:
> Hey Bassam,
>
> You'll want to look at mat3_to_vec_roll in /source/blender/blenkernel/intern/armature.c
>
> Basically, it's taking the Y component of the matrix as the head->tail vector, reconverting that to a matrix as a bone with a roll of 0.0 and calculating the rotation difference between the original matrix and the computed one.
>
> Martin
>
> --- On Mon, 2/14/11, Bassam Kurdali <bkurdali at freefac.org> wrote:
>
> > From: Bassam Kurdali <bkurdali at freefac.org>
> > Subject: [Bf-python] going form head/tail/roll to matrix formula?
> > To: bf-python at blender.org
> > Received: Monday, February 14, 2011, 5:24 PM
> > Hey pythoneers, riggers
> > was hoping someone could help with this:
> >
> > In 2.49 we could write in python to the bone matrix- made
> > doing
> > transforms very easy.
> >
> > In 2.5 this is now read only (no problem-lets convert to
> > head/tail/roll
> > and write those) but going from the matrix to
> > head/tail/roll (or back)
> > is something I have not been able to figure out.
> >
> > There must be a set of formulas for this, so if anybody
> > knows, please
> > reply here.
> >
> > suggestion: a utility function in geometry module might be
> > nice.
> >
> > Thanks
> > Bassam
> >
> >
> >
> > _______________________________________________
> > Bf-python mailing list
> > Bf-python at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-python
> >
>
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
More information about the Bf-python
mailing list