// 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)); } }
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); } }
// 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(); } }
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; } } }