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]
                          );
            }
        }
        public static void GetWebcamViewMatrix(ref Matrix4x4 viewMatrix)
        {
            IntPtr viewMatrixPtr = IntPtr.Zero;

            CompositorInterop.getWebcamViewMatrix(ref viewMatrixPtr);

            MarshalAndCopy(viewMatrixPtr, ref viewMatrix);
        }
        public static void GetProjectionMatrix(int eye, ref Matrix4x4 projectionMatrix)
        {
            IntPtr projectionMatrixPtr = IntPtr.Zero;

            CompositorInterop.getProjectionMatrix(eye, ref projectionMatrixPtr);

            MarshalAndCopy(projectionMatrixPtr, ref projectionMatrix);
        }
Beispiel #4
0
        /// <summary>
        /// Initialize the Compositor
        /// </summary>
        private void Awake()
        {
            CompositorInterop.InitCompositor(_enableAsynchronousRendering);
            _warpDisabledForUI = _enable3DWarp || _enable2DWarp;

            if (!_contentCamera)
            {
                Debug.LogError("Unable to find ContentCamera; please reimport MetaCameraRig prefab.");
            }
        }