GetJointTransformation() приватный Метод

private GetJointTransformation ( uint userID, SkeletonJoint joint, SkeletonJointTransformation &pTransformation ) : bool
userID uint
joint SkeletonJoint
pTransformation SkeletonJointTransformation
Результат bool
Пример #1
0
    public bool GetJointPosition(NiteWrapper.SkeletonJoint joint, out Vector3 position)
    {
        if (kinectConnect && calibratedUser)
        {
            NiteWrapper.SkeletonJointTransformation trans = new NiteWrapper.SkeletonJointTransformation();
            NiteWrapper.GetJointTransformation(calibratedUserId, joint, ref trans);

            // Nite gives position in mm convert to Unity unit = meters
            position = new Vector3(trans.pos.x / 1000.0F, trans.pos.y / 1000.0F, trans.pos.z / 1000.0F);
            return(trans.pos.confidence > confidenceThreshold);
        }
        else
        {
            position = new Vector3(0.0F, 0.0F, 0.0F);
            return(false);
        }
    }
Пример #2
0
    public bool GetJointOrientation(NiteWrapper.SkeletonJoint joint, out Quaternion rotation)
    {
        if (kinectConnect && calibratedUser)
        {
            NiteWrapper.SkeletonJointTransformation trans = new NiteWrapper.SkeletonJointTransformation();
            NiteWrapper.GetJointTransformation(calibratedUserId, joint, ref trans);

            Vector3 worldZVec = new Vector3(trans.ori.m02, trans.ori.m12, trans.ori.m22);
            Vector3 worldYVec = new Vector3(trans.ori.m01, trans.ori.m11, trans.ori.m21);
            rotation = Quaternion.LookRotation(worldZVec, worldYVec);
            return(trans.ori.confidence > confidenceThreshold);
        }
        else
        {
            rotation = Quaternion.identity;
            return(false);
        }
    }
Пример #3
0
    void TransformBone(uint userId, NiteWrapper.SkeletonJoint joint, Transform dest)
    {
        NiteWrapper.SkeletonJointTransformation trans = new NiteWrapper.SkeletonJointTransformation();
        NiteWrapper.GetJointTransformation(userId, joint, ref trans);

        // only modify joint if confidence is high enough in this frame
        if (trans.ori.confidence > 0.5)
        {
            // Z coordinate in OpenNI is opposite from Unity. We will create a quat
            // to rotate from OpenNI to Unity (relative to initial rotation)
            Vector3    worldZVec     = new Vector3(trans.ori.m02, -trans.ori.m12, trans.ori.m22);
            Vector3    worldYVec     = new Vector3(-trans.ori.m01, trans.ori.m11, -trans.ori.m21);
            Quaternion jointRotation = Quaternion.LookRotation(worldZVec, worldYVec);

            Quaternion newRotation = jointRotation * initialRotations[(int)joint];

            // Some smoothing
            dest.rotation = Quaternion.Slerp(dest.rotation, newRotation, Time.deltaTime * 20);
        }
    }