void Update() { // TODO: Turns out this has some issues. It's -1 at the upper extent, and 1 at the lower. It seems to also extend beyond 1/-1 which is shouldn't. // TODO : Really, we want this to be a non-linear control, it should be possible at the extremes to spend longer with more control brightnessRatio = Mathf.Clamp(ratioController.getVerticalDirection(), -1, 1); // Don't over communicate :-) if (Mathf.Abs(previousBrightnessRatio - brightnessRatio) > 0.01) { NetworkManager.instance.SetFloat("brightnessRatio", brightnessRatio); Debug.Log("Brightness Ratio " + brightnessRatio); previousBrightnessRatio = brightnessRatio; } cameraRig.SetBinocularSuppressionRatio(brightnessRatio); //Now lets check to see if the headset if being held still if (!ignoreStillnessSensor) { float still = stillness.getTimeStill(); Debug.Log("Time still " + still); if (still > secondsOfStillnessForSelect) { //Selected! indicator.Reset(); StoreSuppressionRatioAndQuit(); } else { //redraw the indicator and play a rising tone?!? float percentage = (still / secondsOfStillnessForSelect); //Debug.Log("Percentage still " + percentage); indicator.SetIndicatorPercentage(percentage); } } if (esInput.GetShortButtonPress("EyeSkills Confirm") || NetworkManager.instance.GetButton("save")) { StoreSuppressionRatioAndQuit(); } else if (esInput.GetShortButtonPress("EyeSkills Up") || NetworkManager.instance.GetButton("inConflict")) { AudioManager.instance.Say("inConflict"); model.IntoConflict(); } else if (esInput.GetShortButtonPress("EyeSkills Down") || NetworkManager.instance.GetButton("outOfConflict")) { AudioManager.instance.Say("notInConflict"); model.OutOfConflict(); } }
IEnumerator DemonstrateBinocularSuppressionRatio(EyeSkillsVRHeadsetInput ratioController, ConflictZoneModel model, EyeSkillsCameraRig cameraRig) { float brightnessRatio; while (true) { //Update the luminance ratio for each eye brightnessRatio = Mathf.Clamp(ratioController.getVerticalDirection(), -1, 1); cameraRig.SetBinocularSuppressionRatio(brightnessRatio); yield return(null); } }
/// <summary> /// Identifies the binocular suppression ratio. /// </summary> /// <returns>The binocular suppression ratio.</returns> /// <param name="ratioController">Ratio controller. Where we get our signal from to alter the ratio - e.g. tilt angle of head</param> /// <param name="model">Model. The model that provides us the conflict images.</param> /// <param name="cameraRig">Camera rig. The cameras whose relative brightness we wish to alter.</param> /// <param name="stillness">Stillness. Where we get information from about whether or not the headset is still. Might have been better to pass this headset specific mechanism to the VRHeadsetInput, which could have implemented a generic interface for reporting "stillness"</param> /// <param name="indicator">Indicator. The element which informs the user about the progress of the stillness based selection</param> /// <param name="NextStep">Next step.</param> /// <param name="secondsOfStillnessForSelect">Seconds of stillness for select.</param> IEnumerator IdentifyBinocularSuppressionRatio(EyeSkillsVRHeadsetInput ratioController, ConflictZoneModel model, EyeSkillsCameraRig cameraRig, EyeSkillsVRHeadsetSelectByStillness stillness, SelectionIndicatorScaler indicator, Action <float> NextStep, float secondsOfStillnessForSelect) { float suppressionRatio = 0; float still = 0; float brightnessRatio; stillness.StartTracking(); //TODO : We probably need a maximum timeout for if the headset never appears to settle! still = stillness.getTimeStill(); while (still < secondsOfStillnessForSelect) { //Update the luminance ratio for each eye brightnessRatio = Mathf.Clamp(ratioController.getVerticalDirection(), -1, 1); cameraRig.SetBinocularSuppressionRatio(brightnessRatio); //redraw the indicator and play a rising tone?!? float percentage = (still / secondsOfStillnessForSelect); //Debug.Log("Percentage still " + percentage); indicator.SetIndicatorPercentage(percentage); yield return(null); still = stillness.getTimeStill(); //Debug.Log("ratio : "+ brightnessRatio + " %:" + percentage); } stillness.StopTracking(); indicator.Reset(); StopConflictEnvironment(); NextStep(suppressionRatio); }
void Update() { //TODO : Do not forget these experiences started as a quick experimental hack. They must be completely refactored. //Debug.Log("Time still " + still); if (!practitionerMode) { if (chooseCancel.IsCancelled()) { ResetEyeMisalignment(); userWantsStraightening = true; } } //TODO: Confirm (or waiting a specified time, or resetting a given number of times) should exit, but restart/shaking the head should reset the camera - we ought to record each reset within the specified time. if (esInput.GetShortButtonPress("EyeSkills Confirm") || NetworkManager.instance.GetButton("store") || NetworkManager.instance.GetButton("start") || chooseCancel.IsCancelled()) //TODO : or SHAKE { // Time to log our new time to the calibration object. // We store the best (least) misalignment the participant achieved as an absolute angle if (cameraRig.config.leastMisalignmentBeforeFusionLost > currentAngle) { Debug.Log("Storing least misalignment before fusion lost"); cameraRig.config.leastMisalignmentBeforeFusionLost = Mathf.Abs(currentAngle); AudioManager.instance.Say("SavingBestAngle"); } Debug.Log("Resetting eye"); ResetEyeMisalignment(); userWantsStraightening = true; } //if (esInput.GetShortButtonPress("EyeSkills Up")) //{ // AudioManager.instance.Say("BlinkersOn"); // blinker1.SetActive(true); // blinker2.SetActive(true); //} //else if (esInput.GetShortButtonPress("EyeSkills Down")) //{ // AudioManager.instance.Say("BlinkersOff"); // blinker1.SetActive(false); // blinker2.SetActive(false); //} if (userWantsStraightening) { //Debug.Log("Straightening"); cameraRig.RotateToStraightenEye(eyeMask, turningRate * Time.deltaTime); // The least distance we were away from being straight. currentAngle = cameraRig.GetEyeAngle(eyeMask).y; //misalignedEye.transform.rotation.eulerAngles.y; if (currentAngle > 180) { currentAngle = 360 - currentAngle; //HACK. Need to think this through more thoroughly. } //currentAngle = Vector3.Angle(misalignedEye.transform.rotation.eulerAngles, nonMisalignedEye.transform.rotation.eulerAngles).y; NetworkManager.instance.SetFloat("degree", currentAngle); } // Lets just hack the binocular suppression de-escalation to implicitly detect when it's needed //Debug.Log("current angle : " + currentAngle); if (Mathf.Approximately(currentAngle, 0) && !areRemovingSuppression) { AudioManager.instance.Say("Straightened"); Debug.Log("Starting to remove suppression"); areRemovingSuppression = true; currentSuppressionRatio = originalSuppressionRatio; } else if (!Mathf.Approximately(currentAngle, 0) && (areRemovingSuppression)) { //the cameras are no longer straight, but we had been manipulating the suppression ratio, so reset it Debug.Log("Resetting suppression"); AudioManager.instance.Say("Resetting"); cameraRig.SetBinocularSuppressionRatio(originalSuppressionRatio); areRemovingSuppression = false; } if (areRemovingSuppression) { // Now we need to gradually straighten up the binocular suppression ratio if (!Mathf.Approximately(currentSuppressionRatio, 0f)) { currentSuppressionRatio = currentSuppressionRatio - (currentSuppressionRatio * suppressionReductionRate * Time.deltaTime); //Debug.Log("Current suppression ratio " + currentSuppressionRatio); cameraRig.SetBinocularSuppressionRatio(currentSuppressionRatio); if (Mathf.Approximately(currentSuppressionRatio, 0f)) { AudioManager.instance.Say("SuppressionCompensationRemoved"); } } } if (esInput.GetShortButtonPress("EyeSkills Up")) //Cycle through the available cameras { int camID = currentCam % phoneCamera.getNumberOfCameras(); Debug.Log("Trying to choose camera number " + camID); phoneCamera.startCamera(camID); currentCam += 1; } }