コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (FoveManager.GetGazedObject() == gazedReference)
     {
         mat.color = Color.yellow;
     }
     else
     {
         mat.color = Color.gray;
     }
 }
コード例 #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        var obj = FoveManager.GetGazedObject().value;

        if (obj == null)
        {
            return;
        }

        var rbody = obj.GetComponent <Rigidbody>();

        if (rbody == null)
        {
            return;
        }

        var gazeRay = fove.GetCombinedGazeRay().value;

        rbody.AddForce(25 * gazeRay.direction);
    }
コード例 #3
0
    private void UpdateFoveInterfaceMatrices(bool immediate)
    {
        var t = fove.transform;

        var markKeyDown       = Input.GetKey(markFrameKey);
        var gazedObjectResult = FoveManager.GetGazedObject();
        var gazedObjectName   = new Result <string>(gazedObjectResult.value? gazedObjectResult.value.name : "", gazedObjectResult.error);

        if (immediate)
        {
            // In the case of 120 FPS recording rate, we re-fetch the HMD latest pose
            // and locally recalculate the fove interface local transform
            var isStanding          = fove.poseType == FoveInterface.PlayerPose.Standing;
            var hmdAdjustedPosition = FoveManager.GetHmdPosition(isStanding);
            var localPos            = fove.fetchPosition? hmdAdjustedPosition : t.position;
            var localRot            = fove.fetchOrientation? FoveManager.GetHmdRotation() : t.rotation;

            var parentTransfo = t.parent != null ? t.parent.localToWorldMatrix : Matrix4x4.identity;
            var localTransfo  = Matrix4x4.TRS(localPos, localRot, t.localScale);

            lock (unityThreadData)
            {
                unityThreadData.HMDToWorld     = parentTransfo * localTransfo;
                unityThreadData.HMDToLocal     = localTransfo;
                unityThreadData.markKeyDown    = markKeyDown;
                unityThreadData.gazedObject    = gazedObjectName;
                unityThreadData.HMDPosition    = localPos;
                unityThreadData.HMDOrientation = localRot;
            }
        }
        else
        {
            // no need to lock the object, we are in synchronize mode (access from the same thread)
            unityThreadData.HMDToWorld     = t.localToWorldMatrix;
            unityThreadData.HMDToLocal     = Matrix4x4.TRS(t.localPosition, t.localRotation, t.localScale);
            unityThreadData.markKeyDown    = markKeyDown;
            unityThreadData.gazedObject    = gazedObjectName;
            unityThreadData.HMDPosition    = t.localPosition;
            unityThreadData.HMDOrientation = t.localRotation;
        }
    }