Beispiel #1
0
        /// <summary>
        /// Updates the target game object transform.
        /// SLAM Reports its transfrom aligned with gravity on (0,-9.8,0)
        /// At the origin with the initial rotation at Identity
        /// </summary>
        public void UpdateTargetGOTransform(bool isScaleEstimated, bool getPoseFromCompositor)
        {
            if (getPoseFromCompositor)
            {
                // We need to call begin frame from SlamApi when we show the SLAM UI. This is to fix jitter
                // in the SLAM UI when we call begin frame from MetaCompositor since the UI works of an old pose
                // It is important to note that this adds a large latency since we call begin frame way before than it should be
                if (_compositor == null)
                {
                    _compositor = UnityEngine.GameObject.FindObjectOfType <MetaCompositor>();
                }
                if (_compositor != null && (!(_compositor.Enable3DWarp || _compositor.Enable2DWarp) || MetaUIContent.IsUIPresent))
                {
                    CompositorInterop.BeginFrame();
                }
                // Update pose for behaviors with rendering pose from compositor
                CompositorInterop.GetRenderPoseToWorld(_trans, _quat);
            }

            if (TargetGO != null)
            {
                TargetGO.transform.localRotation = TypeUtilities.QuaternionFromDouble(_quat);

                TargetGO.transform.localPosition
                    = new Vector3(
                          (float)_trans[0],
                          (float)_trans[1],
                          (float)_trans[2]
                          );
            }
        }
 /// <summary>
 /// Check that we have a reference of the Compositor script
 /// </summary>
 private void CheckComponent()
 {
     if (_component != null)
     {
         return;
     }
     _component = target as Plugin.MetaCompositor;
 }