void Update() { FoveInterface.EyeRays rays = fove.GetGazeRays(); FoveInterface.GazeConvergenceData gcr = FoveInterface.GetGazeConvergence(); //FoveInterface.CheckEyesClosed(); Debug.Log(gcr.accuracy); RaycastHit hit; if (Physics.Raycast(rays.left, out hit, 25)) { //hit.transform.GetComponent<timerScript>().startCounting(); if (hit.point != Vector3.zero) // Vector3 is non-nullable; comparing to null is always false { // Debug.Log(hit.point); transform.position = hit.point; x = hit.transform.tag; vec = hit.point; } } if (x == "Player") { if (Vector3.Distance(prev, vec) > 0.9 || prev == Vector3.zero) { prev = vec; if (c < count) { pcount = c; positions[c++] = new Vector4(vec.x, vec.y, vec.z, 0); Debug.Log(c + ":" + count); } else { if (c >= count) { Debug.Log("this is end"); c = 0; } } } else { if (properties[pcount].y < 1.0) { properties[pcount] += new Vector4(0, 0.005f, 0, 0); } } } for (int i = 0; i < positions.Length; i++) { positions[i] += new Vector4(UnityEngine.Random.Range(-0.1f, +0.1f), UnityEngine.Random.Range(-0.1f, +0.1f), 0, 0) * Time.deltaTime; } material.SetInt("_Points_Length", count); material.SetVectorArray("_Points", positions); material.SetVectorArray("_Properties", properties); }
// Update is called once per frame void Update() { var pose = FoveManager.GetHMDPose(); var conv = FoveManager.GetHMDGazeConvergence(); var foveConv = fove.GetGazeConvergence(); ManagerOrientText.text = toFomattedString(pose.orientation.ToQuaternion()); ManagerPosText.text = toFomattedString(pose.position.ToVector3()); ManagerGazeText.text = toFomattedString(conv.ray.direction); InterfaceOrientText.text = toFomattedString(fove.transform.rotation); InterfacePosText.text = toFomattedString(fove.transform.position); InterfaceGazeText.text = toFomattedString(foveConv.ray.direction); }
private void Extract(Vector3 r_hit, Vector3 l_hit, GameObject desired) { s.right_hitpoint = r_hit; s.left_hitpoint = l_hit; s.desired_object_position = desired.transform.position; s.desired_object_scale = desired.transform.localScale; Fove.Unity.EyeRays rays = m_foveInterface.GetGazeRays(); s.right_eye_ray = rays.right; s.left_eye_ray = rays.left; Fove.Unity.GazeConvergenceData converged_Gaze = m_foveInterface.GetGazeConvergence(); s.gaze_convergence_ray = converged_Gaze.ray; s.distance_of_convergence = converged_Gaze.distance; // s.eyes_closed = Fove.CheckEyesClosed(); }
private void Update() { RaycastHit hit; myEyeStruct = FoveInterface.CheckEyesClosed(); gcd = FoveInterface.GetGazeConvergence(); if (!prevgcd.Equals(gcd) || prev == "") { Physics.Raycast(gcd.ray, out hit, Mathf.Infinity); transform.position = hit.point; prevgcd = gcd; //Debug.Log("(accuracy,distance,ray) " + gcd.accuracy + " " + gcd.distance + " " + gcd.ray); } if (prev == "" || prev != myEyeStruct.ToString()) { prev = myEyeStruct.ToString(); //Debug.Log(prev); } }
// Update is called once per frame. Figure out what the user is looking at void Update() { // Get the current time long currentTimeTicks = DateTime.Now.Ticks; List <string> currentLookAtItemPath = null; // Get a normalize ray of the direction the user's eye is looking at FoveInterfaceBase.GazeConvergenceData gazeConvergenceData = FoveInterface.GetGazeConvergence(); // Determine where the ray hit if it does hit something RaycastHit eyeRayHit; Physics.Raycast(gazeConvergenceData.ray, out eyeRayHit, Mathf.Infinity); // If the ray does hit something, put the cursor at that location if (eyeRayHit.point != Vector3.zero) { transform.position = eyeRayHit.point; currentLookAtItemPath = TransformToObjectPath(eyeRayHit.collider.transform); } // Else, just set it as a point 3 meters away in the direction of the ray // and determine what user is looking at in the skybox else { transform.position = gazeConvergenceData.ray.GetPoint(3.0f); Vector3 gazeDirection = gazeConvergenceData.ray.direction; // Convert from spherical coordinates to longitude and latitude float magnitude = gazeDirection.magnitude; float longitude = Mathf.PI - Mathf.Acos(gazeDirection.y / magnitude); // 0 to PI float latitude = Mathf.Atan2(gazeDirection.x, gazeDirection.z) + Mathf.PI; // 0 to 2 * PI // Map longitude/latitude over to UV coordinates float U = (latitude / (Mathf.PI * 2.0f)) % 1.0f; float V = (longitude / Mathf.PI) % 1.0f; // See if user is looking at a labeled area Color gazeItemColor = labelTexture.GetPixel((int)(U * labelTexture.width), (int)(V * labelTexture.height)); // Fix any floating point rounding issues -- nearest 0.01 gazeItemColor.r = (float)Math.Round(gazeItemColor.r, 2); gazeItemColor.g = (float)Math.Round(gazeItemColor.g, 2); gazeItemColor.b = (float)Math.Round(gazeItemColor.b, 2); // Keep track of what the user is looking at if (labelDictionary.ContainsKey(gazeItemColor)) { currentLookAtItemPath = labelDictionary[gazeItemColor]; } else { currentLookAtItemPath = null; } } // Keep track of eye blink Fove.Managed.EFVR_Eye eyeClosedStatus = FoveInterface.CheckEyesClosed(); if ((lastEyeClosedStatus != Fove.Managed.EFVR_Eye.Neither) && (eyeClosedStatus == Fove.Managed.EFVR_Eye.Neither)) { currentEyeBlinkCount++; } // Keep track of the duration we've looked at that item and blink count long totalLookAtDuration = eyeTrackingLogger.UpdateLabels(currentLookAtItemPath, currentTimeTicks - lastUpdateTimeTicks, currentEyeBlinkCount - lastEyeBlinkCount); // Make sure labeled text is facing user transform.LookAt(foveHeadset.transform); transform.RotateAround(transform.position, transform.up, 180.0f); // Set the labeler to how long we've looked at that item string itemName = (currentLookAtItemPath == null) ? "null" : currentLookAtItemPath[currentLookAtItemPath.Count - 1]; ((TextMesh)eyeLabeler.GetComponent(typeof(TextMesh))).text = itemName + Environment.NewLine + (totalLookAtDuration / TimeSpan.TicksPerMillisecond) + " ms"; // Only render if user specified eyeCursor.GetComponent <Renderer>().enabled = renderCursor; eyeLabeler.GetComponent <Renderer>().enabled = renderCursor; // Update state lastUpdateTimeTicks = currentTimeTicks; lastEyeClosedStatus = eyeClosedStatus; lastEyeBlinkCount = currentEyeBlinkCount; }