Need access to final calculated bone transforms

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

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

Need access to final calculated bone transforms

Postby jsgreenawalt » Tue Jan 24, 2006 4:38 pm

(edit - nevermind, see below)

Hello. I'm a developer currently working on the Torque Game Engine DTS Exporter for Blender.

One of the most requested features from users of the exporter is the ability to export animations that are created using the various constraint types. Right now, it is only possible to export animations created using "targetless IK" and FK. For more complex rigs, it is highly desirable to be able to use the other constraint types.

In order to make this happen, I need access to the final calculated bone transforms after all constraints have been applied. I was under the (apparently) mistaken impression that the new pose API in Blender 2.41 would help to solve this problem. I have run a number of tests using the "bf-blender / Windows 2.41RC1 (2006/1/17) RC BUILD" and it is quite clear that the poseMatrix property of the posebones does not take any of the constraints into account.

Would it be possible to give us read only access to this data in a future version of blender?

Thanks,
Joseph Greenawalt
Last edited by jsgreenawalt on Tue Jan 24, 2006 7:53 pm, edited 1 time in total.

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

Postby jsgreenawalt » Tue Jan 24, 2006 7:51 pm

Nevermind :oops: I feel incredibly stupid. The poseMatrix already contains the values I need. The problem was that I was running my test scripts from one of the aux screens (ctrl-left arrow) with no 3d view visible. This was causing my code that was supposed to be cycling through the frames to do nothing. My appologies for requesting a feature that already exists :wink:

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

Postby kakapo » Tue Jan 24, 2006 7:55 pm

how exactly are you cycling through the frames? i had a 3d view visible but this didn't seem to work for me like in my example in this thread: http://www.blender.org/forum/viewtopic. ... sc&start=0

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

Postby jsgreenawalt » Tue Jan 24, 2006 8:02 pm

Here's my latest test script:

Code: Select all

import Blender
from Blender import *

arm = Blender.Object.Get('Armature')
armData = arm.getData()
act = Blender.Armature.NLA.GetActions()['Action']
act.setActive(arm)

def getPosesForFrame(frame):
   print "At Frame %i" % frame
   Blender.Set("curframe", frame)
   Blender.Window.Redraw()
   pose = arm.getPose()
   for bonename in armData.bones.values():
      print "Bone %s poseMatrix:" % bonename.name
      print pose.bones[bonename.name].poseMatrix
      
print "*****************************"      
getPosesForFrame(1)
getPosesForFrame(20)
print "*****************************"


I am using another bone in my armature as the constraint target (don't know if it will work w/ empties), Have tested with "track to", "copy rotation", and IK. Seems to be working well so far.

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

Postby kakapo » Wed Jan 25, 2006 8:16 am

thanks, i will try again. maybe it's because of your two lines dealing with the action? are they necessary?

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

Postby jsgreenawalt » Wed Jan 25, 2006 3:17 pm

Yes, I believe they are. I think that if you don't set an active action for your armature it won't work properly.


Return to “Python”

Who is online

Users browsing this forum: No registered users and 1 guest