コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (acquireEyeDatas)
        {
            LeftEye         = FoveInterface.GetLeftEyeVector();
            RightEye        = FoveInterface.GetRightEyeVector();
            acquireEyeDatas = targetMoveScript.trainingRunning;

            Frame FrameLeft = new Frame();
            FrameLeft.timeStamp = Time.time;
            FrameLeft.EyePos    = LeftEye;

            Frame FrameRight = new Frame();
            FrameRight.timeStamp = Time.time;
            FrameRight.EyePos    = RightEye;

            FrameLeft.EyePos = targetMoveScript.gameObject.transform.position; // :!!!!!!!

            framelistLeft.FrameList.Add(FrameLeft);
            framelistRight.FrameList.Add(FrameRight);

            /*if (!acquireEyeDatas)
             *  WriteEyesData();*/
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            readEyeData();
        }
    }
コード例 #2
0
    // Correct the yaw drift component of the FOVE headset
    private void CorrectHeadsetYawDrift()
    {
        long currentTimeMs         = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
        long timeSinceLastUpdateMs = currentTimeMs - lastDriftCorrectionTimeMs;

        if (timeSinceLastUpdateMs < (long)millisecondsBetweenDriftCorrection)
        {
            return;
        }

        Quaternion foveToFlatSurface     = Quaternion.Euler(FoveHeadsetTareOrientation.eulerAngles.x, 0.0f, FoveHeadsetTareOrientation.eulerAngles.z);
        Quaternion viveToFlatSurface     = Quaternion.Euler(ViveTrackerTareOrientation.eulerAngles.x, 0.0f, ViveTrackerTareOrientation.eulerAngles.z);
        Quaternion tareFoveOnFlatSurface = (FoveHeadsetTareOrientation * Quaternion.Inverse(foveToFlatSurface));
        Quaternion tareViveOnFlatSurface = (ViveTrackerTareOrientation * Quaternion.Inverse(viveToFlatSurface));

        Quaternion currentFoveRotation  = FoveInterface.GetHMDRotation();
        Quaternion curFoveOnFlatSurface = (currentFoveRotation * Quaternion.Inverse(foveToFlatSurface));
        Quaternion curViveOnFlatSurface = (currentViveTrackerPose.rot * Quaternion.Inverse(viveToFlatSurface));

        Quaternion desiredYawDiff = tareFoveOnFlatSurface * Quaternion.Inverse(tareViveOnFlatSurface);
        Quaternion currentYawDiff = curFoveOnFlatSurface * Quaternion.Inverse(curViveOnFlatSurface);

        yawDriftCorrectionOffset = (desiredYawDiff * Quaternion.Inverse(currentYawDiff)).eulerAngles.y;

        lastDriftCorrectionTimeMs = currentTimeMs;
    }
コード例 #3
0
ファイル: FOVELookSample.cs プロジェクト: oi7/GIX510
    // Update is called once per frame
    void Update()
    {
        Vector3    position    = UnityEngine.FoveInterface.GetHMDPosition();
        string     pos_str     = position.ToString();
        Quaternion orientation = UnityEngine.FoveInterface.GetHMDRotation();
        string     ori_str     = orientation.ToString();

        Debug.Log(pos_str);
        Debug.Log(ori_str);

        if (FoveInterface.IsLookingAtCollider(my_collider))
        {
            if (light_enabled)
            {
                l.enabled = true;
                m.SetColor("_EmissionColor", l.color);
                DynamicGI.SetEmissive(GetComponent <Renderer>(), l.color);
                m.EnableKeyword("_EMISSION");
            }
            //bool check = FoveInterface.IsLookingAtCollider(my_collider);
        }
        else
        {
            gameObject.GetComponent <Renderer> ().material.color = Color.white;
            //GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
            m.DisableKeyword("_EMISSION");
            if (light_enabled)
            {
                l.enabled = false;
                DynamicGI.SetEmissive(GetComponent <Renderer>(), Color.black);
            }
        }
    }
コード例 #4
0
    // Update is called once per frame
    private void Update()
    {
        Ray ray = new Ray(this.transform.position, FoveInterface.GetHMDRotation() * Vector3.forward * distance);

        //Rayを画面に表示
        Debug.DrawRay(ray.origin, ray.direction * distance, Color.green);

        /*
         * Debug.LogFormat("Rotation x : {0}, y: {1} z: {2} ",
         *          ray.direction.x, ray.direction.y, ray.direction.z);
         */

        Debug.LogFormat("{0}", Mathf.Round(FoveInterface.GetHMDPosition().z));
        // まばたきでボールを飛ばすように
        countTime += Time.deltaTime;

        if (FoveInterface.CheckEyesClosed() == EFVR_Eye.Both &&
            countTime > blinkThreshold)
        {
            GameObject tempBall = MakeBall();
            tempBall.GetComponent <BaketBall>().Shot(ray.direction * power);
            tempBall  = null;
            countTime = 0;
        }
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        /*
         * If eyes have been closed, start the timer
         */
        if (FoveInterface.CheckEyesClosed() == Fove.EFVR_Eye.Both)
        {
            t.started = true;
        }

        if (t.started)
        {
            t.value += Time.deltaTime;
        }

        if (FoveInterface.CheckEyesClosed() == Fove.EFVR_Eye.Neither && t.started)
        {
            /*
             * If time between closing and opening eyes is less than the threshold
             * A blink has been detected
             */
            if (t.value < blinkThreshold)
            {
                blinkLight.enabled = !blinkLight.enabled;
            }

            t.started = false;
            t.value   = 0;
        }
    }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        transform.position = new Vector3(0, 0, -10);
        if (Input.GetKeyDown(KeyCode.M))
        {
            this.GetComponent <Renderer>().enabled = true;
        }

        if (this.GetComponent <Renderer>().enabled)
        {
            RaycastHit    hit;
            FoveInterface foveInterface = transform.parent.GetComponent <FoveInterface>();
            Ray           ray           = new Ray(foveInterface.transform.position, foveInterface.transform.forward);
            if (Physics.Raycast(ray, out hit, 10.0f))
            {
                transform.position = hit.point;
            }
            else
            {
                transform.position = foveInterface.transform.position + foveInterface.transform.forward * 10f;
            }
        }

        if (Input.GetKeyUp(KeyCode.M))
        {
            this.GetComponent <Renderer>().enabled = false;
            Vector3 loc = transform.localPosition;
            Fove.Managed.SFVR_Vec3 driftLocation;
            driftLocation.x = loc.x;
            driftLocation.y = loc.y;
            driftLocation.z = loc.z;
            FoveInterfaceBase.GetFVRHeadset().ManualDriftCorrection3D(driftLocation);
        }
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        Scene scene = SceneManager.GetActiveScene();

        orientationDataFilePath = "./DataRecordings/" + participantId + "_" + scene.name + DateTime.Now.ToString("MM-dd-yy_hh-mm-ss") + "_tracking.csv";
        cueTypeDataFilePath     = "./DataRecordings/" + participantId + "_" + scene.name + DateTime.Now.ToString("MM-dd-yy_hh-mm-ss") + "_cues.csv";
        cueLocationDataFilePath = "./DataRecordings/" + participantId + "_" + scene.name + DateTime.Now.ToString("MM-dd-yy_hh-mm-ss") + "_cueLocation.csv";

        orientationStringWriter = new StreamWriter(orientationDataFilePath);
        string[] trackingHeaders = new string[] { "video_time", "x_rot", "y_rot", "z_rot", "quat_x", "quat_y", "quat_z", "quat_w",
                                                  "left_eye_vector_x", "left_eye_vector_y", "left_eye_vector_z", "right_eye_vector_x", "right_eye_vector_y", "right_eye_vector_z",
                                                  "left_eye_texture_x", "left_eye_texture_y", "right_eye_texture_x", "right_eye_texture_y", "inside_target_area" };
        orientationStringWriter.Write(string.Join(delimiter, trackingHeaders) + "\n");

        cueTypeStringWriter = new StreamWriter(cueTypeDataFilePath);
        string[] cueTypeHeaders = new string[] { "video_time", "cue_ype" };
        cueTypeStringWriter.Write(string.Join(delimiter, cueTypeHeaders) + "\n");
        cueTypeStringWriter.Close();

        cueLocationStringWriter = new StreamWriter(cueLocationDataFilePath);
        string[] cueLocationHeaders = new string[] { "video_time", "long", "lat", "pixel_x", "pixel_y", "cue_type" };
        cueLocationStringWriter.Write(string.Join(delimiter, cueLocationHeaders) + "\n");

        foveInterface = fove.GetComponent <FoveInterface>();
    }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        FoveInterface.EyeRays rays = FoveInterface.GetEyeRays();
        //var point = rays.left.GetPoint(1.0f);
        //indicator.transform.position = point;
        RaycastHit hit;

        Physics.Raycast(rays.right, out hit, Mathf.Infinity);
        var vector1 = hit.point - node1.transform.position;
        var vector2 = node2.transform.position - node1.transform.position;
        var angle1  = Vector3.Angle(vector1, vector2);

        var vector3 = hit.point - node2.transform.position;
        var vector4 = node1.transform.position - node2.transform.position;
        var angle2  = Vector3.Angle(vector3, vector4);

        //Debug.LogFormat("angle 1: {0}, angle 2: {1}", angle1, angle2);
        highlight(angle1, angle2);

        if (Input.GetKeyDown(KeyCode.Space))
        {
            cleanTargetsOnMenu();
            //further selection
            displayTargetsOnMenu();
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            //clear all targets on menu
            TargetsController.selectedList.Clear();
        }
    }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        //sendMsg (my_collider);
        if (FoveInterface.IsLookingAtCollider(my_collider))
//send osc message mycollider.position
        {
            //Debug.Log ("HIER"+my_collider.transform.position.x+" "+my_collider.transform.position.y+" "+my_collider.transform.position.z);
            sendMsg(my_collider);
            //OscSender.sendMsg (my_collider);
            if (light_enabled)
            {
                l.enabled = true;
                m.SetColor("_EmissionColor", l.color);
                DynamicGI.SetEmissive(GetComponent <Renderer>(), l.color);
                m.EnableKeyword("_EMISSION");
            }
            //bool check = FoveInterface.IsLookingAtCollider(my_collider);
        }
        else
        {
            gameObject.GetComponent <Renderer> ().material.color = Color.white;
            //GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
            m.DisableKeyword("_EMISSION");
            if (light_enabled)
            {
                l.enabled = false;
                DynamicGI.SetEmissive(GetComponent <Renderer>(), Color.black);
            }
        }
    }
コード例 #10
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.M))
        {
            this.GetComponent <Renderer>().enabled = true;
        }

        if (this.GetComponent <Renderer>().enabled)
        {
            RaycastHit    hit;
            FoveInterface foveInterface = transform.parent.GetComponent <FoveInterface>();
            Ray           ray           = new Ray(foveInterface.transform.position, foveInterface.transform.forward);
            if (Physics.Raycast(ray, out hit, 10.0f))
            {
                transform.position = hit.point;
            }
            else
            {
                transform.position = foveInterface.transform.position + foveInterface.transform.forward * 1.5f;
            }
        }

        if (Input.GetKeyUp(KeyCode.M))
        {
            this.GetComponent <Renderer>().enabled = false;
            Fove.FoveHeadset.GetHeadset().ManualDriftCorrection3D(transform.localPosition);
        }
    }
コード例 #11
0
 // Update is called once per frame
 void Update()
 {
     if (FoveInterface.IsLookingAtCollider(my_collider))
     {
         if (light_enabled)
         {
             l.enabled = true;
             m.SetColor("_EmissionColor", l.color);
             DynamicGI.SetEmissive(GetComponent <Renderer>(), l.color);
             m.EnableKeyword("_EMISSION");
         }
         //bool check = FoveInterface.IsLookingAtCollider(my_collider);
     }
     else
     {
         gameObject.GetComponent <Renderer> ().material.color = Color.white;
         //GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
         m.DisableKeyword("_EMISSION");
         if (light_enabled)
         {
             l.enabled = false;
             DynamicGI.SetEmissive(GetComponent <Renderer>(), Color.black);
         }
     }
 }
コード例 #12
0
    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);
    }
コード例 #13
0
ファイル: FoveCursor1.cs プロジェクト: Yoshiya1113/Fove
    // Update is called once per frame
    void Update()
    {
        FoveInterface.EyeRays eyes = FoveInterface.GetEyeRays();
        RaycastHit            hitLeft, hitRight;

        switch (FoveInterface.CheckEyesClosed())
        {
        case Fove.EFVR_Eye.Neither:

            Physics.Raycast(eyes.left, out hitLeft, Mathf.Infinity);
            Physics.Raycast(eyes.right, out hitRight, Mathf.Infinity);
            if (hitLeft.point != Vector3.zero && hitRight.point != Vector3.zero)
            {
                transform.position = hitLeft.point + ((hitRight.point - hitLeft.point) / 2);
            }
            else
            {
                transform.position = eyes.left.GetPoint(3.0f) + ((eyes.right.GetPoint(3.0f) - eyes.left.GetPoint(3.0f)) / 2);
            }

            /*Debug.Log("NotWink");
             * Debug.Log("Right:" + eyes.right);
             * Debug.Log("Hit_R:" + hitRight.point);
             * Debug.Log("Left:" + eyes.left);
             * Debug.Log("Hit_L" + hitLeft.point);*/
            break;

        case Fove.EFVR_Eye.Left:

            Physics.Raycast(eyes.right, out hitRight, Mathf.Infinity);
            if (hitRight.point != Vector3.zero)     // Vector3 is non-nullable; comparing to null is always false
            {
                transform.position = hitRight.point;
            }
            else
            {
                transform.position = eyes.right.GetPoint(3.0f);
            }
            break;

        case Fove.EFVR_Eye.Right:

            Physics.Raycast(eyes.left, out hitLeft, Mathf.Infinity);
            if (hitLeft.point != Vector3.zero)     // Vector3 is non-nullable; comparing to null is always false
            {
                transform.position = hitLeft.point;
            }
            else
            {
                transform.position = eyes.left.GetPoint(3.0f);
            }
            break;
        }
    }
コード例 #14
0
 // Update is called once per frame
 void Update()
 {
     if (FoveInterface.IsLookingAtCollider(mCollider))
     {
         Debug.Log("COLLISION");
         this.GetComponent <Renderer>().material = _material[1];
     }
     else
     {
         this.GetComponent <Renderer>().material = _material[0];
     }
 }
コード例 #15
0
 // Update is called once per frame
 void Update()
 {
     if (FoveInterface.IsLookingAtCollider(mCollider))
     {
         Debug.Log("COLLISION");
         mLight.enabled = true;
     }
     else
     {
         mLight.enabled = false;
     }
 }
コード例 #16
0
    /**
     * Helper function for calibration setup.
     * This will perform the following procedures
     *
     *    1) Initialize eye tracking calibration
     *    2) Ensure Vive Tracker for Headset and Vive Controllers are connected
     *    3) Prompt to calibrate FOVE headset to Vive space (Press H)
     *    4) Load initial scene (Scene_000) if everything is completed
     */
    private void RunCalibrationSetup()
    {
        if (eyeTrackerCalibrationStarted == false)
        {
            FoveInterface.EnsureEyeTrackingCalibration();
            eyeTrackerCalibrationStarted = true;
        }

        if (RenderSettings.skybox != defaultSkyboxMaterial)
        {
            RenderSettings.skybox = defaultSkyboxMaterial;
        }

        bool eyeTrackerCalibrated        = (!FoveInterface.IsEyeTrackingCalibrating() && FoveInterface.IsEyeTrackingCalibrated());
        bool headsetCalibrated           = headsetLocalizationInstance.IsHeadsetCalibrated();
        bool viveTrackerHeadsetConnected = headsetLocalizationInstance.IsHeadsetPositionTracked();
        bool controllersConnected        = headsetLocalizationInstance.IsControllersConnected();

        string uiPromptMessage = "";

        if (viveTrackerHeadsetConnected == false)
        {
            uiPromptMessage += "Please turn on Vive Tracker for headset.\n";
        }
        if (controllersConnected == false)
        {
            uiPromptMessage += "Please connect both Vive controllers.\n";
        }
        if (eyeTrackerCalibrated == false)
        {
            uiPromptMessage += "Please calibrate eye tracking.\n";
        }
        if (headsetCalibrated == false)
        {
            uiPromptMessage += "Please calibrate headset and vive to world space [H]\n";
        }
        uiPrompt.SetUiPromptMessage(uiPromptMessage);
        uiPrompt.TurnOnUiPrompt();

        if (eyeTrackerCalibrated && headsetCalibrated)
        {
            systemCalibrated = true;
            uiPrompt.TurnOffUiPrompt();

            // Initialize a new scene
            headsetLocalizationInstance.ReCenterUser();
            eyeTrackerInstance.CreateNewScene(GenerateSceneName(currentSceneNumber));
            SceneManager.LoadSceneAsync(GenerateSceneName(currentSceneNumber), LoadSceneMode.Additive);
            ChangeSkybox(currentSceneNumber);
            currentSceneState = SCENE_CHANGE_STATE.Changing;
        }
    }
コード例 #17
0
    // Latepdate ensures that the object doesn't lag behind the user's head motion
    void Update()
    {
        //set value
        rays        = fove.GetGazeRays_Immediate();
        myEyeStruct = FoveInterface.CheckEyesClosed();
        //raycast
        Physics.Raycast(rays.right, out hit, Mathf.Infinity);

        if (hit.point != Vector3.zero) //&& (myEyeStruct == EFVR_Eye.Left || myEyeStruct == EFVR_Eye.Both))
        {
            transform.position = hit.point;
        }
    }
コード例 #18
0
    void drawLeftEyeRay()
    {
        FoveInterface.EyeRays rays = FoveInterface.GetEyeRays();
        var origin = rays.left.origin;
        var merge  = rays.left.GetPoint(10f);

        Debug.Log(origin.x);
        Debug.Log(merge.x);

        lineRenderer.numCapVertices = 2;
        lineRenderer.SetPosition(0, origin);
        lineRenderer.SetPosition(1, merge);
    }
コード例 #19
0
    // Latepdate ensures that the object doesn't lag behind the user's head motion
    void Update()
    {
        FoveInterface.EyeRays rays = FoveInterface.GetEyeRays();
        Ray r = rays.left;

        RaycastHit   hit;
        MeshCollider coll = videoSphere.GetComponent <MeshCollider>();

        if (coll != null && coll.Raycast(r, out hit, Mathf.Infinity))
        {
            transform.position = hit.point;
        }
    }
    // Update is called once per frame
    private void UpdatePositionBasedOnEyes()
    {
        // this is from here.. maybe better robustness against lost tracking: https://github.com/twday/Fove-Unity-Examples/blob/master/Assets/Examples/FoveCursor/Scripts/FoveCursor.cs

        FoveInterface.EyeRays eyes = FoveInterface.GetEyeRays();
        RaycastHit            hitLeft, hitRight;

        switch (FoveInterface.CheckEyesClosed())
        {
        case Fove.EFVR_Eye.Neither:

            Physics.Raycast(eyes.left, out hitLeft, Mathf.Infinity);
            Physics.Raycast(eyes.right, out hitRight, Mathf.Infinity);
            if (hitLeft.point != Vector3.zero && hitRight.point != Vector3.zero)
            {
                transform.position = hitLeft.point + ((hitRight.point - hitLeft.point) / 2);
            }
            else
            {
                transform.position = eyes.left.GetPoint(3.0f) + ((eyes.right.GetPoint(3.0f) - eyes.left.GetPoint(3.0f)) / 2);
            }

            break;

        case Fove.EFVR_Eye.Left:

            Physics.Raycast(eyes.right, out hitRight, Mathf.Infinity);
            if (hitRight.point != Vector3.zero)     // Vector3 is non-nullable; comparing to null is always false
            {
                transform.position = hitRight.point;
            }
            else
            {
                transform.position = eyes.right.GetPoint(3.0f);
            }
            break;

        case Fove.EFVR_Eye.Right:

            Physics.Raycast(eyes.left, out hitLeft, Mathf.Infinity);
            if (hitLeft.point != Vector3.zero)     // Vector3 is non-nullable; comparing to null is always false
            {
                transform.position = hitLeft.point;
            }
            else
            {
                transform.position = eyes.left.GetPoint(3.0f);
            }
            break;
        }
    }
コード例 #21
0
    void Update()
    {
        if (Input.GetKeyDown(VisualizeEyesKey))
        {
            VisualizeEyes = !VisualizeEyes;
        }
        if (Input.GetKeyDown(VisualizeMidpointKey))
        {
            VisualizeMidPoint = !VisualizeMidPoint;
        }

        FoveInterface.EyeRays rays = FoveInterface.GetEyeRays();

        // LEFT
        Ray     rayLeft       = rays.left;
        Vector3 leftOrigin    = rayLeft.origin;
        Vector3 leftDirection = rayLeft.direction;
        Vector3 leftWorldPos  = leftOrigin + (DistanceOriginWorldPoint * leftDirection);

        // RIGHT
        Ray     rayRight       = rays.right;
        Vector3 rightOrigin    = rayRight.origin;
        Vector3 rightDirection = rayRight.direction;
        Vector3 rightWorldPos  = rightOrigin + (DistanceOriginWorldPoint * rightDirection);

        if (VisualizeEyes)
        {
            LeftPointer.transform.position  = leftWorldPos;
            RightPointer.transform.position = rightWorldPos;
        }

        // MIDPOINT
        Vector3 midpoint = (rightWorldPos + leftWorldPos) / 2;

        if (VisualizeMidPoint)
        {
            MidpointPointer.transform.position = midpoint;
        }

        var tempObj = GetFocussedHighlightPiece(midpoint);

        if (tempObj != null)
        {
            if (highlightedObject != tempObj)
            {
                highlightedObject = tempObj;
                GazeHighLighter.SetProceduralBox(highlightedObject);
            }
        }
    }
コード例 #22
0
    // Use this for initialization
    void Start()
    {
        Scene scene = SceneManager.GetActiveScene();

        orientationDataFilePath = "./DataRecordings/" + participantId + "_" + scene.name + DateTime.Now.ToString("MM-dd-yy_hh-mm-ss") + ".csv";

        orientationStringWriter = new StreamWriter(orientationDataFilePath);
        string[] headers = new string[] { "video_time", "x_rot", "y_rot", "z_rot", "quat_x", "quat_y", "quat_z", "quat_w",
                                          "left_eye_vector_x", "left_eye_vector_y", "left_eye_vector_z", "right_eye_vector_x", "right_eye_vector_y", "right_eye_vector_z",
                                          "left_eye_texture_x", "left_eye_texture_y", "right_eye_texture_x", "right_eye_texture_y" };
        orientationStringWriter.Write(string.Join(delimiter, headers) + "\n");

        foveInterface = fove.GetComponent <FoveInterface>();
    }
コード例 #23
0
    // Update is called once per frame
    void Update()
    {
        //時間関連データの取得
        nt = DateTime.Now;     //ここに到達したときの時刻を取得する
        TimeSpan ts = nt - st; //実行からどれくらい経過しているのかを計算

        //fpsの計算
        ++frameCount;
        float time = Time.realtimeSinceStartup - prevTime;

        if (time >= 0.5f)
        {
            fpstime = frameCount / time;
            //Debug.LogFormat("{0}fps", fpstime);
            frameCount = 0;
            prevTime   = Time.realtimeSinceStartup;
        }

        //目のデータの取得
        FoveInterface.EyeRays eyes = FoveInterface.GetEyeRays();

        //HMD関連のデータの取得
        hmdpos = FoveInterface.GetHMDPosition(); //HMDの位置座標
        hmdrot = FoveInterface.GetHMDRotation(); //HMDの方向座標
        //Debug.Log(hmdpos.x + "," + hmdpos.y + "," + hmdpos.z + "," + hmdrot.x + "," + hmdrot.y + "," + hmdrot.z + "," + hmdrot.w);

        if (Input.GetKeyDown(KeyCode.Space))
        {
            tf = 1;
        }

        if (tf == 1)//csvへの書き込み
        {
            //CSVに記録する情報
            //現在時刻,現在時刻のミリ秒,経過時間,経過時間のミリ秒,fps,チェッカールームの回転速度,眼球の座標(左),眼球の座標(右),視線のベクトル(左),視線のベクトル(右),HMDの座標,HMDの向き
            streamWriter.Write(nt.ToString() + ',' + nt.Millisecond.ToString() + ',' + ts.ToString() + ',' + nt.Millisecond.ToString() + ','
                               + eyes.right.origin.x.ToString() + ',' + eyes.right.origin.y.ToString() + ',' + eyes.right.origin.z.ToString() + ','
                               + eyes.left.origin.x.ToString() + ',' + eyes.left.origin.y.ToString() + ',' + eyes.left.origin.z.ToString() + ','
                               + hmdpos.x.ToString() + ',' + hmdpos.y.ToString() + ',' + hmdpos.z.ToString() + ','
                               + hmdrot.x.ToString() + ',' + hmdrot.y.ToString() + ',' + hmdrot.z.ToString() + ',' + hmdrot.w.ToString()); //csvに書き込むデータのリスト
            streamWriter.WriteLine();                                                                                                      //データの取得
            Debug.Log("書き込み中");
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            streamWriter.Close();//csvに書き込む
            Debug.Log("書き込み終了");
        }
    }
コード例 #24
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Graphics.Blit(source, destination);

        if (_compositor == null)
        {
            return;
        }

        IntPtr texPtr = source.GetNativeTexturePtr();

        if (texPtr != IntPtr.Zero)
        {
            _layerSubmitInfo.pose = FoveInterface.GetLastPose();
            switch (whichEye)
            {
            case EFVR_Eye.Left:
                _layerSubmitInfo.left.texInfo.pTexture  = texPtr;
                _layerSubmitInfo.right.texInfo.pTexture = IntPtr.Zero;
                break;

            case EFVR_Eye.Right:
                _layerSubmitInfo.left.texInfo.pTexture  = IntPtr.Zero;
                _layerSubmitInfo.right.texInfo.pTexture = texPtr;
                break;

            default:
                Debug.LogError("[FOVE] Camera set to " + whichEye + " which isn't supported.");
                return;
            }

            var result = _compositor.Submit(ref _layerSubmitInfo);
            if (result != EFVR_ErrorCode.None)
            {
                Debug.LogWarning("[FOVE] Submit returned unexpected " + result);
            }

            GL.Flush();
        }
        else
        {
            Debug.LogWarning("RenderTexture native pointer is null; cannot submit null texture pointers.");
        }

        if (!suppressProjectionUpdates)
        {
            couldUseNewMatrices = true;
        }
    }
コード例 #25
0
 void Awake()
 {
     VRCamera                  = GetComponent <Camera>();
     Instance                  = this;
     Cursor.visible            = false;
     _lineRenderer             = GetComponent <LineRenderer>();
     _pupilTracker             = FindObjectOfType <PupilGazeTracker>();
     _foveInterface            = GetComponent <FoveInterface>();
     _viveControllerTransforms = new List <Transform>();
     _viveControllerTransforms.Add(transform.root.Find("Controller (right)"));
     //_viveControllerTransforms.Add(transform.root.Find("Controller (left)"));
     if (_drawRay)
     {
         _lineRenderer.positionCount = 2;
     }
 }
コード例 #26
0
        private void Update()
        {
            //move the weapon in function of Type of Inputs
            if (m_camInputManager.CurrentInputName == "Mouse")
            {
                transform.position = m_cameraTransform.position;
                transform.rotation = m_cameraTransform.rotation;
            }
            else if (m_camInputManager.CurrentInputName == "Gamepad")
            {
                transform.position = m_cameraTransform.position;

                if (m_camInputManager.CurrentCamera.name == "VRCamera")
                {
                    transform.rotation = Quaternion.Slerp(transform.rotation, InputTracking.GetLocalRotation(VRNode.Head),
                                                          m_Damping * (1 - Mathf.Exp(k_DampingCoef * Time.deltaTime)));

                    Quaternion lookAtRotation = Quaternion.LookRotation(m_VRReticle.ReticleTransform.position - m_gunContainer.position);
                    m_gunContainer.rotation = Quaternion.Slerp(m_gunContainer.rotation, lookAtRotation, m_GunContainerSmoothing * Time.deltaTime);
                }
                else if (m_camInputManager.CurrentCamera.name == "FoveInterface")
                {
                    Quaternion quat = FoveInterface.GetHMDRotation();
                    transform.rotation = Quaternion.Slerp(transform.rotation, quat,
                                                          m_Damping * (1 - Mathf.Exp(k_DampingCoef * Time.deltaTime)));

                    Quaternion lookAtRotation = Quaternion.LookRotation(m_VRReticle.ReticleTransform.position - m_gunContainer.position);
                    m_gunContainer.rotation = Quaternion.Slerp(m_gunContainer.rotation, lookAtRotation, m_GunContainerSmoothing * Time.deltaTime);
                }
            }

            else if (m_camInputManager.CurrentInputName == "Touch")
            {
                //Update anchors of touch weapon
                OVRInput.Update();
                if (tag == "LTouch")
                {
                    transform.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
                    transform.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
                }
                else if (tag == "RTouch")
                {
                    transform.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
                    transform.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
                }
            }
        }
コード例 #27
0
    void Awake()
    {
        foveInterface = SceneLoader.instance.foveInterface.GetComponentInChildren <FoveInterface>().gameObject;

        float forwardAmount = 0.55f;

        transform.position = FoveInterface.GetHMDRotation() * Vector3.forward * forwardAmount;
        transform.position = new Vector3(transform.position.x + foveInterface.transform.position.x,
                                         foveInterface.transform.position.y,
                                         transform.position.z + foveInterface.transform.position.z);
        transform.LookAt(foveInterface.transform.position);

        // Light configuration
        globalDirectionalLight.transform.position = transform.position;
        globalDirectionalLight.transform.rotation = transform.rotation;
        globalDirectionalLight.transform.Rotate(new Vector3(30, 30, 0));
    }
コード例 #28
0
    void Start()
    {
        f = GetComponent <FoveInterface>();
        calibrationSphere = GameObject.Find("Calibration Sphere");
        calibrationSphere.SetActive(false);
        leftEyeSphere  = GameObject.Find("Left Gaze Sphere");
        rightEyeSphere = GameObject.Find("Right Gaze Sphere");

        /*text1 = GameObject.Find("Text 1").GetComponent<Text>();
         * text2 = GameObject.Find("Text 2").GetComponent<Text>();
         * text3 = GameObject.Find("Text 3").GetComponent<Text>();
         * GameObject.Find("Text 1").SetActive(false);
         * GameObject.Find("Text 2").SetActive(false);
         * GameObject.Find("Text 3").SetActive(false);
         * indicator = GameObject.Find("Indicator");*/
        recordingLight = GameObject.Find("Recording Light");
    }
コード例 #29
0
    // LateUpdate ensures that the object doesn't lag behind the user's head motion
    void FixedUpdate()
    {
        //set value
        rays        = fove.GetGazeRays_Immediate();
        myEyeStruct = FoveInterface.CheckEyesClosed();
        //raycast
        Debug.Log(myEyeStruct.ToString());
        Physics.Raycast(rays.left, out hit, Mathf.Infinity);
        if (fove.Gazecast(hit.collider))
        {
            transform.position = hit.point;

            if (hit.point != Vector3.zero) //&& (myEyeStruct == EFVR_Eye.Right || myEyeStruct == EFVR_Eye.Both))
            {
                transform.position = hit.point;
                //send a message to a destination gameobject

                if (prev == null)
                {
                    //set the prev to the current hit collider

                    prev = hit.collider;
                    Debug.Log("hit collider set collider to my object " + prev.GetType());
                    if (prev.GetComponent <timerScript>() != null)
                    {
                        prev.SendMessage("StartTimer");
                    }
                }
                else if (prev.name != hit.collider.name)
                {
                    if (prev.GetComponent <timerScript>() != null)
                    {
                        prev.SendMessage("StopTimer");
                    }

                    if (hit.collider.GetComponent <timerScript>() != null)
                    {
                        hit.collider.SendMessage("StartTimer");
                    }

                    prev = hit.collider;
                }
            }
        }
    }
コード例 #30
0
    // Latepdate ensures that the object doesn't lag behind the user's head motion
    void Update()
    {
        FoveInterface.EyeRays rays = FoveInterface.GetEyeRays();

        // TODO: calculate the convergence point in FoveInterface

        // Just hack in to use the left eye for now...
        RaycastHit hit;

        Physics.Raycast(rays.left, out hit, Mathf.Infinity);
        if (hit.point != Vector3.zero) // Vector3 is non-nullable; comparing to null is always false
        {
            transform.position = hit.point;
        }
        else
        {
            transform.position = rays.left.GetPoint(3.0f);
        }
    }