Generating Armature animation from script

Hi all,

I’m relatively new to Blender, and am looking to use it to visualise 3D animation from some motion data I have.

Anywho. I’m trying to get a Python script to import a set of stick lines (start point and end point pairs in world space) representing a rough human pose shape (legs, arms torso, and head) and convert this data in to an Armature animation.

I’m currently having trouble getting my head around how the pose bones of an object represent changes for each animation frame.

So far as I understand from my google’ing around and reading tutorials, the procedure I need is something along the lines of:

  • create armature hierarchy (this part I can do)
  • create key frame for location and rotation at each frame (no prob here either)
  • then set up loc and quat props of the pose bones appropriatelyNow, step 3 is where I’m a bit confused. I’ve got all these points in world space, so I guess my first question is what coordinate frame do the loc/quat properties live in?

Also, as I change the frame number to build up the animation, are the successive values of loc/quat supposed to be deltas between each frame, or an offset relative to the armature’s initial pose?

Generating the armature hierarchy is actually really easy, since I can just set the editbone.head and editbone.tail properties to the start/end points of each world-space line. However there doesn’t appear to be a way to do this for each frame that I can see, but I could well have missed something.

Cheers for any help,

ob1

Actually looking at this some more, I just realised there’s no way to define a “roll” around the bone direction with only two points to represent each bone.

I think I’ll have to work out how to generate a consistent “up” axis for each bone based on the positions of other bones or something. Argh :frowning:

ob1

Well Ob1,
It is quite difficult to do this with blender.
I don’t understand what is your problem,But i am also using python animating charecter,you can visit my tutorial for animation by interpolation [

](http://sushilronghe.tripod.com/Ronghester/index.html)http://sushilronghe.tripod.com/Ronghester/index.html

Do search on this forum about your query,You will get some good hit,but most of them are outdated ,for blender 2.42 and above you will need to consult the release notes on blender site.
“”“Best of luck for your work”""

Cheers ronghester, I’ll have a look at your tutorial.

I managed to find what I think is the correct coordinate space to translate things in. So far it looks like pose animation is relative to the intial pose the armature was created in, but I still have to fix rotation for the bones. The rotation always seems to be out by 10 degrees or so.

Also, does anyone have experience with getting mesh animations to work (ie. moving vertices each frame without using armatures)?

I just cant seem to get Blender to set a Mesh keypoint for some reason.

You’d probably be better off converting your data to BVH format as import scripts have already been written for it.

Mike

Yeah you are right, it might be less hassle just converting to that format.

If I can’t figure this out I may well look to doing something like that. There’d still be a problem in that I’d have to convert the “two-point” line bones from my data to BVH, but it might be easier than randomly changing parameters in Blender trying to get these bones to line up :slight_smile:

OK, figured it out now. Just had to puzzle through the coordinate systems and figure out what each frame was relative to (also fixed some quaternion rotation math so it was rotating the right way :P)

I might post what I’ve done here or something so others can see what I got up to. Could be useful, dunno (although I think it’s a bit hacky).

Only thing remains now is to orient the bones to have a concept of “forward” (since I don’t get roll from only having two points per bone), but can generate that easily enough from the rest of the frame, eg. take average direction vector of cross product of torso and left shoulder, and torso and right shoulder or something.

In any case, I can at least visualise complete data files now which is great.

Oh one last thing; Blender rules - I can’t believe I was considering forking out for Maya :smiley:

hii i’m new in BLender and i get problem in use the script from
http://sushilronghe.tripod.com/Ronghester/index.html
1 import Blender
2 from Blender import Object
3 maya=Object.Get(‘maya’)
4 action=maya.getIpo()
5 posX = action.getCurve(‘LocX’)
6 for a in range (0,21,5):
7 print posX[a]
8 posX[25]=0.0

and then in line 7 i got an error message like this
“TypeError:UnsubscriptableObject”
pls help me

To ang2ara,
In none of my script i did like this.If you can take some time to read it again.
Mean while ,here is what you are doing wrong.

action=maya.getIpo()
posX = action.getCurve(‘LocX’)

First thing you need to do is
creat an Ipo for your purpose,Like

action = Ipo.New(‘Object’,‘cometoschool’)

then add the curve ‘locX’ like…

action.addCurve(‘LocX’)

then you get back your curve and set the keys by this way…

posX = action.getCurve(‘LocX’)

for a in range (0,21,5):
print posX[a]

Then set this Ipo for your Object.
//////////////////////////////////////////////////////////////////////////////////
You must be new to python,THe error itself is telling you what is going wrong.
I felt it very badly because you have not fallowed the tutorial completely and just made
such bad words about it.
in future before making such comments ,please check if you are doing any thing wrong.
THat’s all

i want to learn python scripting

i have checked the blender python - wiki
and most of the links but i dont able to get a exact link
cauz there are certain changes in blender 2.43
as i had searched the net
some blender python resources were old one :frowning:
i am a blender animator in india
by the way :wink:

thanks a lot for your reply, i apreciate it so much.
but about bad words i had on the tutorial. plss tell me what it is!? cause my english is not good enough. if i had any bad words on this forums, please forgive me!! i felt so sory, but thx 4 everything.
let us make a better community :slight_smile:
luv u all

to ang2arg,
Oh man forget…
But repair your mistake. Luv you too…

Can you post what you have done?