private float helper_timeSlice_lastYUpdate = 0.0f; // helper value to keep track of the last y-position update of the Time Slice when moved through Leap Motion Grasp Interaction /// <summary> /// Method to identify the Activation Toggle of a 3D Radar Chart (from potentially multiple in the Scene) the Leap Motion controller collided with, and set link interface references accordingly. /// </summary> /// <param name="controller">InteractionController representing the Leap Motion hand controller a contact event occured with.</param> private void vrlmTriggerActivationToggleOnPerControllerContactBegin(InteractionController controller) { // Developer Note: This is basically required to support interaction with multiple 3D Radar Charts in the Scene, assuming interaction with each charts' Activation Toggle switches the focus. // Generally, the routine goes as follows // (1) Identify collided (contacted) GameObject (potentially one or multiple). // (2) Identify Activation Toggle component among collided GameObjects, and retrieve reference to its 3D Radar Chart's main interface. // (3) Link references between VRLM and TDRC interfaces accordingly. // (4) Continue with interaction. // (1) HashSet <IInteractionBehaviour> .Enumerator em = controller.contactingObjects.GetEnumerator(); IInteractionBehaviour ib = null; while (em.MoveNext()) { ib = em.Current; // (2) TDRCInteractionActivationToggle iatComponent = ib.transform.GetComponent <TDRCInteractionActivationToggle>(); if (iatComponent != null) { break; } } // (3) ThreeDimRadarChartInterface tdrcInterfaceRef = ib.transform.parent.parent.GetComponent <ThreeDimRadarChartInterface>(); tdrcInterface = tdrcInterfaceRef; // (4) vrlmTriggerActivationToggle(); }
/// <summary> /// Method to set up all necessary GameObjects references for VR and Leap Motion Interaction. /// </summary> /// <param name="tdrcInterfaceRef">Reference to the ThreeDimRadarChartInterface instance.</param> /// <returns>True once everything has been set up.</returns> public bool setupForVRAndLeapMotionInteraction(ThreeDimRadarChartInterface tdrcInterfaceRef) { tdrcInterface = tdrcInterfaceRef; // Generally, the setup of GameObjects for Leap Motion interaction follows the same routine of: // (1) Attach an InteractionBehaviour component to the corresponding GameObject. // (2) Configure the attached InteractionBehaviour component if necessary. // (3) Setup EventListerners in the attached InteractionBehaviour component. if (tdrcInterface.interact_activationToggle != null) { InteractionBehaviour ibActivationToggle = tdrcInterface.interact_activationToggle.gameObject.AddComponent <InteractionBehaviour>(); ibActivationToggle.ignoreGrasping = true; ibActivationToggle.OnPerControllerContactBegin = vrlmTriggerActivationToggleOnPerControllerContactBegin; } if (tdrcInterface.interact_rotationHandle != null) { InteractionBehaviour ibRotationHandle = tdrcInterface.interact_rotationHandle.gameObject.AddComponent <InteractionBehaviour>(); ibRotationHandle.moveObjectWhenGrasped = true; // Note: Movement properties can be adjusted by editing the RigidBody component of the TDRCInteractionInteractionRotationHandle GameObject } if (tdrcInterface.interact_timeSliceGO != null) { ibTimeSliceGO = tdrcInterface.interact_timeSliceGO.AddComponent <InteractionBehaviour>(); ibTimeSliceGO.moveObjectWhenGrasped = false; ibTimeSliceGO.OnGraspStay = vrlmGraspStayTimeSlice; } return(true); }
/// <summary> /// Method to keep track of a reference to the 3D Radar Chart's main interface. /// </summary> /// <param name="tdrcInterfaceRef">Reference to the ThreeDimRadarChartInterface instance.</param> public void setTDRCInterface(ThreeDimRadarChartInterface tdrcInterfaceRef) { tdrcInterface = tdrcInterfaceRef; if (tdrcInterface != null) { updateButtonSprite(); } }
/// <summary> /// Method to keep track of a reference to the 3D Radar Chart's main interface. /// </summary> /// <param name="tdrcInterfaceRef">Reference to the ThreeDimRadarChartInterface instance.</param> public void setTDRCInterface(ThreeDimRadarChartInterface tdrcInterfaceRef) { tdrcInterface = tdrcInterfaceRef; }
private GameObject visualFeedback_rangeSelectionAxis; // reference to temporary created axis during time range selection process (as visual feedback during the time range selection process) #region PROPERTY_SETTERS /// <summary> /// Method to keep track of a reference to the 3D Radar Chart's main interface. /// </summary> /// <param name="tdrcInterfaceRef">Reference to the ThreeDimRadarChartInterface instance.</param> public void setTDRCInterface(ThreeDimRadarChartInterface tdrcInterfaceRef) { tdrcInterface = tdrcInterfaceRef; tdrcInterface.stt_timeRangeSelectionState = RangeSelectionState.NothingSelected; }
/// <summary> /// General update routine. /// </summary> private void Update() { // KEYBOARD INTERACTION for demonstration purposes // // Q - init and load data if (Input.GetKeyDown(KeyCode.Q)) { Debug.Log("Q pressed"); // only instantiate if not already existing if (demo_TDRCInterface == null && mainCamera != null) { // instantiate new TDRCInterface GameObject (attached as a Child to the GameObject this demo script is attached to) and get reference to ThreeDimRadarChartInterface component demo_TDRCInterface = Instantiate(Resources.Load(demo_TDRCInterfacePrefab) as GameObject, this.transform).GetComponent <ThreeDimRadarChartInterface>(); demo_TDRCInterface.name = "TDRCInterface_1"; // AFTER instantiation _AND_ BEFORE INITIALIZATION: do additional custom configurations to the ThreeDimRadarChartInterface, e.g., set data source and data source color coding properties, configure data transformation related values (normalization, scaling), etc. // Note: Default configuration possible beforehand by editing the Prefab directly in the Resources directory using the Unity Inspector. (Recommendation: If done so, create a copy of the original Prefab for save keeping of original configuration.) // // Some configuration examples: //demo_TDRCInterface.dataSourceLocalFilePath = "3D_Radar_Chart-resources/data/sample_data-3dtimevis"; //demo_TDRCInterface.isDataLoadedFromServer = false; //demo_TDRCInterface.cnfg2d_isFrequencyPolygonVisualizationNormalized = true; //demo_TDRCInterface.cnfg2d_frequencyPolygonMinimumDataValueForNormalization = 1; // based on Resources/3D_Radar_Chart-resources/data/sample_data-3dtimevis //demo_TDRCInterface.cnfg2d_frequencyPolygonMaximumDataValueForNormalization = 36; // based on Resources/3D_Radar_Chart-resources/data/sample_data-3dtimevis //demo_TDRCInterface.cnfg2d_frequencyPolygonNormalizationScaleFactor = 10.0f; //demo_TDRCInterface.cnfg2d_frequencyPolygonDataValueScaling = TDRCFrequencyPolygon.DataValueScaling.Linear; //demo_TDRCInterface.cnfg2d_linearScaleFactor = 0.25f; // ... // configuration for VR and Leap Motion if (demo_isEnabledForLeapMotionVRUsage) { demo_TDRCInterface.cnfgVRLM_isEnabled = true; } else { demo_TDRCInterface.cnfgVRLM_isEnabled = false; } // initialize 3D Radar Chart demo_TDRCInterface.initWithCameraAndPosition(mainCamera, demo_TDRCPosition); } } // if 3D Radar Chart has been set up if (demo_TDRCInterface != null) { // A - toggle activation state if (Input.GetKeyDown(KeyCode.A)) { Debug.Log("A pressed"); demo_TDRCInterface.triggerActivationToggle(); } // RIGHT / LEFT ARROW KEY - manual rotation of the Rotation Handle if (Input.GetKeyDown(KeyCode.RightArrow)) { Debug.Log("RIGHT Arrow pressed"); demo_TDRCInterface.interact_rotationHandle.rotateRight(demo_TDRCInterface.cnfgRotHndl_manualRotationEulerAngle); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { Debug.Log("LEFT Arrow pressed"); demo_TDRCInterface.interact_rotationHandle.rotateLeft(demo_TDRCInterface.cnfgRotHndl_manualRotationEulerAngle); } // UP / DOWN ARROW KEY - move Time Slice up and down by one index along the time-series axis if (Input.GetKeyDown(KeyCode.UpArrow)) { Debug.Log("UP Arrow pressed"); demo_TDRCInterface.timeSliceMoveUpOneIndex(); } if (Input.GetKeyDown(KeyCode.DownArrow)) { Debug.Log("DOWN Arrow pressed"); demo_TDRCInterface.timeSliceMoveDownOneIndex(); } // S - iterate through Time Range Selection states if (Input.GetKeyDown(KeyCode.S)) { Debug.Log("S pressed"); demo_TDRCInterface.timeRangeSelector.iterateTimeRangeSelectionState(); } } }
/// <summary> /// Method used for data value scaling based on the configuration of the 3D Radar Chart's Interface. (Note: Data value is just transformed for visualization, i.e., no changes in the actual data are performed.) /// </summary> /// <param name="dataValue">Float value representing the original data value that is going to be scaled for visualization.</param> /// <param name="tdrci">Reference to ThreeDimRadarChartInterface instance used for configuration.</param> /// <returns>Float value representing the scaled original data value.</returns> private static float getDataValueForVisualizationBasedOnConfiguredScaling(float dataValue, ThreeDimRadarChartInterface tdrci) { float scaledDataValue; switch (tdrci.cnfg2d_frequencyPolygonDataValueScaling) { case DataValueScaling.NoScaling: default: scaledDataValue = (dataValue > 0) ? dataValue : 0.0f; break; case DataValueScaling.Linear: scaledDataValue = (dataValue > 0) ? dataValue * tdrci.cnfg2d_linearScaleFactor : 0.0f; break; case DataValueScaling.Logarithmic_Base2: scaledDataValue = (dataValue > 0) ? Mathf.Log(dataValue, 2) : 0.0f; break; } return(scaledDataValue); }
/// <summary> /// Method used for data value normalization based on the configuration of the 3D Radar Chart's Interface. (Note: Data value is just transformed for visualization, i.e., no changes in the actual data are performed.) /// </summary> /// <param name="dataValue">Float value representing the original data value that is going to be normalized for visualization.</param> /// <param name="tdrci">Reference to ThreeDimRadarChartInterface instance used for configuration.</param> /// <returns>Float value representing the normalized original data value (data value range = 0 to 1).</returns> private static float getDataValueForVisualizationBasedOnConfiguredNormalization(float dataValue, ThreeDimRadarChartInterface tdrci) { return((dataValue - tdrci.cnfg2d_frequencyPolygonMinimumDataValueForNormalization) / (tdrci.cnfg2d_frequencyPolygonMaximumDataValueForNormalization - tdrci.cnfg2d_frequencyPolygonMinimumDataValueForNormalization)); }
/// <summary> /// Method used for data value transformation (normalization or scaling) based on the configuration of the 3D Radar Chart's Interface. (Note: Data value is just transformed for visualization, i.e., no changes in the actual data are performed.) /// </summary> /// <param name="dataValue">Float value representing the original data value that is going to be transformed (normalized or scaled) for visualization.</param> /// <param name="tdrci">Reference to ThreeDimRadarChartInterface instance used for configuration.</param> /// <returns>Float value representing the transformed original data value.</returns> public static float getDataValueForVisualizationBasedOnTDRCInterfaceConfig(float dataValue, ThreeDimRadarChartInterface tdrci) { // check whether to apply normalization if (tdrci.cnfg2d_isFrequencyPolygonVisualizationNormalized) { return(getDataValueForVisualizationBasedOnConfiguredNormalization(dataValue, tdrci) * tdrci.cnfg2d_frequencyPolygonNormalizationScaleFactor); } // if not: apply scaling based on configuration else { return(getDataValueForVisualizationBasedOnConfiguredScaling(dataValue, tdrci)); } }