bone matrices - bind pose <-> current frame

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

kakapo
Posts: 0
Joined: Sat Sep 04, 2004 2:32 pm

bone matrices - bind pose <-> current frame

Post by kakapo »

http://members.iinet.net.au/~cpbarton/i ... odule.html

i would like to write an exporter which exports bone animation so i need the inverse bone matrix of the bind pose to multiply it with the bone matrix of the current animation frame.

how can i get the bind pose information? is there a way to get the matrix directly or do i have to calculate it from head/tail/roll (since the documentation says this information is in rest state)? is the Editbone matrix the bind pose matrix?

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post by ascotan »

The animation api is almost done. There is a pose module which will allow you to pull the tranform matrix from the pose directly. It's not available yet though :9

kakapo
Posts: 0
Joined: Sat Sep 04, 2004 2:32 pm

Post by kakapo »

ok... how will this work then with the pose module?



what is the difference between the currently available Bone.matrix and Editbone.matrix? isn't this what i need?

or couldn't there simply be some more keys for the matrix like "ARMATURESPACE", "BONESPACE", "ARMATURESPACEBINDPOSE", "BONESPACEBINDPOSE"?

Ben
Posts: 9
Joined: Wed Oct 23, 2002 8:32 pm

Post by Ben »

ascotan wrote:The animation api is almost done. There is a pose module which will allow you to pull the tranform matrix from the pose directly. It's not available yet though :9
Great news!!! :lol: When it will be available? Is there any build
which has this module!

Ben

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post by ascotan »

No builds with this yet. Hopefully it will get included as soon as the cvs freeze comes off. Also part of this is the ability to access pose constraints.

LetterRip
Posts: 0
Joined: Thu Mar 25, 2004 7:03 am

Post by LetterRip »

ascotan,

could you put the patch in the tracker? I'll bring it up at the meeting - if we do a 2.40a I'd like to see if we could get it included as well, that would ensure that the scripts will get tested before 2.41, and those who need animation export capabilities can get them for a stable release prior to 2.41.

LetterRip

kakapo
Posts: 0
Joined: Sat Sep 04, 2004 2:32 pm

Post by kakapo »

since it looks like 2.41 is quite near now, i guess the pose module is finished already? could i have a glimpse at its docs somewhere? :)

LetterRip
Posts: 0
Joined: Thu Mar 25, 2004 7:03 am

Post by LetterRip »

Hi it is committed to CVS, if you download a recent testing build - then you can start using it :)

If you want to read the api documentation - go to cvs and look at the file pose.py


http://tinyurl.com/73jjr

LetterRip

kakapo
Posts: 0
Joined: Sat Sep 04, 2004 2:32 pm

Post by kakapo »

thanks!

i don't quite grasp how to get a pose object though.

like this from the armature object?

pose = Object.Get("Armature").getPose()
print pose.bones

doesn't seem to work (i use the windows orange build from january 15th).

stiv
Posts: 0
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv »

kakapo wrote:doesn't seem to work (i use the windows orange build from january 15th).
I don't believe any of the new BPy Armature code has made it into the Orange branch, just regular bf-blender cvs.

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

i had a ArmatureObject.getPose() that predated ascotans version, that Pose did not know anything about bones, just had a method pose.fromAction(sourceact, framenum) for playing back actions with py :)

but yah ascotans work is in CVS HEAD now, not in orange (before Ton merges again at some point, perhaps).

~Toni

Ben
Posts: 9
Joined: Wed Oct 23, 2002 8:32 pm

Post by Ben »

this build has the Pose module
http://blender.org/forum/viewtopic.php?t=7450

and :

Code: Select all

pose = ArmatureObject.getPose()
bones_dict = pose.bones
pose_bone = bones_dict[bone.name]
get the pose for a given bone.Then you get from that

-localMatrix
-poseMatrix

Can someone please, explain in which space are these matrices?
I do not obtain the same results, as taken from IPO transformations.

Ben

kakapo
Posts: 0
Joined: Sat Sep 04, 2004 2:32 pm

Post by kakapo »

Ben wrote:Can someone please, explain in which space are these matrices?
i wonder about this too?

the bone does some rotation (for example the thigh during a walk cycle - caused by the ik) but the returned poseMatrix is always the same for me.

Code: Select all

for frame in range(1, 24):
  Blender.Set("curframe", frame)
  Window.Redraw()
  pose = Object.Get("Armature").getPose()
  for bonename in bonelist:
    # matrix is always the same for each frame but it should change!
    if bonename == "leg1.L": print pose.bones[bonename].poseMatrix
is it supposed to be used that way or am i doing something wrong?

Ben
Posts: 9
Joined: Wed Oct 23, 2002 8:32 pm

Post by Ben »

..it happens to me too!!!

jsgreenawalt
Posts: 0
Joined: Sun Jan 08, 2006 6:27 am

Post by jsgreenawalt »

Do the martices that are returned by the pose module take into account IK constraints so that an accurate bone transform is returned for the frame? If so this will be really useful.

Post Reply