private IEnumerator CheckAllPins(IAlignmentManager alignMgr)
        {
            for (int i = 0; i < pinData.Length; ++i)
            {
                alignMgr.AddAlignmentAnchor(pinData[i].name, pinData[i].virtualPose, pinData[i].lockedPose);
            }
            alignMgr.SendAlignmentAnchors();

            for (int i = 0; i < pinData.Length; ++i)
            {
                int nextIdx = (i + 1) % pinData.Length;
                CheckAlignment(alignMgr, pinData[i].virtualPose.position, pinData[i].lockedPose.position);
                CheckAlignment(alignMgr,
                               (pinData[i].virtualPose.position + pinData[nextIdx].virtualPose.position) * 0.5f,
                               (pinData[i].lockedPose.position + pinData[nextIdx].virtualPose.position) * 0.5f);
            }

            for (int i = 0; i < pinData.Length - 3; ++i)
            {
                int j = (i + 1) % pinData.Length;
                int k = (j + 1) % pinData.Length;
                CheckAlignment(alignMgr,
                               (pinData[i].virtualPose.position + pinData[j].virtualPose.position + pinData[k].virtualPose.position) / 3.0f,
                               (pinData[i].lockedPose.position + pinData[j].lockedPose.position + pinData[k].virtualPose.position) / 3.0f);
            }

            alignMgr.ClearAlignmentAnchors();
            alignMgr.SendAlignmentAnchors();

            yield return(null);
        }
        /// <summary>
        /// Adjust to refit operations.
        /// </summary>
        /// <param name="mainId">The new combined fragment.</param>
        /// <param name="absorbedIds">Id's of other fragments being merged into mainId.</param>
        /// <remarks>
        /// This callback occurs *after* the refit operation. As part of the refit,
        /// positions of the managed SpacePinOrientables may have changed, and therefore
        /// their implied orientations must be re-calculated.
        /// Note that there is an apparent race condition, as there is no order guarantee on
        /// the order of refit notifications, and the AlignmentManager also relies on the
        /// refit notification to adjust after refit operations.
        /// However, both the Orienter and the AlignmentManager rely only on the positions
        /// having been set, which was accomplished during the refit and before the refit
        /// notification. So it really doesn't matter whether the Orienter.OnRefit or the
        /// AlignmentManager.OnRefit is called first.
        /// </remarks>
        private void OnRefit(FragmentId mainId, FragmentId[] absorbedIds)
        {
            IAlignmentManager alignMgr = WorldLockingManager.GetInstance().AlignmentManager;

            Reorient(mainId, alignMgr);
            alignMgr.SendAlignmentAnchors();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Notify the manager that all necessary updates have been submitted and
        /// are ready for processing.
        /// </summary>
        /// <param name="mgr"></param>
        protected void SendAlignmentData(IAlignmentManager mgr)
        {
            mgr.SendAlignmentAnchors();

            CheckAttachment();

            transform.SetLocalPose(RestorePoseLocal);
        }
        /// <summary>
        /// Notify the manager that all necessary updates have been submitted and
        /// are ready for processing.
        /// </summary>
        /// <param name="mgr"></param>
        protected void SendAlignmentData(IAlignmentManager mgr)
        {
            mgr.SendAlignmentAnchors();

            CheckAttachment();

            transform.SetGlobalPose(InitialPose);
        }
        private IEnumerator CheckSinglePin(IAlignmentManager alignMgr, int pinIdx)
        {
            alignMgr.ClearAlignmentAnchors();
            var id0 = alignMgr.AddAlignmentAnchor(pinData[pinIdx].name, pinData[pinIdx].virtualPose, pinData[pinIdx].lockedPose);

            alignMgr.SendAlignmentAnchors();

            yield return(null);

            CheckAlignment(alignMgr, pinData[pinIdx].virtualPose.position, pinData[pinIdx].lockedPose.position);

            CheckAlignment(alignMgr, pinData[pinIdx].virtualPose.position + new Vector3(1.0f, 0, 0), pinData[pinIdx].lockedPose.position + new Vector3(1.0f, 0, 0));

            alignMgr.ClearAlignmentAnchors();
            alignMgr.SendAlignmentAnchors();

            yield return(null);
        }
        private IEnumerator CheckDualPins(IAlignmentManager alignMgr, int pinIdx0, int pinIdx1)
        {
            alignMgr.AddAlignmentAnchor(pinData[pinIdx0].name, pinData[pinIdx0].virtualPose, pinData[pinIdx0].lockedPose);
            alignMgr.AddAlignmentAnchor(pinData[pinIdx1].name, pinData[pinIdx1].virtualPose, pinData[pinIdx1].lockedPose);
            alignMgr.SendAlignmentAnchors();

            yield return(null);

            CheckAlignment(alignMgr, pinData[pinIdx0].virtualPose.position, pinData[pinIdx0].lockedPose.position);

            CheckAlignment(alignMgr, pinData[pinIdx1].virtualPose.position, pinData[pinIdx1].lockedPose.position);

            CheckAlignment(alignMgr,
                           (pinData[pinIdx0].virtualPose.position + pinData[pinIdx1].virtualPose.position) * 0.5f,
                           (pinData[pinIdx0].lockedPose.position + pinData[pinIdx1].lockedPose.position) * 0.5f);

            alignMgr.ClearAlignmentAnchors();
            alignMgr.SendAlignmentAnchors();

            yield return(null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adjust to refit operations.
        /// </summary>
        /// <param name="mainId">The new combined fragment.</param>
        /// <param name="absorbedIds">Id's of other fragments being merged into mainId.</param>
        /// <remarks>
        /// This callback occurs *after* the refit operation. As part of the refit,
        /// positions of the managed SpacePinOrientables may have changed, and therefore
        /// their implied orientations must be re-calculated.
        /// Note that there is an apparent race condition, as there is no order guarantee on
        /// the order of refit notifications, and the AlignmentManager also relies on the
        /// refit notification to adjust after refit operations.
        /// However, both the Orienter and the AlignmentManager rely only on the positions
        /// having been set, which was accomplished during the refit and before the refit
        /// notification. So it really doesn't matter whether the Orienter.OnRefit or the
        /// AlignmentManager.OnRefit is called first.
        /// </remarks>
        private void OnRefit(FragmentId mainId, FragmentId[] absorbedIds)
        {
            /// Use the last alignment manager used. If none, use the wlt manager's current alignment manager.
            IAlignmentManager alignMgr = cachedAlignmentManager;

            if (alignMgr == null)
            {
                alignMgr = WorldLockingManager.GetInstance().AlignmentManager;
            }
            Reorient(mainId, alignMgr);
            alignMgr.SendAlignmentAnchors();
        }
Exemplo n.º 8
0
        public IEnumerator SaveLoadTestSaveThenLoad()
        {
            GameObject          rig    = loadHelper.LoadBasicSceneRig();
            WorldLockingManager wltMgr = WorldLockingManager.GetInstance();
            var settings = wltMgr.Settings;

            settings.AutoLoad = false;
            settings.AutoSave = false;
            wltMgr.Settings   = settings;

            IAlignmentManager alignMgr = wltMgr.AlignmentManager;

            alignMgr.ClearAlignmentAnchors();
            alignMgr.SendAlignmentAnchors();

            // Verify alignment is identity
            VerifyAlignmentIdentity(alignMgr, pinData);

            // Add pins
            for (int i = 0; i < pinData.Length; ++i)
            {
                pinData[i].anchorId = alignMgr.AddAlignmentAnchor(pinData[i].name, pinData[i].virtualPose, pinData[i].lockedPose);
            }
            alignMgr.SendAlignmentAnchors();

            yield return(null);

            // Verify alignment at pins
            VerifyAlignment(alignMgr, pinData);

            // Save
            wltMgr.Save();

            yield return(null);

            // Verify alignment at pins, saving should be non-destructive.
            VerifyAlignment(alignMgr, pinData);

            // Clear
            alignMgr.ClearAlignmentAnchors();
            alignMgr.SendAlignmentAnchors();

            yield return(null);


            // Verify alignment is identity
            VerifyAlignmentIdentity(alignMgr, pinData);

            // Load
            wltMgr.Load();

            yield return(null);

            for (int i = 0; i < pinData.Length; ++i)
            {
                pinData[i].anchorId = alignMgr.RestoreAlignmentAnchor(pinData[i].name, pinData[i].virtualPose);
            }
            alignMgr.SendAlignmentAnchors();

            yield return(null);

            // Verify alignment at pins, load should have restored them.
            VerifyAlignment(alignMgr, pinData);

            GameObject.Destroy(rig);

            yield return(null);
        }