public void Hash() { var pose1 = new HeadPose(40, 20, 9); var pose2 = new HeadPose(40, 20, 0); var dictionary = new Dictionary <HeadPose, int>(); dictionary.Add(pose1, dictionary.Count); try { dictionary.Add(pose2, dictionary.Count); } catch { Assert.True(false, $"{typeof(HeadPose)} must not throw exception."); } try { dictionary.Add(pose2, dictionary.Count); Assert.True(false, $"{typeof(HeadPose)} must throw exception because key is duplicate."); } catch (ArgumentException) { } }
// Update is called once per frame void FixedUpdate() { HeadPose headPose = TobiiAPI.GetHeadPose(); if (headPose.IsRecent()) { transform.rotation = Quaternion.Lerp(transform.rotation, headPose.Rotation, Mathf.Min(Time.time * speed, 0.02f)); } }
public IEnumerator CargarHeadPose(int playerN, int headID, System.Action <bool> onEnded) { Player player; if (!BattleSystem.Instance.battleON) { player = playerN == 1 ? GameManager.Instance.player : BattleSystem.Instance.player2; } else { player = playerN == 1 ? BattleSystem.Instance.player1 : BattleSystem.Instance.player2; } string spriteID = int.Parse(headID.ToString().Substring(1)) < 10 ? headID.ToString().Substring(2) : headID.ToString().Substring(1); string localizador = "/HeadgearPose/" + spriteID + "_"; Texture2D textureC_C = (Texture2D)Resources.Load("Piezas" + localizador + "C_C"); Sprite mySpriteC_C = Sprite.Create(textureC_C, new Rect(0f, 0f, textureC_C.width, textureC_C.height), Vector2.zero); while (mySpriteC_C == null) { yield return(new WaitForEndOfFrame()); } //Texture2D textureC_O = (Texture2D)Resources.Load("Piezas" + localizador + "C_O"); //Sprite mySpriteC_O = Sprite.Create(textureC_O, new Rect(0f, 0f, textureC_O.width, textureC_O.height), Vector2.zero); //while (mySpriteC_O == null) yield return new WaitForEndOfFrame(); //Texture2D textureO_O = (Texture2D)Resources.Load("Piezas" + localizador + "C_O"); //Sprite mySpriteO_O = Sprite.Create(textureO_O, new Rect(0f, 0f, textureO_O.width, textureO_O.height), Vector2.zero); //while (mySpriteO_O == null) yield return new WaitForEndOfFrame(); Sprite mySpriteO_C; yield return(Items.Instance.ItemSpriteByID(player.criatura.equipment.head.ID, result => { mySpriteO_C = result; if (playerN == 1) { pose_player1 = new HeadPose() { openedClosed = mySpriteO_C, closedClosed = mySpriteC_C, }; } else { pose_player2 = new HeadPose() { openedClosed = mySpriteO_C, closedClosed = mySpriteC_C, }; } })); onEnded(true); yield return(new WaitForEndOfFrame()); }
public void NotEqual3() { var pose1 = new HeadPose(40, 20, 9); var pose2 = new HeadPose(40, 20, 0); Assert.NotEqual(pose1, pose2); Assert.True(pose1 != pose2); Assert.True(!pose1.Equals(pose2)); Assert.False(pose1 == pose2); }
public void Equal() { var pose1 = new HeadPose(10, 20, 9); var pose2 = new HeadPose(10, 20, 9); Assert.Equal(pose1, pose2); Assert.True(pose1 == pose2); Assert.True(pose1.Equals(pose2)); Assert.False(pose1 != pose2); }
public FaceFormatter(Face face) { attributes = face.FaceAttributes; age = attributes.Age; gender = attributes.Gender; smile = attributes.Smile; facialHair = attributes.FacialHair; headPose = attributes.HeadPose; glasses = attributes.Glasses; pos = face.FaceRectangle.Left + face.FaceRectangle.Width / 2; }
public void OnJSONMessage(string msg) { HeadPose head = JsonUtility.FromJson <HeadPose>(msg); //Debug.Log("Head " + head.id + " - " + head.headx + " " + head.heady + " " + head.headz); if (head != null && head.headx > 0) { Vector3 newPosition = new Vector3(head.headx, head.heady, head.headz); cube.localPosition = newPosition; } }
void Update() { HeadPose headPose = TobiiAPI.GetHeadPose(); Debug.Log("hoge"); if (headPose.IsRecent()) { Debug.Log("HeadPose Position (X,Y,Z): " + headPose.Position.x + ", " + headPose.Position.y + ", " + headPose.Position.z); Debug.Log("HeadPose Rotation (X,Y,Z): " + headPose.Rotation.eulerAngles.x + ", " + headPose.Rotation.eulerAngles.y + ", " + headPose.Rotation.eulerAngles.z); } }
public override int GetHeadPose(ref HeadPose headPose, int frameIndex) { int rv = 0; //headPose.orientation.z = -headPose.orientation.z; //headPose.position.x = -headPose.position.x; //headPose.position.y = -headPose.position.y; //rv = SvrGetPredictedPose(ref headPose.orientation.x, ref headPose.orientation.y, ref headPose.orientation.z, ref headPose.orientation.w, // ref headPose.position.x, ref headPose.position.y, ref headPose.position.z, frameIndex, SystemInfo.graphicsMultiThreaded); //headPose.orientation.z = -headPose.orientation.z; //headPose.position.x = -headPose.position.x; //headPose.position.y = -headPose.position.y; rv = SVRGetLatestEyeMatrices(leftViewData, rightViewData, TData, RData, frameIndex, SystemInfo.graphicsMultiThreaded); //leftViewMatrix.SetColumn(0, new Vector4(leftViewData[0], leftViewData[1], leftViewData[2], leftViewData[3])); //leftViewMatrix.SetColumn(1, new Vector4(leftViewData[4], leftViewData[5], leftViewData[6], leftViewData[7])); //leftViewMatrix.SetColumn(2, new Vector4(leftViewData[8], leftViewData[9], leftViewData[10], leftViewData[11])); //leftViewMatrix.SetColumn(3, new Vector4(leftViewData[12], leftViewData[13], leftViewData[14], leftViewData[15])); //rightViewMatrix.SetColumn(0, new Vector4(rightViewData[0], rightViewData[1], rightViewData[2], rightViewData[3])); //rightViewMatrix.SetColumn(1, new Vector4(rightViewData[4], rightViewData[5], rightViewData[6], rightViewData[7])); //rightViewMatrix.SetColumn(2, new Vector4(rightViewData[8], rightViewData[9], rightViewData[10], rightViewData[11])); //rightViewMatrix.SetColumn(3, new Vector4(rightViewData[12], rightViewData[13], rightViewData[14], rightViewData[15])); // Debug.Log($"leftViewMatrix [{leftViewMatrix.m00}, {leftViewMatrix.m01}, {leftViewMatrix.m02}, {leftViewMatrix.m03};" + //$"{leftViewMatrix.m10}, {leftViewMatrix.m11}, {leftViewMatrix.m12}, {leftViewMatrix.m13};" + //$"{leftViewMatrix.m20}, {leftViewMatrix.m21}, {leftViewMatrix.m22}, {leftViewMatrix.m23};" + //$"{leftViewMatrix.m30}, {leftViewMatrix.m31}, {leftViewMatrix.m32}, {leftViewMatrix.m33}]"); // Debug.Log($"rightViewMatrix [{rightViewMatrix.m00}, {rightViewMatrix.m01}, {rightViewMatrix.m02}, {rightViewMatrix.m03};" + //$"{rightViewMatrix.m10}, {rightViewMatrix.m11}, {rightViewMatrix.m12}, {rightViewMatrix.m13};" + //$"{rightViewMatrix.m20}, {rightViewMatrix.m21}, {rightViewMatrix.m22}, {rightViewMatrix.m23};" + //$"{rightViewMatrix.m30}, {rightViewMatrix.m31}, {rightViewMatrix.m32}, {rightViewMatrix.m33}]"); headPose.orientation.x = RData[0]; headPose.orientation.y = RData[1]; headPose.orientation.z = RData[2]; headPose.orientation.w = RData[3]; headPose.position.x = TData[0]; headPose.position.y = TData[1]; headPose.position.z = TData[2]; headPose.orientation.z = -headPose.orientation.z; headPose.position.x = -headPose.position.x; headPose.position.y = -headPose.position.y; return(rv); }
// Update is called once per frame void Update() { up = TobiiAPI.GetUserPresence(); if (physics == true) { if (up == UserPresence.Present) { hp = TobiiAPI.GetHeadPose(); if (hp.Rotation.eulerAngles.y > 180) { if (hp.Rotation.eulerAngles.y < 330) { rb.AddForce((360 - hp.Rotation.eulerAngles.y) * (-1) / 5, 0, 0, ForceMode.Force); } } if (hp.Rotation.eulerAngles.y < 180) { if (hp.Rotation.eulerAngles.y > 20) { rb.AddForce(hp.Rotation.eulerAngles.y / 5, 0, 0, ForceMode.Force); } } } } if (floorPresent == true) { if (up == UserPresence.NotPresent) { floor.active = false; floorPresent = false; } } if (gaze.HasGazeFocus) { if (physics == false) { if (dwellTime == 0) { dwellTime = Time.time; } if (Time.time - dwellTime >= 0.4) { cube.AddComponent <Rigidbody>(); rb = cube.GetComponent <Rigidbody>(); physics = true; } } } if (!gaze.HasGazeFocus) { dwellTime = 0; } }
private void get_degree() { if (!standard_input) { hp = TobiiAPI.GetHeadPose(); input_degree = hp.Rotation.eulerAngles.y; } else { input_degree = Input.GetAxis("Horizontal") * (-1) * 21; input_degree = input_degree + 180; } }
public override int GetHeadPose(ref HeadPose headPose, int frameIndex) { headPose.orientation.z = -headPose.orientation.z; headPose.position.x = -headPose.position.x; headPose.position.y = -headPose.position.y; int rv = SvrGetPredictedPose(ref headPose.orientation.x, ref headPose.orientation.y, ref headPose.orientation.z, ref headPose.orientation.w, ref headPose.position.x, ref headPose.position.y, ref headPose.position.z, frameIndex, SystemInfo.graphicsMultiThreaded); headPose.orientation.z = -headPose.orientation.z; headPose.position.x = -headPose.position.x; headPose.position.y = -headPose.position.y; return(rv); }
// Update is called once per frame void Update() { HeadPose headPose = TobiiAPI.GetHeadPose(); Vector3 direction = Vector3.zero; if (headPose.IsRecent()) { print("HeadPose Position (X,Y,Z): " + headPose.Position.x + ", " + headPose.Position.y + ", " + headPose.Position.z); if (headPose.Position.y < 50.0f) { direction = Vector3.down; } if (headPose.Position.y > 150.0f) { direction = Vector3.up; } if (headPose.Position.x < -50.0f) { direction = Vector3.left; } if (headPose.Position.x > 50.0f) { direction = Vector3.right; } if (headPose.Position.z > 600.0f) { direction = Vector3.back; } if (headPose.Position.z < 450.0f) { direction = Vector3.forward; } if (direction != Vector3.zero) { transform.Translate(direction * speed * Time.deltaTime, Space.Self); } } // Exit Application if (Input.GetKey("escape")) { Application.Quit(); } }
private void Doprocess(HeadPose headPose) { processIdel = false; var pitch = headPose.Pitch; var roll = headPose.Roll; var yaw = headPose.Yaw; switch (processStep) { case 1: if (firstInProcess) { firstInProcess = false; Log("Step1: detect head pose up and down."); IndicateMsg = "Please look Up and Down!"; } StepOne(pitch); break; case 2: if (firstInProcess) { firstInProcess = false; Log("Step2: detect head pose Left and Right."); IndicateMsg = "Please look Left and Right!"; } StepTwo(yaw); break; case 3: if (firstInProcess) { firstInProcess = false; Log("Step3: detect head pose roll left and Right."); IndicateMsg = "Please roll you face Left and Right!"; } StepThree(roll); break; default: break; } }
public static HeadPose GetHeadPose() { var headPose = new HeadPose(); headPose.Rotation = new HeadRotation(); headPose.Rotation.Yaw = EyeTrackingHost.GetInstance().Yaw; headPose.Rotation.Pitch = EyeTrackingHost.GetInstance().Pitch; headPose.Rotation.Roll = EyeTrackingHost.GetInstance().Roll; headPose.Position = new HeadPosition(); headPose.Position.X = EyeTrackingHost.GetInstance().X; headPose.Position.Y = EyeTrackingHost.GetInstance().Y; headPose.Position.Z = EyeTrackingHost.GetInstance().Z; headPose.TimeStampMicroSeconds = EyeTrackingHost.GetInstance().TimeStampMicroSeconds; return(headPose); }
private Vector2D PupilCornerDistance(Gaze gaze, HeadPose headPose) { var leftPupilCornerVector = gaze.PupilPosition.Left - gaze.InnerEyeCornerPosition.Left; var headAngel = headPose.Angle; var headPitch = Angle.FromRadians(headAngel.X); var headYaw = Angle.FromRadians(headAngel.Y); var headRoll = Angle.FromRadians(headAngel.Z); var realigned = CoordinateSystem.Rotation(headYaw, headPitch, headRoll); leftPupilCornerVector = leftPupilCornerVector.TransformBy(realigned); var xDistance = leftPupilCornerVector.X; var yDistance = leftPupilCornerVector.Y; return(new Vector2D(xDistance, yDistance)); }
/// <inheritdoc /> public override void Update() { // Override gaze before base.Update() updates the controllers if (mixedRealityGazeProviderHeadOverride != null && mixedRealityGazeProviderHeadOverride.UseHeadGazeOverride && WindowsMixedRealityUtilities.SpatialCoordinateSystem != null) { SpatialPointerPose pointerPose = SpatialPointerPose.TryGetAtTimestamp(WindowsMixedRealityUtilities.SpatialCoordinateSystem, PerceptionTimestampHelper.FromHistoricalTargetTime(DateTimeOffset.Now)); if (pointerPose != null) { HeadPose head = pointerPose.Head; if (head != null) { mixedRealityGazeProviderHeadOverride.OverrideHeadGaze(head.Position.ToUnityVector3(), head.ForwardDirection.ToUnityVector3()); } } } base.Update(); }
public override int GetHeadPose(ref HeadPose headPose, int frameIndex) { int poseStatus = 0; headPose.orientation = Quaternion.identity; headPose.position = Vector3.zero; if (Input.GetMouseButton(0)) // 0/Left mouse button { poseStatus |= (int)TrackingMode.kTrackingOrientation; poseStatus |= (int)TrackingMode.kTrackingPosition; } if (Input.GetMouseButton(1)) // 1/Right mouse button { Vector2 mouseNDC = Vector2.zero; mouseNDC.x = 2 * (Input.mousePosition.x / Screen.width) - 1f; mouseNDC.y = 2 * (Input.mousePosition.y / Screen.height) - 1f; Vector3 eulers = Vector3.zero; eulers.y = mouseNDC.x * 90f; // +/- degrees eulers.x = -mouseNDC.y * 45f; // +/- degrees headPose.orientation.eulerAngles = eulers; poseStatus |= (int)TrackingMode.kTrackingOrientation; } if (Input.GetMouseButton(2)) // 2/Middle mouse button { Vector2 mouseNDC = Vector2.zero; mouseNDC.x = 2 * (Input.mousePosition.x / Screen.width) - 1f; mouseNDC.y = 2 * (Input.mousePosition.y / Screen.height) - 1f; headPose.position.x = mouseNDC.x; headPose.position.z = mouseNDC.y; poseStatus |= (int)TrackingMode.kTrackingPosition; } return(poseStatus); }
// Update is called once per frame void Update() { if (physics == true) { hp = TobiiAPI.GetHeadPose(); if (hp.Rotation.eulerAngles.x > 180) { if (hp.Rotation.eulerAngles.x < 345) { rb.AddForce(0, (360 - hp.Rotation.eulerAngles.x) / 2, 0, ForceMode.Force); } } if (hp.Rotation.eulerAngles.x < 180) { if (hp.Rotation.eulerAngles.x > 30) { rb.AddForce(0, ((hp.Rotation.eulerAngles.x) * (-1)) / 10, 0, ForceMode.Force); } } } if (gaze.HasGazeFocus) { if (physics == false) { if (dwellTime == 0) { dwellTime = Time.time; } if (Time.time - dwellTime >= 0.4) { physics = true; } } } if (!gaze.HasGazeFocus) { dwellTime = 0; } }
/// <inheritdoc/> public override void Update() { Profiler.BeginSample("[MRTK] WindowsMixedRealityDeviceManager.Update"); base.Update(); #if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP if (mixedRealityGazeProviderHeadOverride != null && mixedRealityGazeProviderHeadOverride.UseHeadGazeOverride) { SpatialPointerPose pointerPose = SpatialPointerPose.TryGetAtTimestamp(WindowsMixedRealityUtilities.SpatialCoordinateSystem, PerceptionTimestampHelper.FromHistoricalTargetTime(DateTimeOffset.Now)); if (pointerPose != null) { HeadPose head = pointerPose.Head; if (head != null) { mixedRealityGazeProviderHeadOverride.OverrideHeadGaze(head.Position.ToUnityVector3(), head.ForwardDirection.ToUnityVector3()); } } } #endif // (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP UpdateInteractionManagerReading(); for (var i = 0; i < numInteractionManagerStates; i++) { // SourceDetected gets raised when a new controller is detected and, if previously present, // when OnEnable is called. Do not create a new controller here. var controller = GetOrAddController(interactionManagerStates[i].source, false); if (controller != null) { controller.UpdateController(interactionManagerStates[i]); } } LastInteractionManagerStateReading = interactionManagerStates; Profiler.EndSample(); // Update }
// draw face rectangles /// <summary> /// Draws the face rectangles in the given texture. /// </summary> /// <param name="faces">List of faces.</param> /// <param name="tex">Tex.</param> /// <param name="faceColors">List of face colors for each face</param> /// <param name="drawHeadPoseArrow">If true, draws arrow according to head pose of each face</param> public void DrawFaceRects(Texture2D tex, Face[] faces, Color[] faceColors, bool drawHeadPoseArrow) { for (int i = 0; i < faces.Length; i++) { Face face = faces[i]; Color faceColor = faceColors[i % faceColors.Length]; FaceRectangle rect = face.faceRectangle; CloudTexTools.DrawRect(tex, rect.left, rect.top, rect.width, rect.height, faceColor); if (drawHeadPoseArrow) { HeadPose headPose = face.faceAttributes.headPose; int cx = rect.width / 2; int cy = rect.height / 4; int arrowX = rect.left + cx; int arrowY = rect.top + (3 * cy); int radius = Math.Min(cx, cy); float x = arrowX + radius * Mathf.Sin(headPose.yaw * Mathf.Deg2Rad); float y = arrowY + radius * Mathf.Cos(headPose.yaw * Mathf.Deg2Rad); int arrowHead = radius / 4; if (arrowHead > 15) { arrowHead = 15; } if (arrowHead < 8) { arrowHead = 8; } CloudTexTools.DrawArrow(tex, arrowX, arrowY, (int)x, (int)y, faceColor, arrowHead, 30); } } tex.Apply(); }
// Update is called once per frame void Update() { headPose = TobiiAPI.GetHeadPose(); /* * if (headPose.IsRecent()) * { * * //transform.localRotation = Quaternion.Lerp(transform.localRotation, headPose.Rotation, Time.unscaledDeltaTime * Responsiveness); * transform.localRotation = Quaternion.Lerp(transform.localRotation, headPose.Rotation, Time.unscaledDeltaTime * Responsiveness); * } */ var gazePoint = TobiiAPI.GetGazePoint(); if (gazePoint.IsRecent() && Camera.main != null) { var eyeRotation = Quaternion.Euler((gazePoint.Viewport.y - 0.5f) * Camera.main.fieldOfView, (gazePoint.Viewport.x - 0.5f) * Camera.main.fieldOfView * Camera.main.aspect, 0); var eyeLocalRotation = Quaternion.Inverse(transform.localRotation) * eyeRotation; var pitch = eyeLocalRotation.eulerAngles.x; if (pitch > 180) { pitch -= 360; } var yaw = eyeLocalRotation.eulerAngles.y; if (yaw > 180) { yaw -= 360; } LeftEyePosition = new Vector2(Mathf.Sin(yaw * Mathf.Deg2Rad), Mathf.Sin(pitch * Mathf.Deg2Rad)); RightEyePosition = new Vector2(Mathf.Sin(yaw * Mathf.Deg2Rad), Mathf.Sin(pitch * Mathf.Deg2Rad)); } }
private void Update() { //Pauses the level UserPresence userPresence = TobiiAPI.GetUserPresence(); HeadPose headPose = TobiiAPI.GetHeadPose(); if (!m_levelManager.paused) { if (Input.GetButtonDown("Pause") || (GazeManager.TobiiConnected && (userPresence != UserPresence.Present || !headPose.IsValid))) { m_levelManager.TooglePause(); Show(); m_active = true; } } //Resume else if (m_active && Input.GetButtonDown("Pause")) { m_levelManager.TooglePause(); Hide(); m_active = false; } }
public void UpdateBones() { HeadPose headPose = TobiiAPI.GetHeadPose(); if (headPose.IsRecent()) { Vector3 headPosition = new Vector3(-headPose.Position.x, headPose.Position.y, headPose.Position.z); headPosition = SmoothPosition(lastHeadPosition, headPosition); lastHeadPosition = headPosition; headTarget.head.target.transform.position = tracker.ToWorldPosition(headPosition / 1000); headTarget.head.target.confidence.position = 0.8F; Vector3 headAngles = headPose.Rotation.eulerAngles; Quaternion headRotation = tracker.ToWorldOrientation(Quaternion.Euler(headAngles.x, headAngles.y + 180, headAngles.z)); headRotation = SmoothRotation(lastHeadRotation, headRotation); lastHeadRotation = headRotation; switch (rotationTrackingAxis) { case RotationTrackingAxis.XYZ: headTarget.head.target.transform.rotation = headRotation; headTarget.head.target.confidence.rotation = 0.8F; break; case RotationTrackingAxis.XY: headRotation = Quaternion.LookRotation(headRotation * Vector3.forward); headTarget.head.target.transform.rotation = headRotation; headTarget.head.target.confidence.rotation = 0.8F; break; default: break; } } }
private void get_degree_head() { hp = TobiiAPI.GetHeadPose(); float pose_x = hp.Rotation.eulerAngles.y; float pose_z = hp.Rotation.eulerAngles.x; float f = 0.05f; bool z = false; bool reverse = false; float direction = 20; bool do_nothing = false; if (pose_x >= 180) { float amount = 360 - pose_x; if (amount > direction) { direction = amount; z = false; reverse = false; } //input_degree_X = 1 / f + 180; } if (pose_x < 180) { float amount = pose_x; if (amount > direction) { direction = amount; z = false; reverse = true; } //input_degree_X = -1 / f + 180; } if (direction == 20) { if (pose_z >= 180) { float amount = 360 - pose_z; if (amount > 5) { direction = amount; z = true; reverse = true; //input_degree_Z = -1 / f + 180; } } if (pose_z < 180) { float amount = pose_z; if (amount > 5) { direction = amount; z = true; reverse = false; //input_degree_Z = 1 / f + 180; } } } if (direction == 20) { do_nothing = true; } // input manipulation if (z) { input_degree_X = 180; input_degree_Z = 1 / f; if (reverse) { input_degree_Z = input_degree_Z * (-1); } input_degree_Z = input_degree_Z + 180; } if (!z) { input_degree_Z = 180; input_degree_X = 1 / f; if (reverse) { input_degree_X = input_degree_X * (-1); } input_degree_X = input_degree_X + 180; } if (do_nothing) { input_degree_X = 180; input_degree_Z = 180; } }
public virtual int GetHeadPose(ref HeadPose headPose, int frameIndex = -1) { headPose.orientation = Quaternion.identity; headPose.position = Vector3.zero; return(0); }
public override int GetHeadPose(ref HeadPose headPose, int frameIndex) { int poseStatus = 0; headPose.orientation = GetRotation; headPose.position = GetPosition; poseStatus |= (int)TrackingMode.kTrackingOrientation; poseStatus |= (int)TrackingMode.kTrackingPosition; //Debug.Log("Input.mousePosition:"+ Input.mousePosition+" "+ Screen.width+" "+Screen.height); //if (Input.GetMouseButton(0)) // 0/Left mouse button //{ // poseStatus |= (int)TrackingMode.kTrackingOrientation; // poseStatus |= (int)TrackingMode.kTrackingPosition; //} //if(Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) // 1/Right mouse button //{ // mousePressPointTemp1 = Input.mousePosition; // mousePressEuler = SvrManager.Instance.head.eulerAngles; //} else if(Input.GetMouseButton(0) || Input.GetMouseButton(1)) { // mouseNDCRotate.x = 2 * ((Input.mousePosition.x - mousePressPointTemp1.x) / Screen.width) ; // mouseNDCRotate.y = 2 * ((Input.mousePosition.y - mousePressPointTemp1.y) / Screen.height) ; // poseStatus |= (int)TrackingMode.kTrackingOrientation; //} //if(Input.GetKey(KeyCode.W)) { // mouseNDCPosition.y += Time.deltaTime * 0.2f; // poseStatus |= (int)TrackingMode.kTrackingPosition; //} else if(Input.GetKey(KeyCode.S)) { // mouseNDCPosition.y -= Time.deltaTime * 0.2f; // poseStatus |= (int)TrackingMode.kTrackingPosition; //} else { // mouseNDCPosition.y = 0; //} //if(Input.GetKey(KeyCode.A)) { // mouseNDCPosition.x -= Time.deltaTime * 0.2f; // poseStatus |= (int)TrackingMode.kTrackingPosition; //} else if(Input.GetKey(KeyCode.D)) { // mouseNDCPosition.x += Time.deltaTime * 0.2f; // poseStatus |= (int)TrackingMode.kTrackingPosition; //} else { // mouseNDCPosition.x = 0; //} ////if(Input.mouseScrollDelta.y != 0) { //// mouseNDCPosition.x = 0; //// mouseNDCPosition.y = Input.mouseScrollDelta.y * 0.2f; //// poseStatus |= (int)TrackingMode.kTrackingPosition; ////} else { //// mouseNDCPosition = Vector2.zero; ////} /////复位 //if(Input.GetKey(KeyCode.Escape) == true) { // mouseNDCRotate = Vector2.zero; // mouseNDCPosition = Vector2.zero; // mousePressPointTemp1 = Vector2.zero; // mousePressEuler = Vector3.zero; // SvrManager.Instance.head.position = Vector3.zero; // poseStatus |= (int)TrackingMode.kTrackingOrientation; // poseStatus |= (int)TrackingMode.kTrackingPosition; //} //headPose.orientation.eulerAngles = mousePressEuler + new Vector3(-mouseNDCRotate.y * 45f, mouseNDCRotate.x * 90f, 0); //headPose.position = new Vector3(mouseNDCPosition.x,0, mouseNDCPosition.y); //headPose.position = SvrManager.Instance.head.TransformPoint(headPose.position); return(poseStatus); }
void Update() { scotOuter = theVig.VignetteOuterValueDistance; if (simAbs) { noUser = true; } else { noUser = false; } if (Input.GetKeyUp(KeyCode.R)) //Reset { cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true; theVig.VignetteInnerColor.a = 0f; theVig.VignetteOuterColor.a = 0.0f; } if (Input.GetKeyUp(KeyCode.G) && gT.isOn) //glaucoma { cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true; currSim = 0; theVig.VignetteInnerColor = Color.black; theVig.VignetteOuterColor = Color.black; theVig.VignetteInnerColor.a = 0f; theVig.VignetteOuterColor.a = 1f; theVig.VignetteFalloff = 1f; maxScot = 1.5f; minScot = .05f; theVig.VignetteOuterValueDistance = 1.5f; } if (Input.GetKeyUp(KeyCode.C) && cT.isOn) //cataract { cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true; currSim = 2; theVig.VignetteInnerColor = catColour; theVig.VignetteOuterColor = catColour; theVig.VignetteInnerColor.a = .3f; theVig.VignetteOuterColor.a = .1f; theVig.VignetteFalloff = 1f; maxScot = 1.5f; minScot = .05f; theVig.VignetteOuterValueDistance = 1.5f; } if (Input.GetKeyUp(KeyCode.A) && aT.isOn)//AMD { cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true; currSim = 1; theVig.VignetteInnerColor = Color.black; theVig.VignetteOuterColor = Color.gray; theVig.VignetteInnerColor.a = 1f; theVig.VignetteOuterColor.a = 0.05f; theVig.VignetteFalloff = 2f; maxScot = 1.99f; minScot = .2f; theVig.VignetteOuterValueDistance = 0.5f; } if (Input.GetKey(KeyCode.DownArrow)) { if (currSim == 0 && scotOuter > minScot) { theVig.VignetteOuterValueDistance -= (rateOfChange * Time.deltaTime); } if (currSim == 1 && scotOuter < maxScot) { theVig.VignetteOuterValueDistance += (rateOfChange * Time.deltaTime); } if (currSim == 2 && theVig.VignetteInnerColor.a < maxCatAlpha) { theVig.VignetteInnerColor.a += (rateOfChange * Time.deltaTime); theVig.VignetteOuterColor.a += (rateOfChange * Time.deltaTime); } } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } if (Input.GetKey(KeyCode.UpArrow)) { if (currSim == 0 && scotOuter < maxScot) { theVig.VignetteOuterValueDistance += (rateOfChange * Time.deltaTime); } if (currSim == 1 && scotOuter > minScot) { theVig.VignetteOuterValueDistance -= (rateOfChange * Time.deltaTime); } if (currSim == 2 && theVig.VignetteInnerColor.a > minCatAlpha) { theVig.VignetteInnerColor.a -= (rateOfChange * Time.deltaTime); theVig.VignetteOuterColor.a -= (rateOfChange * Time.deltaTime); } } if (TobiiAPI.IsConnected) { UserPresence userPresence = TobiiAPI.GetUserPresence(); if (userPresence.IsUserPresent()) { cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true; noUser = false; GazePoint gazePoint = TobiiAPI.GetGazePoint(); HeadPose headPose = TobiiAPI.GetHeadPose(); theVig.VignetteCenter.x = gazePoint.Screen.x / cam.pixelWidth; theVig.VignetteCenter.y = gazePoint.Screen.y / cam.scaledPixelHeight; } else { noUser = true; StartCoroutine("StartAbsentMode"); } } else { theVig.VignetteCenter.x = Input.mousePosition.x / cam.pixelWidth; theVig.VignetteCenter.y = Input.mousePosition.y / cam.pixelHeight; } }
private string HeadPoseInformation(HeadPose headPose) { return("HeadPose: " + "Pitch: " + headPose.Pitch + ", " + "Roll" + headPose.Roll + ", Yaw" + headPose.Yaw); }
public Record(Gaze gaze, HeadPose headPose, Point2D display) { Gaze = gaze; HeadPose = headPose; Display = display; }