GetEyePose() public static méthode

public static GetEyePose ( Eye eyeId ) : Posef
eyeId Eye
Résultat Posef
Exemple #1
0
    /// <summary>
    /// Gets the head pose at the current time or predicted at the given time.
    /// </summary>
    public OVRPose GetHeadPose(double predictionTime)
    {
#if !UNITY_ANDROID || UNITY_EDITOR
        if (!OVRManager.instance.isVRPresent)
        {
            return(new OVRPose
            {
                position = Vector3.zero,
                orientation = Quaternion.identity,
            });
        }

        return(OVRPlugin.GetEyePose(OVRPlugin.Eye.None).ToOVRPose());
#else
        float px = 0.0f, py = 0.0f, pz = 0.0f, ow = 0.0f, ox = 0.0f, oy = 0.0f, oz = 0.0f;

        double atTime = Time.time + predictionTime;
        OVR_GetCameraPositionOrientation(ref px, ref py, ref pz,
                                         ref ox, ref oy, ref oz, ref ow, atTime);

        return(new OVRPose
        {
            position = new Vector3(px, py, -pz),
            orientation = new Quaternion(-ox, -oy, oz, ow),
        });
#endif
    }
Exemple #2
0
    /// <summary>
    /// Gets the pose of the given eye, predicted for the time when the current frame will scan out.
    /// </summary>
    /// <description>NOTE: This is safe to call in an Update function, but not in LateUpdate or subsequent callbacks.</description>
    public OVRPose GetEyePose(OVREye eye)
    {
#if !UNITY_ANDROID || UNITY_EDITOR
        if (!OVRManager.instance.isVRPresent)
        {
            return(new OVRPose
            {
                position = Vector3.zero,
                orientation = Quaternion.identity,
            });
        }

        bool updateEyePose = !(OVRManager.instance.timeWarp && OVRManager.instance.freezeTimeWarp);
        if (updateEyePose)
        {
            eyePoses[(int)eye] = OVRPlugin.GetEyePose((OVRPlugin.Eye)eye).ToOVRPose();
        }

        return(eyePoses[(int)eye]);
#else
        if (eye == OVREye.Left)
        {
            OVR_GetSensorState(
                OVRManager.instance.monoscopic,
                ref w,
                ref x,
                ref y,
                ref z,
                ref fov,
                ref timeWarpViewNumber);
        }

        Quaternion rot = new Quaternion(-x, -y, z, w);

        float eyeOffsetX = 0.5f * OVRManager.profile.ipd;
        eyeOffsetX = (eye == OVREye.Left) ? -eyeOffsetX : eyeOffsetX;

        float   neckToEyeHeight = OVRManager.profile.eyeHeight - OVRManager.profile.neckHeight;
        Vector3 headNeckModel   = new Vector3(0.0f, neckToEyeHeight, OVRManager.profile.eyeDepth);
        Vector3 pos             = rot * (new Vector3(eyeOffsetX, 0.0f, 0.0f) + headNeckModel);

        // Subtract the HNM pivot to avoid translating the camera when level
        pos -= headNeckModel;

        return(new OVRPose
        {
            position = pos,
            orientation = rot,
        });
#endif
    }