Jump to content

MasakiKitayama

Verified Members
  • Posts

    2
  • Joined

  • Last visited

Reputation

0 Neutral
  1. In my opinion, using the System Origin (Camera.main.transform.position) as the gaze origin in the World coordinate system is not a very good implementation. I propose to use the corrected System Origin with the (local) gaze origin obtained by SRanipal_Eye_v2.GetGazeRay method as below, instead. Using UnityEngine; Using ViveSR.anipal.Eye; ... SRanipal_Eye_v2.GetGazeRay(GazeIndex.LEFT, out Ray ray); // w/o callback Vector3 worldGazeOrigin = Camera.main.transform.position + Camera.main.transform.rotation * ray.origin; Using above implementation, for example, the SRanipal_Eye_v2.Focus method can be modified as follows (the code before modification is commented out). public static bool Focus(GazeIndex index, out Ray ray, out FocusInfo focusInfo, float radius, float maxDistance, int focusableLayer, EyeData_v2 eye_data) { bool valid = GetGazeRay(index, out ray, eye_data); if (valid) { // rayGlobal = new Ray(Camera.main.transform.position, Camera.main.transform.TransformDirection(ray.direction)); Vector3 worldGazeOrigin = Camera.main.transform.position + Camera.main.transform.rotation * ray.origin; Ray rayGlobal = new Ray(worldGazeOrigin, Camera.main.transform.TransformDirection(ray.direction)); RaycastHit hit; if (radius == 0) valid = Physics.Raycast(rayGlobal, out hit, maxDistance, focusableLayer); else valid = Physics.SphereCast(rayGlobal, radius, out hit, maxDistance, focusableLayer); focusInfo = new FocusInfo { point = hit.point, normal = hit.normal, distance = hit.distance, collider = hit.collider, rigidbody = hit.rigidbody, transform = hit.transform }; } else { focusInfo = new FocusInfo(); } return valid; } I can't vouch for the validity of the above implementation, but it seems to work better than the original implementation, at least for my project.
  2. @Leiting I think it is a bug. The origin of the local variable "rayGlobal" should be the origin of the gaze rays (Left, Right, or Combined). Manual fix of the Focus method: public static bool Focus(GazeIndex index, out Ray ray, out FocusInfo focusInfo, float radius, float maxDistance, int focusableLayer, EyeData_v2 eye_data) { bool valid = GetGazeRay(index, out ray, eye_data); if (valid) { Ray rayGlobal = new Ray( Camera.main.transform.position + Camera.main.transform.rotation * ray.origin, Camera.main.transform.TransformDirection(ray.direction)); RaycastHit hit; if (radius == 0) valid = Physics.Raycast(rayGlobal, out hit, maxDistance, focusableLayer); else valid = Physics.SphereCast(rayGlobal, radius, out hit, maxDistance, focusableLayer); focusInfo = new FocusInfo { point = hit.point, normal = hit.normal, distance = hit.distance, collider = hit.collider, rigidbody = hit.rigidbody, transform = hit.transform }; } else { focusInfo = new FocusInfo(); } return valid; }
×
×
  • Create New...