<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2737.800" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>K. The answer to 
this is a little complex, and is going to need some extensive 
fixing.</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>This revolves around 
the BONE_NOCALC flag that is a flag value for the bone.</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>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:</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>static void 
apply_pose_bonechildren (Bone* bone, bPose* pose, int doit)</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial 
size=2>....</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>chan = 
verify_pose_channel (pose, bone->name);  //we are getting the pose for 
this bone </FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial 
size=2>....</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2> if 
(chan->flag & POSE_ROT) <BR>   memcpy (bone->quat, 
chan->quat, sizeof (bone->quat)); //copy the pose's quat rotation to the 
bone's quat rotation</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>The short way to fix 
this is in the .setQuat() function add the line:</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial 
size=2>self->bone->flag |= BONE_NOCALC;</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004><FONT face=Arial size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=957073203-09042004></SPAN><FONT face=Tahoma><FONT size=2><SPAN 
class=957073203-09042004><FONT face=Arial 
color=#0000ff> </FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT face=Tahoma><FONT size=2><SPAN 
class=957073203-09042004></SPAN></FONT></FONT> </DIV>
<DIV><FONT face=Tahoma><FONT size=2><SPAN 
class=957073203-09042004> </SPAN>-----Original Message-----<BR><B>From:</B> 
bf-python-admin@blender.org [mailto:bf-python-admin@blender.org]<B>On Behalf Of 
</B>Michael Schardt<BR><B>Sent:</B> Thursday, April 08, 2004 10:52 
AM<BR><B>To:</B> bf-python@blender.org<BR><B>Subject:</B> [Bf-python] 
bone.setQuat() - not working?<BR><BR></DIV></FONT></FONT>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV><FONT face=Arial size=2>Hello!</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT> </DIV>
  <DIV><FONT face=Arial size=2>I'm trying to pose an armature for MakeHuman via 
  python.</FONT></DIV>
  <DIV><FONT face=Arial size=2>Anyone tried bone.setQuat()? Using this function 
  does indeed change the bone's quaternion - but only as long as there's no 
  redraw.</FONT></DIV>
  <DIV><FONT face=Arial size=2>But without redrawing the window you won't 
  see any changes...</FONT></DIV>
  <DIV><FONT face=Arial size=2>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</FONT></DIV>
  <DIV><FONT face=Arial size=2>Now do a Blender.Window.Redraw() and look at the 
  quaternion again - it's back at its old value.</FONT></DIV>
  <DIV><FONT face=Arial size=2>Am I doing something wrong or is this a 
  bug?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT> </DIV>
  <DIV><FONT face=Arial size=2>Greetings, 
Michael</FONT></DIV></BLOCKQUOTE></BODY></HTML>