Extracting animation information from an armature

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

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

Post by kakapo »

yes, i meant what bight_jeremy said. but how would b-bone vertex group weights be handled if b-bone segments got exported as separate bones.

i don't think exporting b-bones is very important though.

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

Post by ascotan »

The bone struct does not store the rotation of each segment of a b-bone. The segments are created in a function called b_bone_spline_setup in armature.c I think. From this code (at the end it looks like bbone_array recieves a set of matrix transformations for each segment.

It might be possible to extract this info and put it in the api but it's pretty complex and will have to wait. However, it might be possible to mimic this in python knowning the lenth of the bone, the segments and it's bezier handles.

Posts: 0
Joined: Thu Jan 13, 2005 6:20 am

Post by tron_thomas »

It looks like there is already a strategy in development to provide the feature I worked on. So, I'm not sure if it would be worth while to submit the patch, especially since it is against fairly old code now that is being completely replaced.

Mu idea behind exporting the rest position was to mimic what could be done in the user interface when clicking on the "RestPos" button. I added two new method to the Armature class. One called useRestPos which took a boolean that determined whether the rest position should be applied or removed. The other method was named isAtRest and was used to determine if the armature was already in the rest position.

I never really understood how a lot of the armature code worked. I just tracked down the code that was executed when the "RestPos" button was pressed, and I basically called that to implement the useRestPos method. The only problem with this is that RestPos button code worked on the object containing the armature, and the useRestPos method only had the armature object itself without any parent object.

So, I wrote a little function that could search through the scene and find the first object that was using the armature and apply that object the button code. I was always concerned about whether this was a good approach or not. I didn't know how likely it would be for multiple objects to be using the same armature data, and what it meant to apply the rest position to only one of them. Still it worked well for my purposes, and I was actually able to get the output I needed to perform my export.

Not being able to export the animations from the latest versions of Blender has kind of put a damper on the progress I can make with the project I'm working on. That's why I wanted to switch over to helping with the Blender development. It would give me something to do and might help speed up the development.

Post Reply