Ejemplo n.º 1
0
    private static void Render(Material mat, ref G2OM_DeviceData deviceData, G2OM_Candidate[] g2omCandidates, G2OM_CandidateResult[] g2OmCandidatesResult, G2OM_Vector3[] corners, bool renderLeftAndRightEye)
    {
        mat.SetPass(0);

        for (var i = 0; i < g2omCandidates.Length; i++)
        {
            var g2OmCandidate = g2omCandidates[i];

            var result = Interop.G2OM_GetWorldspaceCornerOfCandidate(ref g2OmCandidate, (uint)corners.Length, corners);
            if (result != G2OM_Error.Ok)
            {
                Debug.LogError(string.Format("Failed to get corners of candidate {0}. Error code: {1}", g2OmCandidate.Id, result));
                continue;
            }

            Color resultingColor = GetResultColor(g2OmCandidatesResult, g2OmCandidate.Id);

            RenderCube(corners, resultingColor);
        }

        RenderGaze(deviceData.combined, Color.yellow);

        if (renderLeftAndRightEye)
        {
            RenderGaze(deviceData.leftEye, Color.blue);
            RenderGaze(deviceData.rightEye, Color.red);
        }
    }
Ejemplo n.º 2
0
        public G2OM_RaycastResult GetRaycastResult(ref G2OM_DeviceData deviceData, IG2OM_ObjectDistinguisher distinguisher)
        {
            var raycastResult = new G2OM_RaycastResult();

            GameObject go;
            var        result = FindGameObject(ref deviceData.combined, _layerMask, out go);

            if (result)
            {
                var id            = go.GetInstanceID();
                var hitACandidate = distinguisher.IsGameObjectGazeFocusable(id, go);
                raycastResult.combined = new G2OM_Raycast(hitACandidate, id);
            }

            result = FindGameObject(ref deviceData.leftEye, _layerMask, out go);
            if (result)
            {
                var id            = go.GetInstanceID();
                var hitACandidate = distinguisher.IsGameObjectGazeFocusable(id, go);
                raycastResult.left = new G2OM_Raycast(hitACandidate, id);
            }

            result = FindGameObject(ref deviceData.rightEye, _layerMask, out go);
            if (result)
            {
                var id            = go.GetInstanceID();
                var hitACandidate = distinguisher.IsGameObjectGazeFocusable(id, go);
                raycastResult.right = new G2OM_Raycast(hitACandidate, id);
            }

            return(raycastResult);
        }
 void LateUpdate()
 {
     if (_freezeVisualization == false)
     {
         _candidates      = TobiiXR.Internal.G2OM.GetCandidates();
         _candidateResult = TobiiXR.Internal.G2OM.GetCandidateResult();
         _deviceData      = TobiiXR.Internal.G2OM.GetDeviceData();
     }
 }
Ejemplo n.º 4
0
 void LateUpdate()
 {
     if (_freezeVisualization == false)
     {
         _candidates      = _g2om.GetCandidates();
         _candidateResult = _g2om.GetCandidateResult();
         _deviceData      = _g2om.GetDeviceData();
     }
 }
Ejemplo n.º 5
0
        public void GetRelevantGazeObjects(ref G2OM_DeviceData deviceData, Dictionary <int, GameObject> foundObjects, IG2OM_ObjectDistinguisher distinguisher)
        {
            foundObjects.Clear();

            foreach (var registeredObject in G2OM_ObjectRegistry.Registry)
            {
                foundObjects.Add(registeredObject.Key, registeredObject.Value);
            }
        }
Ejemplo n.º 6
0
    public void Setup(G2OM g2om, Camera mainCamera)
    {
        _g2om = g2om;
        _mat  = new Material(Shader.Find("Hidden/Internal-Colored"));

        _candidates      = g2om.GetCandidates();
        _candidateResult = g2om.GetCandidateResult();
        _deviceData      = g2om.GetDeviceData();

        _mainCamera = mainCamera;

        _camera         = GetComponent <Camera>();
        _camera.enabled = false;
    }
        private void Render(Material mat, ref G2OM_DeviceData deviceData, G2OM_Candidate[] g2omCandidates, G2OM_CandidateResult[] g2OmCandidatesResult, G2OM_Vector3[] corners)
        {
            mat.SetPass(0);

            RenderBackground();

            for (var i = 0; i < g2omCandidates.Length; i++)
            {
                var g2OmCandidate = g2omCandidates[i];

                var result = Interop.G2OM_GetWorldspaceCornerOfCandidate(ref g2OmCandidate, (uint)corners.Length, corners);
                if (result != G2OM_Error.Ok)
                {
                    Debug.LogError(string.Format("Failed to get corners of candidate {0}. Error code: {1}", g2OmCandidate.candidate_id, result));
                    continue;
                }

                Color resultingColor = GetResultColor(g2OmCandidatesResult, g2OmCandidate.candidate_id);

                RenderCube(corners, resultingColor);
            }

            RenderGaze(deviceData.gaze_ray_world_space, Color.yellow);
        }