private void ClickChangeLayerState(ModelLayer layer) { if (!instanceLoaded) { Debug.Log("No model loaded, cannot show layer."); return; } bool addLayer = !layersLoaded.ContainsKey(layer); if (!addLayer) { UnloadLayer(layer); } else { if (layer.DataType == DataType.Volumetric) { List <ModelLayer> layersToUnload = new List <ModelLayer>(); foreach (KeyValuePair <ModelLayer, LayerLoaded> entry in layersLoaded) { layersToUnload.Add(entry.Key); } foreach (ModelLayer l in layersToUnload) { UnloadLayer(l); HoloUtilities.SetButtonStateText(layersButtons[l], false); } } LoadLayer(layer); } HoloUtilities.SetButtonStateText(layersButtons[layer], addLayer); }
private void ClickSetColorMap(string colorMapName, GameObject currentButton) { MapName = colorMapName; foreach (GameObject button in colorMapButtons.Keys) { HoloUtilities.SetButtonStateText(button.GetComponent <PressableButtonHoloLens2>(), currentButton == button); } PlayerPrefs.SetString("ColorMap", colorMapName); PlayerPrefs.Save(); }
private void LoadInitialLayers() { if (!instanceLoaded) { throw new Exception("Cannot call TodoLoadMeshLayer before LoadInstance"); } Assert.IsTrue(instanceBundle != null); ModelLayer layer = instanceBundle.Layers.First <ModelLayer>(l => !l.Simulation); LoadLayer(layer); HoloUtilities.SetButtonStateText(layersButtons[layer], true); }
public void ClickChangeTransformationState(TransformationState newState) { bool rotationBoxRigActiveOld = transformationState == TransformationState.Rotate; bool scaleBoxRigActiveOld = transformationState == TransformationState.Scale; if (newState == transformationState) { // clicking again on the same sidebar button just toggles it off newState = TransformationState.None; } transformationState = newState; HoloUtilities.SetButtonState(ButtonTranslate, newState == TransformationState.Translate); HoloUtilities.SetButtonState(ButtonRotate, newState == TransformationState.Rotate); HoloUtilities.SetButtonState(ButtonScale, newState == TransformationState.Scale); // if transform the model: disable clipping plane manipulator if (newState != TransformationState.None && ModelClipPlaneCtrl.ClippingPlaneState != ModelClippingPlaneControl.ClipPlaneState.Disabled) { ModelClipPlaneCtrl.ClippingPlaneState = ModelClippingPlaneControl.ClipPlaneState.Active; } // turn on/off translation manipulation handDraggable.enabled = newState == TransformationState.Translate; handDraggable.IsDraggingEnabled = newState == TransformationState.Translate; // turn on/off rotation manipulation /* * We do not switch BoundingBoxRig enabled now. * It would serve no purpose (calling Activate or Deactivate is enough), * and it woud actually break Activate (because you cannot call Activate in the same * frame as setting enabled=true for the 1st frame, this causes problems in BoundingBoxRig * as private "objectToBound" is only assigned in BoundingBoxRig.Start). * * rotationBoxRig.enabled = newState == TransformationState.Rotate; */ // call rotationBoxRig.Activate or Deactivate bool rotationBoxRigActiveNew = newState == TransformationState.Rotate; if (rotationBoxRigActiveOld != rotationBoxRigActiveNew && rotationBoxRig != null) { if (rotationBoxRigActiveNew) { rotationBoxRig.GetComponent <BoundingBoxRig>().Activate(); } else { rotationBoxRig.GetComponent <BoundingBoxRig>().Deactivate(); } } /* As with rotationBoxRig, note that you cannot toggle enabled below. * For now, GetComponent<BoundingBoxRig>() is just enabled all the time. */ bool scaleBoxRigActiveNew = newState == TransformationState.Scale; if (scaleBoxRigActiveOld != scaleBoxRigActiveNew) { if (scaleBoxRigActiveNew) { GetComponent <TwoHandManipulatable>().enabled = true; } else { GetComponent <TwoHandManipulatable>().enabled = false; } } }
public void ChangeTransformationState(TransformationState newState) { bool rotationBoxRigActiveOld = transformationState == TransformationState.Rotate; bool scaleBoxRigActiveOld = transformationState == TransformationState.Scale; if (newState == transformationState) { // clicking again on the same sidebar button just toggles it off newState = TransformationState.None; } transformationState = newState; HoloUtilities.SetButtonState(ButtonTranslate, newState == TransformationState.Translate); HoloUtilities.SetButtonState(ButtonRotate, newState == TransformationState.Rotate); HoloUtilities.SetButtonState(ButtonScale, newState == TransformationState.Scale); // if transform the model: disable clipping plane manipulator if (newState != TransformationState.None && ModelClipPlaneCtrl.ClippingPlaneState != ModelClippingPlaneControl.ClipPlaneState.Disabled) { ModelClipPlaneCtrl.ClippingPlaneState = ModelClippingPlaneControl.ClipPlaneState.Active; } if (newState == TransformationState.Translate) { GetComponent <ObjectManipulator>().enabled = true; } else { GetComponent <ObjectManipulator>().enabled = false; } bool rotationBoxRigActiveNew = newState == TransformationState.Rotate; if (rotationBoxRigActiveOld != rotationBoxRigActiveNew && rotationBoxRig != null) { if (rotationBoxRigActiveNew) { rotationBoxRig.GetComponent <BoundsControl>().Active = true; rotationBoxRig.GetComponent <RotationAxisConstraint>().ConstraintOnRotation = AxisFlags.XAxis | AxisFlags.ZAxis; rotationBoxRig.GetComponent <MinMaxScaleConstraint>().enabled = true; } } /* As with rotationBoxRig, note that you cannot toggle enabled below. * For now, GetComponent<BoundingBoxRig>() is just enabled all the time. */ bool scaleBoxRigActiveNew = newState == TransformationState.Scale; if (scaleBoxRigActiveOld != scaleBoxRigActiveNew) { if (scaleBoxRigActiveNew) { rotationBoxRig.GetComponent <BoundsControl>().Active = true; rotationBoxRig.GetComponent <RotationAxisConstraint>().ConstraintOnRotation = AxisFlags.XAxis | AxisFlags.YAxis | AxisFlags.ZAxis; rotationBoxRig.GetComponent <MinMaxScaleConstraint>().enabled = false; } } if (!rotationBoxRigActiveNew && !scaleBoxRigActiveNew && rotationBoxRig != null) { rotationBoxRig.GetComponent <BoundsControl>().Active = false; } }