public virtual void Hide() { _root.RemoveAll(); }
private void ShowMotionControl(MotionControllerWithCustomPossessPoint motionControl) { if (_section == null) { _section = CreateSection(); } _section.RemoveAll(); if (_currentMotionControl != null) { _currentMotionControl.highlighted = false; } if (motionControl == null) { return; } _currentMotionControl = motionControl; _currentMotionControl.highlighted = true; if (MotionControlNames.IsViveTracker(motionControl.name)) { _section.CreateButton("Map to Closest Control", true).button.onClick.AddListener(() => { _trackerAutoSetup.AttachToClosestNode(motionControl); ShowMotionControl(motionControl); context.Refresh(); }); _section.CreateButton("Align to Mapped Control", true).button.onClick.AddListener(() => { var controller = context.containingAtom.freeControllers.FirstOrDefault(fc => fc.name == motionControl.mappedControllerName); if (controller != null) { _trackerAutoSetup.AlignToNode(motionControl, controller); ShowMotionControl(motionControl); context.Refresh(); } }); } _section.CreateToggle(new JSONStorableBool( $"{motionControl.name} Enabled", motionControl.enabled, val => { motionControl.enabled = val; if (MotionControlNames.IsHands(motionControl.name)) { _handsToggleJSON.valNoCallback = _trackers.leftHandMotionControl.enabled || _trackers.rightHandMotionControl.enabled; } context.Refresh(); } )); if (!MotionControlNames.IsHeadOrHands(motionControl.name)) { _section.CreateFilterablePopup(new JSONStorableStringChooser( "", new[] { _none }.Concat(_trackers.controllers.Select(mc => mc.controller.name)).ToList(), motionControl.mappedControllerName, "Map to control*", val => { motionControl.mappedControllerName = val == _none ? null : val; context.Refresh(); }), false); _section.CreateToggle(new JSONStorableBool( $"{motionControl.name} Controls Position*", motionControl.controlPosition, val => motionControl.controlPosition = val ), false); _section.CreateToggle(new JSONStorableBool( $"{motionControl.name} Controls Rotation*", motionControl.controlRotation, val => motionControl.controlRotation = val ), false); } if (MotionControlNames.IsHands(motionControl.name)) { _section.CreateToggle(new JSONStorableBool( $"Fingers Tracking*", motionControl.fingersTracking, val => motionControl.fingersTracking = val ), false); _section.CreateToggle(new JSONStorableBool( $"Position Tracking*", motionControl.controlPosition, val => motionControl.controlPosition = motionControl.controlRotation = val ), false); _section.CreateToggle(new JSONStorableBool( $"Use Leap Motion Position*", motionControl.useLeapPositioning, val => motionControl.useLeapPositioning = val ), false); } _section.CreateSlider(new JSONStorableFloat( $"Offset X*", motionControl.offsetControllerCustom.x, val => motionControl.offsetControllerCustom = new Vector3(val, motionControl.offsetControllerCustom.y, motionControl.offsetControllerCustom.z), -0.5f, 0.5f, false), false); _section.CreateSlider(new JSONStorableFloat( $"Offset Y*", motionControl.offsetControllerCustom.y, val => motionControl.offsetControllerCustom = new Vector3(motionControl.offsetControllerCustom.x, val, motionControl.offsetControllerCustom.z), -0.5f, 0.5f, false), false); _section.CreateSlider(new JSONStorableFloat( $"Offset Z*", motionControl.offsetControllerCustom.z, val => motionControl.offsetControllerCustom = new Vector3(motionControl.offsetControllerCustom.x, motionControl.offsetControllerCustom.y, val), -0.5f, 0.5f, false), false); _section.CreateSlider(new JSONStorableFloat( $"Rotate Controller X*", motionControl.rotateControllerCustom.x, val => motionControl.rotateControllerCustom = new Vector3(val, motionControl.rotateControllerCustom.y, motionControl.rotateControllerCustom.z), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"Rotate Controller Y*", motionControl.rotateControllerCustom.y, val => motionControl.rotateControllerCustom = new Vector3(motionControl.rotateControllerCustom.x, val, motionControl.rotateControllerCustom.z), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"Rotate Controller Z*", motionControl.rotateControllerCustom.z, val => motionControl.rotateControllerCustom = new Vector3(motionControl.rotateControllerCustom.x, motionControl.rotateControllerCustom.y, val), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"Rotate Around Tracker X*", motionControl.rotateAroundTrackerCustom.x, val => motionControl.rotateAroundTrackerCustom = new Vector3(val, motionControl.rotateAroundTrackerCustom.y, motionControl.rotateAroundTrackerCustom.z), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"Rotate Around Tracker Y*", motionControl.rotateAroundTrackerCustom.y, val => motionControl.rotateAroundTrackerCustom = new Vector3(motionControl.rotateAroundTrackerCustom.x, val, motionControl.rotateAroundTrackerCustom.z), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"Rotate Around Tracker Z*", motionControl.rotateAroundTrackerCustom.z, val => motionControl.rotateAroundTrackerCustom = new Vector3(motionControl.rotateAroundTrackerCustom.x, motionControl.rotateAroundTrackerCustom.y, val), -180, 180, false), false); _section.CreateToggle(new JSONStorableBool( "Keep current physics hold strength*", motionControl.keepCurrentPhysicsHoldStrength, val => motionControl.keepCurrentPhysicsHoldStrength = val), false); if (MotionControlNames.IsHands(motionControl.name)) { _section.CreateButton("Sync to other hand").button.onClick.AddListener(() => { var otherHand = motionControl.name == MotionControlNames.LeftHand ? _trackers.rightHandMotionControl : _trackers.leftHandMotionControl; otherHand.offsetControllerCustom = new Vector3(-motionControl.offsetControllerCustom.x, motionControl.offsetControllerCustom.y, motionControl.offsetControllerCustom.z); otherHand.rotateControllerCustom = new Vector3(motionControl.rotateControllerCustom.x, -motionControl.rotateControllerCustom.y, -motionControl.rotateControllerCustom.z); otherHand.rotateAroundTrackerCustom = new Vector3(motionControl.rotateAroundTrackerCustom.x, -motionControl.rotateAroundTrackerCustom.y, -motionControl.rotateAroundTrackerCustom.z); }); } }
private void ShowMotionControl(MotionControllerWithCustomPossessPoint motionControl) { if (_section == null) { _section = CreateSection(); } _section.RemoveAll(); if (motionControl == null) { return; } _section.CreateToggle(new JSONStorableBool( $"{motionControl.name} Enabled", motionControl.enabled, val => { motionControl.enabled = val; context.Refresh(); } )); _section.CreateFilterablePopup(new JSONStorableStringChooser( "", new[] { _none }.Concat(_trackers.controllers.Select(mc => mc.controller.name)).ToList(), motionControl.mappedControllerName, "Map to control", val => { motionControl.mappedControllerName = val == _none ? null : val; context.Refresh(); }), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Offset X", motionControl.customOffset.x, val => motionControl.customOffset = new Vector3(val, motionControl.customOffset.y, motionControl.customOffset.z), -0.5f, 0.5f, false), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Offset Y", motionControl.customOffset.y, val => motionControl.customOffset = new Vector3(motionControl.customOffset.x, val, motionControl.customOffset.z), -0.5f, 0.5f, false), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Offset Z", motionControl.customOffset.z, val => motionControl.customOffset = new Vector3(motionControl.customOffset.x, motionControl.customOffset.y, val), -0.5f, 0.5f, false), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Offset rotate X", motionControl.customOffsetRotation.x, val => motionControl.customOffsetRotation = new Vector3(val, motionControl.customOffsetRotation.y, motionControl.customOffsetRotation.z), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Offset rotate Y", motionControl.customOffsetRotation.y, val => motionControl.customOffsetRotation = new Vector3(motionControl.customOffsetRotation.x, val, motionControl.customOffsetRotation.z), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Offset rotate Z", motionControl.customOffsetRotation.z, val => motionControl.customOffsetRotation = new Vector3(motionControl.customOffsetRotation.x, motionControl.customOffsetRotation.y, val), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Point rotate X", motionControl.possessPointRotation.x, val => motionControl.possessPointRotation = new Vector3(val, motionControl.possessPointRotation.y, motionControl.possessPointRotation.z), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Point rotate Y", motionControl.possessPointRotation.y, val => motionControl.possessPointRotation = new Vector3(motionControl.possessPointRotation.x, val, motionControl.possessPointRotation.z), -180, 180, false), false); _section.CreateSlider(new JSONStorableFloat( $"{motionControl.name} Point rotate Z", motionControl.possessPointRotation.z, val => motionControl.possessPointRotation = new Vector3(motionControl.possessPointRotation.x, motionControl.possessPointRotation.y, val), -180, 180, false), false); _section.CreateButton("Attach and align to closest node", true).button.onClick.AddListener(() => { AttachToClosestNode(motionControl); }); }