Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Converting World-Co-ordinate Bone Rotations to Parent-Co-Ordinate Rotations

Discussion in 'Scripting' started by raeldor, Jul 25, 2014.

  1. raeldor

    raeldor

    Joined:
    Jul 8, 2013
    Posts:
    55
    Hi All,

    I'm trying to animate my mesh using Kinect, but it seems kinect provides the bone rotations in world co-ordinates. How do I convert from world co-ordinates to parent-child co-ordinates. I did some searching and thought it was something like this...

    Code (CSharp):
    1.  
    2.                 GameObject leftArm = GameObject.Find("upper_arm.L");
    3.                 Windows.Kinect.Vector4 leftShoulderOrientation = body.JointOrientations[Kinect.JointType.ShoulderLeft].Orientation;
    4.                 Windows.Kinect.Vector4 leftElbowOrientation = body.JointOrientations[Kinect.JointType.ElbowLeft].Orientation;
    5.                 leftArm.transform.localRotation = Quaternion.Inverse(QuaternionFromVector4(leftShoulderOrientation)) * QuaternionFromVector4(leftElbowOrientation);
    6.  
    But it seems to be rendering odd results.

    The other option here is, I have access to the bone positions, so if it's easier to calculate the rotation from the parent bone by using position that might be an option too.

    Any math gurus out there might be able to help?

    Thanks
    Ray
     
    Last edited: Jul 25, 2014
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    I think you might want to look at Transform.TransformPoint, Transform.TransformDirection, and the Inverse variants of each of those.

    Edit: Or perhaps not, I misread.
     
  3. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Any update on how to achieve this? I'm running into the same issue?
     
  4. raeldor

    raeldor

    Joined:
    Jul 8, 2013
    Posts:
    55
  5. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    It says "You are not authorized to perform this action." Do I need to sign up for something?
     
  6. raeldor

    raeldor

    Joined:
    Jul 8, 2013
    Posts:
    55
    Might be a closed forum, sorry. The quote from that post is...

    Because the Kinect quaternions seem to assume that any bone points to the sky before rotating,
    I turned the bones of my model to the sky before applying the quaternions.