// Use this for initialization void Start() { FindTrackedObjects(); //TODO: Make this happen in Update() at regular intervals, and clean up existing devices. MessageDisplay.DisplayMessageAll("Which object is holding the ZED?"); #if ZED_STEAM_VR //Subscribe to controllers being connected/disconnected so we can update the available devices. deviceConnectedAction = (x, y) => FindTrackedObjects(); SteamVR_Events.DeviceConnected.AddListener(deviceConnectedAction); #endif }
/// <summary> /// Creates the ball objects and other minor setup. "ForceReset" will clear existing balls if /// they were aleady set up, otherwise nothing will happen. /// </summary> public void SetUpBalls(bool forcereset = true) { if (isSetup) { if (forcereset) //If we're resetting, clear all existing balls and positions. { CleanUpBalls(); } else //Already set up but we don't want to reset. This is likely unintentional. { UnityEngine.Debug.LogError("Called AutomatedCalibration.Setup when it was already set up, but without requesting a reset."); return; } } Transform zedtrans = zedManager.transform; //Shorthand //Create the balls. for (int i = 0; i < spherePositions.Length; i++) { virtualPositions = new Vector3[spherePositions.Length]; realPositions = new Vector3[spherePositions.Length]; GameObject newballgo = Instantiate(autoCalibBallPrefab, zedtrans, false); newballgo.transform.localPosition = spherePositions[i]; AutoCalibBall newball = newballgo.GetComponentInChildren <AutoCalibBall>(); if (!newball) { throw new System.Exception("No AutoCalibBall script on autoCalibBallPrefab."); } newball.Setup(this, i); balls.Add(newball); } isSetup = true; //Update all message displays with instructions. MessageDisplay.DisplayMessageAll("AUTOMATIC MODE\r\nPut your controller inside a ball and click.\r\n" + "If the virtual ZED isn't facing you, use Manual Mode to get the image roughly aligned."); }
/// <summary> /// Handles the process of adding a reference point. First logs the starting point as the "virtual" point, and freezes the /// 2D video so the user can align the virtual controller with the real-world image. When they click again, this adds /// the "real" point and sends it to the AutoCalibrationManager. /// </summary> private IEnumerator PlacingBall(ZEDXRGrabber clicker) { if (!isSetup) { throw new System.Exception("Tried to use AutoCalibBall to calibrate before Setup was called on it."); } col.enabled = false; SetBallStateDisplay(DisplayState.Nothing); //Display new message. MessageDisplay.DisplayMessageAll("AUTOMATIC MODE\r\nLine up the virtual controller with its real-world counterpart. Then click again."); virtualPos = zedManager.transform.InverseTransformPoint(clicker.transform.position); //DrawOutputToPlane.pauseTextureUpdate = true; //Pause the video zedManager.pauseLiveReading = true; //TODO: Graphics stuff. //TODO: Hide all other calibration balls. //print("Paused - " + ballIndex); //First wait to make sure the click key is no longer held, so we can click it a second time separately. while (clicker.zedController.CheckClickButton(ControllerButtonState.Down)) { yield return(null); } //Now wait for it to go down again. while (!clicker.zedController.CheckClickButton(ControllerButtonState.Down)) { yield return(null); } realPos = zedManager.transform.InverseTransformPoint(clicker.transform.position); autoCalib.AddNewPositions(ballIndex, virtualPos, realPos); zedManager.pauseLiveReading = false; col.enabled = true; MessageDisplay.DisplayMessageAll("AUTOMATIC MODE\r\nRepeat this process with the rest of the balls, or stop when you're satisfied."); hasBeenSet = true; SetBallStateDisplay(DisplayState.Checkmark); }
/// <summary> /// Displays the instructions for calibration in manual mode. /// <para>his could have been put in any class used for manual transform mode exclusively - this was chosen arbitrarily.1</para>T /// </summary> private void OnEnable() { MessageDisplay.DisplayMessageAll("MANUAL MODE\r\nGrab the colored arrows/circles to move the ZED.\r\n" + "Position the 3D model of the ZED like it is in real-life."); }