private void initbodyCtrlData() { bodyCtrlData = new BodyCtrlData(); bodyCtrlData.userPosition = Vector3.zero; bodyCtrlData.UserID = 0; bodyCtrlData.jointRotation = new Quaternion[22]; bodyCtrlData.HandLeftPos = Vector3.zero; bodyCtrlData.HandRightPos = Vector3.zero; }
public BodyCtrlData(BodyCtrlData data) { jointRotation = new Quaternion[22]; for (int i = 0; i < jointRotation.Length; ++i) { jointRotation[i] = data.jointRotation[i]; } userPosition = data.userPosition; HandLeftPos = data.HandLeftPos; HandRightPos = data.HandRightPos; UserID = data.UserID; }
// Update the avatar each frame. public void MoveBody(BodyCtrlData bodyCtrlData) { if (!transform.gameObject.activeInHierarchy) { return; } // move the avatar to its Kinect position MoveAvatar(bodyCtrlData.UserID); for (var boneIndex = 0; boneIndex < bones.Length; boneIndex++) { if (!bones[boneIndex] || bodyCtrlData.jointRotation[boneIndex] == Quaternion.identity || boneIndex == 12) { continue; } if (boneIndex2JointMap.ContainsKey(boneIndex)) { Transform boneTransform = bones[boneIndex]; if (smoothFactor != 0f) { boneTransform.rotation = Quaternion.Slerp(boneTransform.rotation, bodyCtrlData.jointRotation[boneIndex], smoothFactor * Time.deltaTime); } else { boneTransform.rotation = bodyCtrlData.jointRotation[boneIndex]; } } else if (specIndex2JointMap.ContainsKey(boneIndex)) { // special bones (clavicles) List <KinectWrapper.NuiSkeletonPositionIndex> alJoints = !mirroredMovement ? specIndex2JointMap[boneIndex] : specIndex2MirrorJointMap[boneIndex]; if (alJoints.Count >= 2) { //Vector3 baseDir = alJoints[0].ToString().EndsWith("Left") ? Vector3.left : Vector3.right; //TransformSpecialBone(UserID, alJoints[0], alJoints[1], boneIndex, baseDir, !mirroredMovement); } } } }
public LpSensorManager(ref BodyCtrlData body_data, ref WristCtrlData wrist_data, int p, string b_a, int deta_time) { port = p; blue_addr = b_a; IpStr = "127.0.0.1"; ip = IPAddress.Parse(IpStr); ip_end_point = new IPEndPoint(ip, port); ref_body_data = body_data; ref_wrist_data = wrist_data; client = new Process(); client.StartInfo.FileName = string.Format(Application.streamingAssetsPath + @"\LpSensor\LpSensorTest.exe"); client.StartInfo.UseShellExecute = false; client.StartInfo.CreateNoWindow = true; client.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; client.StartInfo.Arguments = string.Format("{0} {1} {2}", port, blue_addr, deta_time); client.EnableRaisingEvents = true; bIsKilled = false; }
public ModelCtrlData(ModelCtrlData obj) { handCtrlData = new HandCtrlData(obj.handCtrlData); bodyCtrlData = new BodyCtrlData(obj.bodyCtrlData); wristCtrlData = new WristCtrlData(obj.wristCtrlData); }
public ModelCtrlData() { handCtrlData = new HandCtrlData(); bodyCtrlData = new BodyCtrlData(); wristCtrlData = new WristCtrlData(); }