[Bf-python] bone.setQuat() - not working?

Joseph Gilbert models at paposo.com
Fri Apr 9 05:45:13 CEST 2004


K. The answer to this is a little complex, and is going to need some
extensive fixing.

This revolves around the BONE_NOCALC flag that is a flag value for the bone.
Normally bone rotations/transformations are recalculated based on the
current 'pose' in the object. The object contains a current 'poseChannel'
for every bone. What happens is that when the bones are drawn in the 3dview
this function get's called:
static void apply_pose_bonechildren (Bone* bone, bPose* pose, int doit)
....
chan = verify_pose_channel (pose, bone->name);  //we are getting the pose
for this bone
....
 if (chan->flag & POSE_ROT)
   memcpy (bone->quat, chan->quat, sizeof (bone->quat)); //copy the pose's
quat rotation to the bone's quat rotation

Now it just so happens that there is a single empty pose channel for each
bone (i think) normally, and what get's copied is an identity quaternion
from the blank poseChannel.
So wha'ts happening is that you are setting the quat value, and then you
call redraw() and the bone's quat info is updated according to the object's
current pose info - which is blank.
The short way to fix this is in the .setQuat() function add the line:
self->bone->flag |= BONE_NOCALC;
This will tell the 3d window to not update the bone's values based on pose
information. However, this may not be the best thing to do. What should
happen is that when you want to rotatate a bone you set up a pose channel
for it rather than setting the quat value directly in the bone. Then when
the scene gets redrawn the 3dView updates the bone's transformation info
from the poseChannel.


 -----Original Message-----
From: bf-python-admin at blender.org [mailto:bf-python-admin at blender.org]On
Behalf Of Michael Schardt
Sent: Thursday, April 08, 2004 10:52 AM
To: bf-python at blender.org
Subject: [Bf-python] bone.setQuat() - not working?


  Hello!

  I'm trying to pose an armature for MakeHuman via python.
  Anyone tried bone.setQuat()? Using this function does indeed change the
bone's quaternion - but only as long as there's no redraw.
  But without redrawing the window you won't see any changes...
  Try this: print a bone's quat with bone.getQuat(). Then set it with
bone.setQuat() and look at the result with bone.getQuat() again - ok so far
  Now do a Blender.Window.Redraw() and look at the quaternion again - it's
back at its old value.
  Am I doing something wrong or is this a bug?

  Greetings, Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20040408/88f76e96/attachment.html>


More information about the Bf-python mailing list