Manually rotate skeleton (something wrong with my code). RRS feed

  • Question

  • I am trying to rotate the skeleton data to simulate the rendering model from different angle (with the player still facing the Kinect). For example, I want to render a model as if it's turned by 45 decree while maintain the same general position, here is my code:


    sin = Math.Sin(MathHelper.ToRadiance(45));

    cos = Math.Cos(MathHelper.ToRadiance(45));

    backupjoint = OriginalHipjoint //This is to save the original root position.

    //Rotate each position by 45 decree

    foreach (Joint joint in currentSkeleton.Joints)


    tempX =  joint.X * cos + joint.Z * sin;

    tempZ = joint.X * -sin + joint.Z * cos;

    joint.X = tempX;

    joint.Z = tempZ;

    if (joint.JointType == JointType.Hip)

    offset = joint - backupjoint //To get the new offset.


    //Translate all new joint back to the original position (after translation)

    foreach (Joint joint in currentSkeleton.Joints)


    joint = joint - offset


    But for some reason even though the model is translate, the original offset wasn't applied into the joints. Anyone have an idea what I am missing?

    Saturday, September 29, 2012 1:11 AM