示例#1
0
        void Start()
        {
            customMessages = SpectatorView.SV_CustomMessages.Instance;

            if (customMessages != null)
            {
                RegisterCustomMessages();
            }
        }
示例#2
0
        void Update()
        {
            if (!registeredSharingStageCallbacks && SharingStage.Instance != null &&
                HolographicCameraManager.Instance != null && SharingStage.Instance.SessionUsersTracker != null)
            {
                registeredSharingStageCallbacks = true;

                SharingStage.Instance.SessionUsersTracker.UserJoined += SessionUsersTracker_UserJoined;
                SharingStage.Instance.SessionUsersTracker.UserLeft   += SessionUsersTracker_UserLeft;
            }

            if (customMessages == null)
            {
                customMessages = SpectatorView.SV_CustomMessages.Instance;
                if (customMessages != null)
                {
                    RegisterCustomMessages();
                }
            }

            if (customMessages == null)
            {
                return;
            }

#if !UNITY_EDITOR
            SendSpatialMappingData();

            Vector3    pos;
            Quaternion rot;

            try
            {
                if (GetHeadTransform(WorldManager.GetNativeISpatialCoordinateSystemPtr(),
                                     -1 * (int)colorFrameDurationNS,
                                     out rot.x, out rot.y, out rot.z, out rot.w,
                                     out pos.x, out pos.y, out pos.z))
                {
                    // Transform the head position and rotation from world space into local space
                    Vector3    HeadPos = this.transform.InverseTransformPoint(pos);
                    Quaternion HeadRot = Quaternion.Inverse(this.transform.rotation) * rot;
                    customMessages.SendHeadTransform(HeadPos, HeadRot);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
#endif
        }
        void Start()
        {
            customMessages = SpectatorView.SV_CustomMessages.Instance;
            if (customMessages != null)
            {
                RegisterCustomMessages();
            }

            lastPosition = transform.localPosition;
            lastRotation = transform.localRotation;
            lastScale    = transform.localScale;

#if UNITY_EDITOR
            HideObjects();
#endif
        }
示例#4
0
        void Update()
        {
            if (!registeredSharingStageCallbacks && SharingStage.Instance != null &&
                HolographicCameraManager.Instance != null && SharingStage.Instance.SessionUsersTracker != null)
            {
                registeredSharingStageCallbacks = true;

                SharingStage.Instance.SessionUsersTracker.UserJoined += SessionUsersTracker_UserJoined;
                SharingStage.Instance.SessionUsersTracker.UserLeft   += SessionUsersTracker_UserLeft;
            }

            if (customMessages == null)
            {
                customMessages = SpectatorView.SV_CustomMessages.Instance;
                if (customMessages != null)
                {
                    RegisterCustomMessages();
                }
            }

            if (customMessages == null)
            {
                return;
            }

#if !UNITY_EDITOR
            SendSpatialMappingData();

            Vector3    pos;
            Quaternion rot;

            long timeSinceLastColorFrameNS = (long)((Time.time - colorFrameReceivedTimeS) * 1000000000);

            // If the elapsed time is greater than a color frame duration, decrease the offset time by that number of frames.
            if (timeSinceLastColorFrameNS >= colorFrameDurationNS && colorFrameDurationNS != 0)
            {
                int numOffsets = (int)(timeSinceLastColorFrameNS / colorFrameDurationNS);

                timeSinceLastColorFrameNS -= (numOffsets * colorFrameDurationNS);
                if (timeSinceLastColorFrameNS < 0)
                {
                    timeSinceLastColorFrameNS = 0;
                }
            }

            try
            {
                if (GetHeadTransform(WorldManager.GetNativeISpatialCoordinateSystemPtr(),
                                     (int)((-1 * timeSinceLastColorFrameNS) + prevTimeOffsetNS),
                                     out rot.x, out rot.y, out rot.z, out rot.w,
                                     out pos.x, out pos.y, out pos.z))
                {
                    // Transform the head position and rotation from world space into local space
                    Vector3    HeadPos = this.transform.InverseTransformPoint(pos);
                    Quaternion HeadRot = Quaternion.Inverse(this.transform.rotation) * rot;
                    customMessages.SendHeadTransform(HeadPos, HeadRot);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
#else
            timeSinceLastNetworkTimeSnapshot += Time.deltaTime;
            if (timeSinceLastNetworkTimeSnapshot >= networkTimeSnapshotInterval)
            {
                timeSinceLastNetworkTimeSnapshot = 0;

                RequestCurrentNetworkLatency();
                customMessages.SendTPPCColorDuration(GetColorDuration());
            }
#endif
        }