Code Bug or Blender Bug?

I start with this pose:

http://members.cox.net/vexgames/bonepose.gif

Notice that each bone is one unit long, and is that length along its own local Y. Were these bones not bent like this, it would just be a long line of one unit long bones, always extending along their local Y axis.

I rotated the bones, as shown in the picture, so one of the bones is rotated 90 degrees along Z. Then I rotate the next one to be -90 degrees along Z.

So… if I were to output the rotation of each bone now, in bonespace, they should all be zero, except there should be a 90 in there, followed by a -90.

However, the rotations of the bones (in bonse space) is output as
zero zero zero zero zero zero… never anything except zero, using the code:


for bone in arm.getBones():
  mymat = element[3].getRestMatrix('bonespace')
  RotMat = mymat.rotationPart()
  Quatty = RotMat.toQuat()	
  objectdatalist.append(Quatty.axis[0])
  objectdatalist.append(Quatty.axis[1])
  objectdatalist.append(Quatty.axis[2])
  objectdatalist.append(Quatty.angle)
  print objectdatalist

The result is a zero rotation on all the bones, always.

Interestingly enough, the bones that are rotated are showing it as a translation along X in bone space - I don’t see how this is possible. As you can see on the picture, clearly, the bone has been rotated, not translated.

Am I missing something here, or is this a bug in Blender? I’m busy writing some serious export tools for a game project, and I have to get these things 100 percent correct. I need the positions and rotations of these bones, in bone space, and I figured that asking for the matrix, in bone space, would supply this…

Note that at the time of writing, if I ask it for the bone’s ‘quat’ instead of using the matrix method, I can get the correct rotation (90 degrees), but the position is messed up by such a rotation, as I mentioned above, so its still useless…

Are you rotating those bone in edit mode (purple; tab) or pose mode (light blue; ctrl-tab)?

Pose mode (Light Blue).

The object starts out as a straight line, and one of the bones is rotated and then the next one is rotated, to form that pose.

It shouldn’t matter which though - the operation is clearly a rotation. The vertices attached to the bone rotate around the bone. The child bones of the bone rotate around the bone. It’s definitely not a translation, both mathematically and visually. However, when asking blender for the matrices, it outputs everything I do in pose mode as a matrix with a translation part, never a rotation part… basically, it seems to be outputting the heads and tails of those bones as relative transforms, instead of the actual MATRIX which the verts will be deformed using.

I need the matrix the verts are being deformed with… in bonespace. Worldspace has the same issues, though, it seems.

Erk. This is the grief I ran up against when working in the sources on an NLA to NLA match-moving feature. At this point, it’s not possible to get a true matrix for a bone. It’s only relative to the next bone up it’s IK or parenting chain. To calculate it, you have to trace the matrices up the bone heirarchy until you hit a root bone, multiplying (I think) as you go along.

That said, I have no idea why it is not reporting the proper rotations. I don’t think that anyone is successfully using the bone portion of the Python code at the moment, though, so that’s probably why this hasn’t come to light yet.

This is probably the reason nobodys using it :slight_smile:

Almost all bone operations that you do want (such as in a human skeleton/etc) are always rotations, never translations… but its reporting everything as a translation…

You can get the rotation using ‘getQuat()’ but then that doesn’t give you the correct -translation- part or length along Y…

If this -is- a blender bug, I can generate more formal pictures explaining it… but where would I send such a report, so that I can be sure it’d be noticed?

The python coders mailing list, most likely. Currently, Ton is working on a revamp of character animation tools for the 2.37 release, most likely to include fixes to the bone system. After that, the Python hooks into it will probably change. I doubt that anyone will be willing to start messing around with the current bones code in Python if Ton is restructuring.

Python mailing list info:

http://projects.blender.org/mailman/listinfo/bf-python

Thanks. I posted to that list - is there a place though, to see current open bugs in the Blender CVS / etc? I have experience with 3D coding and CVS, and perhaps I could even take a look at it all…

hi all, does any one know how to setPosition for a bone. i want to be able to move arount from a python code.