public bool Apply() { context.diagnostics.TakeSnapshot($"{nameof(RecordViveTrackersStep)}.{nameof(Apply)}.Before"); var autoSetup = new TrackerAutoSetup(context); lastError = autoSetup.AlignAllNow(); context.diagnostics.TakeSnapshot($"{nameof(RecordViveTrackersStep)}.{nameof(Apply)}.After"); return(true); }
public bool Apply() { context.diagnostics.TakeSnapshot($"{nameof(ExperimentalRecordViveTrackersStep)}.{nameof(Apply)}.Before"); var autoSetup = new TrackerAutoSetup(context); var hashSet = new HashSet <string>(); foreach (var mc in context.trackers.viveTrackers) { if (mc.mappedControllerName != null) { continue; } if (!mc.SyncMotionControl()) { continue; } autoSetup.AttachToClosestNode(mc); if (!hashSet.Add(mc.mappedControllerName)) { lastError = $"The same controller was bound more than once: {mc.mappedControllerName}"; context.diagnostics.Log(lastError); mc.mappedControllerName = null; foreach (var mc2 in context.trackers.viveTrackers) { if (mc2.mappedControllerName == null || mc2.mappedControllerName.EndsWith("FootControl")) { continue; } mc2.ResetToDefault(); } return(false); } } context.Refresh(); context.diagnostics.TakeSnapshot($"{nameof(ExperimentalRecordViveTrackersStep)}.{nameof(Apply)}.After"); return(true); }
public bool Apply() { context.diagnostics.TakeSnapshot($"{nameof(ExperimentalRecordViveTrackersFeetStep)}.{nameof(Apply)}.Before"); var feet = context.containingAtom.freeControllers.Where(fc => fc.name.EndsWith("FootControl")).ToList(); var eyes = context.head.position.y; var floor = context.worldScale.worldScaleMethodJSON.val == WorldScaleModule.PlayerHeightMethod ? eyes - (context.worldScale.playerHeightJSON.val * SuperController.singleton.worldScale) : 0f; var maxY = floor + (eyes - floor) * 0.25f; var trackersNearFloor = context.trackers.viveTrackers .Where(t => t.SyncMotionControl()) .Where(t => t.currentMotionControl.position.y < maxY) .ToList(); if (trackersNearFloor.Count != 2) { lastError = $"Expected to find 2 trackers near floor level, but {trackersNearFloor.Count} were found.\n\nFoot trackers were not assigned.\n\nTry again, or skip this step."; return(false); } var autoSetup = new TrackerAutoSetup(context); foreach (var mc in trackersNearFloor) { autoSetup.AttachToClosestNode(mc, feet); } if (trackersNearFloor[0].mappedControllerName == trackersNearFloor[1].mappedControllerName) { lastError = $"Embody: Both vive trackers were mapped to the same foot.\n\nMake sure your feet are each placed close to the model's feet.\n\nTry again, or skip this step."; trackersNearFloor[0].mappedControllerName = null; trackersNearFloor[1].mappedControllerName = null; return(false); } context.Refresh(); context.diagnostics.TakeSnapshot($"{nameof(ExperimentalRecordViveTrackersFeetStep)}.{nameof(Apply)}.After"); return(true); }
public TrackersSettingsScreen(EmbodyContext context, ITrackersModule trackers) : base(context) { _trackers = trackers; _trackerAutoSetup = new TrackerAutoSetup(context); }