private IEnumerator MoveSphereInside(Action initialAction, Action finalAction) { if (movingSphere) { yield break; } movingSphere = true; var notInZeroSphereControllers = sphereControllers.Where( sphereController => sphereController.notInZero ).ToList(); if (notInZeroSphereControllers.Count == 1) { movingSphere = false; yield break; } var radiusAlphaTargetReached = new List <Tuple <bool, bool> >(); for (int i = 0; i < notInZeroSphereControllers.Count; i++) { radiusAlphaTargetReached.Add(Tuple.New(false, false)); } var actualRadiusFactor = radiusFactor * -1; csvCreator.AddLines("Changing Sphere", (actualVisualization + 2).ToString()); if (initialAction != null) { initialAction(); } while (true) { for (int i = 0; i < notInZeroSphereControllers.Count; i++) { var sphereController = notInZeroSphereControllers[i]; var radiusTargetReached = false; var alphaTargerReached = false; //Radius var targetRadius = radiusAlphaVisualizationList[i].First; sphereController.sphereRadius += actualRadiusFactor * radiusSpeed; if (TargetReached(actualRadiusFactor, sphereController.sphereRadius, targetRadius)) { radiusTargetReached = true; sphereController.sphereRadius = targetRadius; } //Alpha var actualAlphaFactor = i == 0 ? alphaFactor * -1 : alphaFactor; var targetAlpha = radiusAlphaVisualizationList[i].Second; sphereController.alpha += actualAlphaFactor * alphaSpeed; if (TargetReached(actualAlphaFactor, sphereController.alpha, targetAlpha)) { alphaTargerReached = true; sphereController.alpha = targetAlpha; } sphereController.ChangeVisualizationConfiguration(transform.position, sphereController.sphereRadius, sphereController.alpha); radiusAlphaTargetReached[i] = Tuple.New(radiusTargetReached, alphaTargerReached); } if (radiusAlphaTargetReached.All(t => t.First && t.Second)) { break; } yield return(new WaitForFixedUpdate()); } sphereControllers[actualVisualization].notInZero = false; sphereControllers[actualVisualization].gameObject.SetActive(false); actualVisualization++; if (finalAction != null) { finalAction(); } movingSphere = false; }
public void Start() { Scope = ProfileManager.Instance.currentEvaluationScope; SetVariables(); var visualizationTextureIndex = 0; var visualizationIndex = 0; actualVisualization = 0; radiusAlphaVisualizationList = new List <Tuple <float, float> > { Tuple.New(0.0f, 0.0f) }; movingSphere = false; movingPlane = false; csvCreator = new CsvCreator(csvCreatorPath); csvCreator.AddLines("TEST", ("Use Vortices: " + (!bgiiesMode).ToString() + " -- UseBgiies: " + bgiiesMode.ToString() + " -- Use LeapMotion: " + useLeapMotion.ToString() + "-- Use Pitch Grab: " + usePitchGrab.ToString() + " -- Use OpenGlove: " + useHapticGlove.ToString() + " -- Use Joystick: " + useJoystick.ToString() + " -- Use Mouse: " + mouseInput.ToString() + " -- Use Kinect: " + kinectInput.ToString())); var leapSpaceChildrens = leapMotionRig.leapSpace.transform.GetChildren(); foreach (var leapSpacechildren in leapSpaceChildrens) { leapSpacechildren.gameObject.SetActive(useLeapMotion); } if (autoTuneVisualizationOnPlay) { if (visualizationPlane) { AutoTunePlanes(); } else { AutoTuneSpheres(); } } if (visualizationPlane) { foreach (var planeController in planeControllers) { planeController.InitializeDioControllers(this, visualizationIndex, transform.position, visualizationTextureIndex, true); radiusAlphaVisualizationList.Add(Tuple.New(planeController.distance, planeController.alpha)); visualizationTextureIndex += planeController.elementsToDisplay; visualizationIndex += 1; } } else { foreach (var sphereController in sphereControllers) { sphereController.InitializeDioControllers(this, visualizationIndex, transform.position, visualizationTextureIndex, true); radiusAlphaVisualizationList.Add(Tuple.New(sphereController.sphereRadius, sphereController.alpha)); visualizationTextureIndex += sphereController.elementsToDisplay; visualizationIndex += 1; } } if (bgiiesMode) { if (lookPointerBgiiesPrefab != null) { var lookPointerPosition = new Vector3(0.0f, 0.0f, radiusAlphaVisualizationList[1].First); lookPointerInstanceBgiies = Instantiate(lookPointerBgiiesPrefab, leapMotionRig.centerEyeAnchor, lookPointerPosition, Quaternion.identity); lookPointerInstanceBgiies.transform.localScale = lookPointerScale; lookPointerInstanceBgiies.Initialize(this); } } else { if (lookPointerPrefab != null && !(useKeyboard && useMouse)) { var lookPointerPosition = new Vector3(0.0f, 0.0f, radiusAlphaVisualizationList[1].First); lookPointerInstance = Instantiate(lookPointerPrefab, leapMotionRig.centerEyeAnchor, lookPointerPosition, Quaternion.identity); lookPointerInstance.transform.localScale = lookPointerScale; lookPointerInstance.Initialize(this); } } rayCastingDetector.Initialize(this); if (bgiiesMode) { buttonPanel.gameObject.SetActive(false); panelBgiies.Initialize(this); if (kinectInput) { bodySrcManager.gameObject.SetActive(true); kinectGestures.gameObject.SetActive(true); kinectGestures.Initialize(this); kinectFace.gameObject.SetActive(true); kinectFace.Initialize(this); kinectGestureManager.gameObject.SetActive(true); kinectGestureManager.Initialize(this); } } else { panelBgiies.gameObject.SetActive(false); buttonPanel.Initialize(this); } loadImageController.Initialize(this); loadingScene.Initialize(this); //unityOpenGlove.Initialize(this); if (useHapticGlove) { unityHapticGlove.gameObject.SetActive(true); unityHapticGlove.Initialize(this); } if (!bgiiesMode) { if (useLeapMotion) { buttonPanel.transform.parent = leapMotionRig.centerEyeAnchor.transform; var buttonPanelPosition = buttonPanel.transform.position; buttonPanelPosition.z = 0.4f; buttonPanel.transform.position = new Vector3(buttonPanelPosition.x, buttonPanelPosition.y, buttonPanelPosition.z); if (!usePitchGrab) { buttonPanel.zoomOut3DButton.gameObject.SetActive(false); } } buttonPanel.zoomIn3DButton.gameObject.SetActive(false); } if (bgiiesMode) { StartCoroutine(loadImageController.LoadFolderImages(planeControllers.SelectMany(sc => sc.dioControllerList).ToList())); } else { StartCoroutine(loadImageController.LoadFolderImages(sphereControllers.SelectMany(sc => sc.dioControllerList).ToList())); } initialSphereAction = () => { buttonPanel.DisableZoomIn(); buttonPanel.DisableZoomOut(); buttonPanel.DisableAccept(); buttonPanel.DisableMoveCameraInside(); buttonPanel.DisableMoveCameraOutside(); }; finalSphereAction = () => { buttonPanel.EnableMoveCameraInside(); buttonPanel.EnableMoveCameraOutside(); }; initialPlaneAction = () => { panelBgiies.DisableMoveCameraInside(); panelBgiies.DisableMoveCameraOutside(); }; finalPlaneAction = () => { panelBgiies.EnableMoveCameraInside(); panelBgiies.EnableMoveCameraOutside(); }; ActionManager.Instance.InitializeManager(this); EEGManager.Instance.CheckInterfaces(); EyetrackerManager.Instance.InitializeManager(this); }