Exemplo n.º 1
0
    void UpdatePose()
    {
        if (m_fusion == null)
        {
            return;
        }

        // Try to get the remaining time in the frame from the compositor, otherwise
        // default back to 90 fps.  If the scene renders in reasonable time, the time
        // will be slightly larger than just the inverse of the framerate.  If the
        // value becomes negative, as can happen when the image processing falls
        // behind, we force it to zero.
        float frameTimeRemaining = 1 / 90.0f;
        var   vr = SteamVR.instance;

        if (vr != null)
        {
            frameTimeRemaining = vr.compositor.GetFrameTimeRemaining();
            frameTimeRemaining = Math.Max(frameTimeRemaining, 0.0f);
        }

        lock (m_fusion_lock)
        {
            if (m_fusion != null)
            {
                Quaternion newOrientation = m_fusion.getOrientation(frameTimeRemaining);
                this.transform.localRotation = newOrientation;
            }
        }
    }