/* * Kinect 1 functions */ private void UpdateKinectRootData(int player) { OpenNI.SkeletonJointTransformation data; if (!playerManager.GetPlayer(player).GetSkeletonJoint(OpenNI.SkeletonJoint.Torso, out data)) { return; } Vector3 newRootPosition = coordinateSystem.ConvertLocation(coordinateSystem.ConvertRawKinectLocation(data.Position.Position), RUISDevice.Kinect_1); skeletons[kinect1SensorID, player].root.position = newRootPosition; skeletons[kinect1SensorID, player].root.positionConfidence = data.Position.Confidence; skeletons[kinect1SensorID, player].root.rotation = coordinateSystem.ConvertRotation(coordinateSystem.ConvertRawKinectRotation(data.Orientation), RUISDevice.Kinect_1); skeletons[kinect1SensorID, player].root.rotationConfidence = data.Orientation.Confidence; }
private Vector3 getSample(RUISDevice device) { Vector3 sample = new Vector3(0, 0, 0); Vector3 tempSample; if (device == RUISDevice.Kinect_1) { OpenNI.SkeletonJointPosition jointPosition; bool success = kinectSelection.GetPlayer(0).GetSkeletonJointPosition(OpenNI.SkeletonJoint.RightHand, out jointPosition); if (success && jointPosition.Confidence >= 0.5) { tempSample = coordinateSystem.ConvertRawKinectLocation(jointPosition.Position); if (Vector3.Distance(tempSample, lastKinectSample) > 0.1) { sample = tempSample; lastKinectSample = sample; this.guiTextUpperLocal = ""; } else { this.guiTextUpperLocal = "Not enough hand movement."; } } } if (device == RUISDevice.Oculus_DK2) { Ovr.Posef headpose = RUISOVRManager.ovrHmd.GetTrackingState().HeadPose.ThePose; float px = headpose.Position.x; float py = headpose.Position.y; float pz = -headpose.Position.z; // This needs to be negated TODO: might change with future OVR version tempSample = new Vector3(px, py, pz); tempSample = coordinateSystem.ConvertRawOculusDK2Location(tempSample); if ((Vector3.Distance(tempSample, lastOculusDK2Sample) > 0.1) && (RUISOVRManager.ovrHmd.GetTrackingState().StatusFlags & (uint)StatusBits.PositionTracked) != 0) // Code from OVRManager.cs { sample = tempSample; lastOculusDK2Sample = sample; this.guiTextUpperLocal = ""; } else { this.guiTextUpperLocal = "Not enough hand movement."; } } return(sample); }
private Vector3 getSample(RUISDevice device) { Vector3 sample = new Vector3(0, 0, 0); Vector3 tempSample; if (device == RUISDevice.Kinect_1) { OpenNI.SkeletonJointPosition jointPosition; bool success = kinectSelection.GetPlayer(0).GetSkeletonJointPosition(OpenNI.SkeletonJoint.RightHand, out jointPosition); if (success && jointPosition.Confidence >= 0.5) { tempSample = coordinateSystem.ConvertRawKinectLocation(jointPosition.Position); if (Vector3.Distance(tempSample, lastKinectSample) > 0.1) { sample = tempSample; lastKinectSample = sample; this.guiTextUpperLocal = ""; } else { this.guiTextUpperLocal = "Not enough hand movement."; } } } if (device == RUISDevice.PS_Move) { if (psMoveWrapper.sphereVisible[calibratingPSMoveControllerId] && psMoveWrapper.handleVelocity[calibratingPSMoveControllerId].magnitude <= 10.0f) { tempSample = coordinateSystem.ConvertRawPSMoveLocation(psMoveWrapper.handlePosition[calibratingPSMoveControllerId]); if (Vector3.Distance(tempSample, lastPSMoveSample) > 0.1) { sample = tempSample; lastPSMoveSample = sample; this.guiTextUpperLocal = ""; } else { this.guiTextUpperLocal = "Not enough hand movement."; } } } return(sample); }
private Vector3 getSample(RUISDevice device) { Vector3 sample = new Vector3(0, 0, 0); Vector3 tempSample; updateBodyData(); if (device == RUISDevice.Kinect_2) { Kinect.Body[] data = kinect2SourceManager.GetBodyData(); bool trackedBodyFound = false; int foundBodies = 0; foreach (var body in data) { foundBodies++; if (body.IsTracked) { if (trackingIDtoIndex[body.TrackingId] == 0) { trackedBodyFound = true; if (body.Joints[Kinect.JointType.HandRight].TrackingState == Kinect.TrackingState.Tracked) { tempSample = new Vector3(body.Joints[Kinect.JointType.HandRight].Position.X, body.Joints[Kinect.JointType.HandRight].Position.Y, body.Joints[Kinect.JointType.HandRight].Position.Z); tempSample = coordinateSystem.ConvertRawKinect2Location(tempSample); if (Vector3.Distance(tempSample, lastKinect2Sample) > 0.2) { sample = tempSample; lastKinect2Sample = sample; device1Error = false; if (!device2Error) { this.guiTextUpperLocal = ""; } } else { device1Error = true; this.guiTextUpperLocal = "Not enough hand movement."; } } } } } if (!trackedBodyFound && foundBodies > 1) { device1Error = true; this.guiTextUpperLocal = "Step out of the Kinect's\nview and come back."; } } if (device == RUISDevice.Kinect_1) { OpenNI.SkeletonJointPosition jointPosition; bool success = kinectSelection.GetPlayer(0).GetSkeletonJointPosition(OpenNI.SkeletonJoint.RightHand, out jointPosition); if (success && jointPosition.Confidence >= 0.5) { tempSample = coordinateSystem.ConvertRawKinectLocation(jointPosition.Position); if (Vector3.Distance(tempSample, lastKinectSample) > 0.2) { sample = tempSample; lastKinectSample = sample; device2Error = false; if (!device1Error) { this.guiTextUpperLocal = ""; } } else { device2Error = true; // this.guiTextUpperLocal = "Not enough hand movement."; } } else { device2Error = true; // this.guiTextUpperLocal = "Not enough hand movement."; } } return(sample); }