KinectManager.GetJointOrientation C# (CSharp) Method

GetJointOrientation() public method

public GetJointOrientation ( uint UserId, int joint, bool flip ) : Quaternion
UserId uint
joint int
flip bool
return Quaternion
    public Quaternion GetJointOrientation(uint UserId, int joint, bool flip)
    {
        KinectWrapper.GetJointTransformation(UserId, joint, ref jointTransform);
        KinectWrapper.SkeletonJointOrientation ori = jointTransform.ori;
        Quaternion quat = ConvertMatrixToQuat(ori, joint, flip);

        return quat;
    }

Usage Example

Example #1
0
    private void FixedUpdate()
    {
        if (manager && manager.IsUserDetected())
        {
            long userId = manager.GetPrimaryUserID();

            if (manager.IsJointTracked(userId, (int)rightKnee))
            {
                Quaternion deltaRot = manager.GetJointOrientation(userId, (int)rightKnee, true) * Quaternion.Inverse(lastKneeRotation);
                Vector3    eulerRot = new Vector3(Mathf.DeltaAngle(0, deltaRot.eulerAngles.x),
                                                  Mathf.DeltaAngle(0, deltaRot.eulerAngles.y), Mathf.DeltaAngle(0, deltaRot.eulerAngles.z));

                angularVelocity  = eulerRot / Time.fixedDeltaTime;
                lastKneeRotation = manager.GetJointOrientation(userId, (int)rightKnee, false);
            }

            rayPos         = new Vector3(transform.position.x + 0.025f, transform.position.y - 0.075f, transform.position.z + 0.19f);
            footRay.origin = rayPos;

            RaycastHit hit;

            if (Physics.Raycast(footRay, out hit, 0.06f))
            {
                if (hit.transform.CompareTag("Ball"))
                {
                    hit.rigidbody.rotation = manager.GetJointOrientation(userId, (int)rightFoot, false);

                    Vector3 direction   = hit.rigidbody.transform.TransformDirection(manager.GetJointDirection(userId, (int)rightFoot, false, true));
                    Vector3 balVelocity = new Vector3(direction.x * angularVelocity.x, direction.y * angularVelocity.y, direction.z * angularVelocity.z);

                    if (balVelocity.y < 0)
                    {
                        balVelocity.y *= -1;
                    }

                    if (balVelocity.z < 0)
                    {
                        balVelocity.z *= -1;
                    }

                    Debug.Log(balVelocity);

                    hit.transform.GetComponent <FootBall>().SetVelocity(balVelocity);

                    /*if (balVelocity.y > 50)
                    *   balVelocity.y = 50;
                    *
                    *  if (balVelocity.z > 50)
                    *   balVelocity.z = 50;
                    *
                    *  balVelocity.y = Mathf.Clamp(balVelocity.y, 10f, 50f);
                    *  balVelocity.z = Mathf.Clamp(balVelocity.z, 10f, 50f);
                    *  Debug.Log(balVelocity);*/
                }
            }
        }
    }
All Usage Examples Of KinectManager::GetJointOrientation