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> /// Communicate the data from this point to the alignment manager. /// </summary> /// <param name="mgr"></param> protected void PushAlignmentData(IAlignmentManager mgr) { if (PinActive) { mgr.RemoveAlignmentAnchor(AnchorId); } AnchorId = mgr.AddAlignmentAnchor(AnchorName, ModelingPoseGlobal, lockedPose); }
/// <summary> /// Communicate the data from this point to the alignment manager. /// </summary> /// <param name="mgr"></param> protected void PushAlignmentData(IAlignmentManager mgr) { DebugLogExtra($"F{Time.frameCount} Push: {name}: MPG={ModelingPoseGlobal.ToString("F3")} GfP={GlobalFromParent.ToString("F3")} R={restorePoseLocal.ToString("F3")} MPP={WorldLockingManager.GetInstance().PinnedFromFrozen.Multiply(ModelingPoseGlobal)}"); if (PinActive) { mgr.RemoveAlignmentAnchor(AnchorId); } AnchorId = mgr.AddAlignmentAnchor(AnchorName, ModelingPoseGlobal, lockedPose); }
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); }
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); }
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); }