Exemple #1
0
        private void UpdateBridgeInputFrame()
        {
            if (_requestedPoseFrameIndex == Time.frameCount)
            {
                _inputFrame.ObtainControl();
                _inputFrame.pose = _requestedPose;
                _requestedPose   = SDKPose.empty;
            }
            else
            {
                _inputFrame.ReleaseControl();
            }

            if (_cameraInstance != null)
            {
                // Near and far is always driven by game
                _inputFrame.pose.nearClipPlane = _cameraInstance.nearClipPlane;
                _inputFrame.pose.farClipPlane  = _cameraInstance.farClipPlane;
            }

            SDKBridge.UpdateInputFrame(ref _inputFrame);
        }
Exemple #2
0
        /// <summary>
        /// Control camera pose by calling this method each frame. The pose is released when you stop calling it.
        /// </summary>
        /// <remarks>
        /// <para>By default the pose is set in worldspace, turn on local space for using the stage relative space instead.</para>
        /// </remarks>
        /// <example>
        /// <code>
        /// public class ControlCameraPose : MonoBehaviour
        /// {
        ///     [SerializeField] LIV.SDK.Unity.LIV _liv;
        ///     [SerializeField] float _fov = 60f;
        ///
        ///     private void Update()
        ///     {
        ///         if(_liv.isActive)
        ///         {
        ///             _liv.render.SetPose(transform.position, transform.rotation, _fov);
        ///         }
        ///     }
        /// }
        /// </code>
        /// </example>
        public bool SetPose(Vector3 position, Quaternion rotation, float verticalFieldOfView = 60f, bool useLocalSpace = false)
        {
            if (_inputFrame.frameid == 0)
            {
                return(false);
            }
            SDKPose inputPose = _inputFrame.pose;
            float   aspect    = 1f;

            if (_resolution.height > 0)
            {
                aspect = (float)_resolution.width / (float)_resolution.height;
            }

            if (!useLocalSpace)
            {
                Matrix4x4 worldToLocal   = Matrix4x4.identity;
                Transform localTransform = stageTransform == null ? stage : stageTransform;
                if (localTransform != null)
                {
                    worldToLocal = localTransform.worldToLocalMatrix;
                }
                position = worldToLocal.MultiplyPoint(position);
                rotation = SDKUtils.RotateQuaternionByMatrix(worldToLocal, rotation);
            }

            _requestedPose = new SDKPose()
            {
                localPosition       = position,
                localRotation       = rotation,
                verticalFieldOfView = verticalFieldOfView,
                projectionMatrix    = Matrix4x4.Perspective(verticalFieldOfView, aspect, inputPose.nearClipPlane, inputPose.farClipPlane)
            };

            _requestedPoseFrameIndex = Time.frameCount;
            return(_inputFrame.priority.pose <= (sbyte)PRIORITY.GAME);
        }
Exemple #3
0
 public static void GetCameraPositionAndRotation(SDKPose pose, Matrix4x4 originLocalToWorldMatrix, out Vector3 position, out Quaternion rotation)
 {
     position = originLocalToWorldMatrix.MultiplyPoint(pose.localPosition);
     rotation = RotateQuaternionByMatrix(originLocalToWorldMatrix, pose.localRotation);
 }
        public static ulong SetFlag(ulong flags, ulong flag, bool enabled) => default;                              // 0x000000018113E150-0x000000018113E170

        public static void GetCameraPositionAndRotation(SDKPose pose, Matrix4x4 originLocalToWorldMatrix, out Vector3 position, out Quaternion rotation)
        {
            position = default;
            rotation = default;
        }         // 0x000000018113D450-0x000000018113D600