Ejemplo n.º 1
0
        /// Returns the interpolated scene pose based on the app primary and secondary ODS tranforms.
        /// Progress the interpolation parameter which is expected to be in the range [0, 1].
        /// Interpolation is done via TrTransform, which gives correct rotation and scale interpoalation.
        public static TrTransform GetScenePose(float progress)
        {
            // Interpolate in worldspace
            TrTransform cameraStart = App.Instance.OdsScenePrimary.inverse;
            TrTransform cameraEnd   = App.Instance.OdsSceneSecondary.inverse;
            TrTransform cameraCur   = TrTransform.Lerp(cameraStart * App.Instance.OdsHeadPrimary,
                                                       cameraEnd * App.Instance.OdsHeadSecondary,
                                                       progress);

            return(cameraCur.inverse);
        }
Ejemplo n.º 2
0
        public void Deserialize()
        {
            m_Scene.Read(m_xformName, m_UsdCamera);

            var basisMat = Matrix4x4.identity;

            if (m_UnitsInMeters)
            {
                basisMat[0, 0] *= App.METERS_TO_UNITS;
                basisMat[1, 1] *= App.METERS_TO_UNITS;
                basisMat[2, 2] *= -1 * App.METERS_TO_UNITS;
            }
            m_UsdCamera.transform = ExportUtils.ChangeBasis(m_UsdCamera.transform, basisMat, basisMat.inverse);

            TrTransform xf_WS  = UsdXformToWorldSpaceXform(m_UsdCamera);
            TrTransform old_WS = TrTransform.FromTransform(transform);
            TrTransform new_WS = TrTransform.Lerp(old_WS, xf_WS, 1 - m_Smoothing);

            new_WS.scale = m_UsdCameraInfo.eyeScale != 0 ? m_UsdCameraInfo.eyeScale : 1;
            new_WS.ToTransform(transform);

            // Pre-M23.3, .usd files won't have fov defined, so this value will be negative.
            if (m_UsdCamera.fov > 0)
            {
                // A bit brute force, but we're running through all cameras in the scene to make
                // sure the preview shows the modified fov.
                for (int i = 0; i < m_PlaybackCameras.Length; ++i)
                {
                    if (m_PlaybackCameras[i].gameObject.activeInHierarchy &&
                        m_PlaybackCameras[i].isActiveAndEnabled)
                    {
                        m_PlaybackCameras[i].fieldOfView = m_UsdCamera.fov;
                    }
                }
            }
        }