// Update the avatar each frame. public void Update() { if (!transform.gameObject.activeInHierarchy) { return; } // Get the KinectManager instance if (c == null) { c = CooplayerCoords.Instance; } // move the avatar to its Kinect position MoveAvatar(); for (var boneIndex = 0; boneIndex < bones.Length; boneIndex++) { if (!bones[boneIndex]) { continue; } if (boneIndex2JointMap.ContainsKey(boneIndex)) { clientRokoborba.SkeletonPositionIndex joint = boneIndex2JointMap[boneIndex]; TransformBone(joint, boneIndex); } } }
// Update the avatar each frame. public void Update() { if (!transform.gameObject.activeInHierarchy) { return; } // Get the KinectManager instance if (c == null) { c = CooplayerCoords.Instance; } // move the avatar to its Kinect position MoveAvatar(); for (var boneIndex = 0; boneIndex < bones.Length; boneIndex++) { if (!bones[boneIndex]) { continue; } if (boneIndex2JointMap.ContainsKey(boneIndex)) { clientRokoborba.SkeletonPositionIndex joint = boneIndex2JointMap[boneIndex]; TransformBone(joint, boneIndex); } } //if(c != null && c.data != null && c.newIncomingEndPoint != null) // udpClient.Send(c.data, c.data.Length, new IPEndPoint(IPAddress.Parse("192.168.1.5"), 12345)); }
// Update the avatar each frame. public void Update() { if (!transform.gameObject.activeInHierarchy) { return; } // Get the KinectManager instance if (c == null) { c = clientRokoborba.Instance; } else if (c.reset) { Debug.Log("RESETIRAAAM"); c.reset = false; ResetToInitialPosition(); } // move the avatar to its Kinect position MoveAvatar(); for (var boneIndex = 0; boneIndex < bones.Length; boneIndex++) { if (!bones[boneIndex]) { continue; } if (boneIndex2JointMap.ContainsKey(boneIndex)) { clientRokoborba.SkeletonPositionIndex joint = boneIndex2JointMap[boneIndex]; TransformBone(joint, boneIndex); } } }
// Apply the rotations tracked by kinect to the joints. protected void TransformBone(clientRokoborba.SkeletonPositionIndex joint, int boneIndex) { Transform boneTransform = bones[boneIndex]; if (boneTransform == null || c == null) { return; } int iJoint = (int)joint; if (iJoint < 0) { return; } // Get Kinect joint orientation Quaternion jointRotation = c.GetJointOrientation(iJoint); //Debug.Log(jointRotation.x + " " + jointRotation.y + " " + jointRotation.z + " " + jointRotation.w + "\n"); //Debug.Log(jointRotation); if (jointRotation == Quaternion.identity) { return; } // Smoothly transition to the new rotation Quaternion newRotation = Kinect2AvatarRot(jointRotation, boneIndex); if (smoothFactor != 0f) { boneTransform.rotation = Quaternion.Slerp(boneTransform.rotation, newRotation, smoothFactor * Time.deltaTime); } else { boneTransform.rotation = newRotation; } }