// Update is called once per frame
 void Update()
 {
     ManagerOrientText.text   = toFomattedString(FoveManager.GetHmdRotation().value);
     ManagerPosText.text      = toFomattedString(FoveManager.GetHmdPosition(false).value);
     ManagerGazeText.text     = toFomattedString(FoveManager.GetHmdCombinedGazeRay().value.direction);
     InterfaceOrientText.text = toFomattedString(fove.transform.rotation);
     InterfacePosText.text    = toFomattedString(fove.transform.position);
     InterfaceGazeText.text   = toFomattedString(fove.GetCombinedGazeRay().value.direction);
 }
Beispiel #2
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;
        }
    }