void TransformBone(uint userId, SkeletonJoint joint, Transform dest, bool move) { // SkeletonJointPosition sjp = this.joints[userId][joint]; // Point3D pos = sjp.position; //Debug.Log("joint " + joint + "x " + pos.X + " y " + pos.Y + " z " + pos.Z); SkeletonJointOrientation ori = new SkeletonJointOrientation(); this.skeletonCapbility.GetSkeletonJointOrientation(userId, joint, ref ori); //float [] m = ori.Orientation.elements; //Debug.Log(m.Length); // only modify joint if confidence is high enough in this frame if (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(-ori.m02, -ori.m12, ori.m22); // elem1 elem2 elem3 // elem4 elem5 elem6 // elem7 elem8 elem9 Vector3 worldZVec = new Vector3(-ori.Orientation.elem3, -ori.Orientation.elem6, ori.Orientation.elem9); // Vector3 worldYVec = new Vector3(trans.ori.m01, trans.ori.m11, -trans.ori.m21); Vector3 worldYVec = new Vector3(ori.Orientation.elem2, ori.Orientation.elem5, -ori.Orientation.elem8); Quaternion jointRotation = Quaternion.LookRotation(worldZVec, worldYVec); Quaternion newRotation = (jointRotation * initialRotations[(int)joint]); // Some smoothing dest.rotation = Quaternion.Slerp(dest.rotation, newRotation, Time.deltaTime * 20); } //if (move) //{ // dest.position = new Vector3(trans.pos.x/1000, trans.pos.y/1000 -1, -trans.pos.z/1000); // dest.position = new Vector3(pos.X/1000, pos.Y/1000 -1, -pos.Z/1000); //} }
void TransformBone(uint userId, SkeletonJoint joint, Transform dest, bool move) { SkeletonJointPosition sjp = this.joints[userId][joint]; Point3D pos = sjp.position; SkeletonJointOrientation ori = new SkeletonJointOrientation(); this.skeletonCapbility.GetSkeletonJointOrientation(userId,joint, ori); float [] m = ori.Orientation.elements; // only modify joint if confidence is high enough in this frame if (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(-ori.m02, -ori.m12, ori.m22); Vector3 worldZVec = new Vector3(-m[2], -m[5], m[8]); // Vector3 worldYVec = new Vector3(trans.ori.m01, trans.ori.m11, -trans.ori.m21); Vector3 worldYVec = new Vector3(m[1], m[4], -m[7]); Quaternion jointRotation = Quaternion.LookRotation(worldZVec, worldYVec); Quaternion newRotation = jointRotation * initialRotations[(int)joint]; // Some smoothing dest.rotation = Quaternion.Slerp(dest.rotation, newRotation, Time.deltaTime * 20); } if (move) { // dest.position = new Vector3(trans.pos.x/1000, trans.pos.y/1000 -1, -trans.pos.z/1000); dest.position = new Vector3(pos.X/1000, pos.Y/1000 -1, -pos.Z/1000); } }
public void Reset(UserID user) { UInt32 status = OpenNIImporter.xnResetSkeleton(this.InternalObject, user); WrapperUtils.CheckStatus(status); }