void FinalizeVector(object sender, ControllerEventArgs e) { if (coordType == CoordSystemType.CARTESIAN) { if (e.isLeft) { leftActiveVec.CreateInCartesian(); leftActiveVec = null; } else { rightActiveVec.CreateInCartesian(); rightActiveVec = null; } } else { if (e.isLeft) { leftActiveVec.CreateInGeneral(); leftActiveVec = null; } else { rightActiveVec.CreateInGeneral(); rightActiveVec = null; } } }
void ReadLeftController() { if (leftController.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { //app.leftMenu.EnableSelector(leftController.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x * 0.045f, // leftController.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).y * 0.045f); app.SetLeftMenuPress(true); } else if (leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad)) { //app.leftMenu.EnableSelector(); } else if (leftController.GetTouch(SteamVR_Controller.ButtonMask.Touchpad)) { //app.leftMenu.UpdateSelector(leftController.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x * 0.045f, // leftController.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).y * 0.045f); } else if (leftController.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad)) { //app.leftMenu.DisableSelector(); //app.SetleftMenuPress(false); } /* * // Toggle Coordinate System * if(leftController.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) * { * int currType = (int)CoordinateSystemInteraction.coordType; * currType++; * currType = currType % 3; * if (Enum.IsDefined(typeof(CoordinateSystemInteraction.CoordType), currType)) * { * CoordinateSystemInteraction.coordType = (CoordinateSystemInteraction.CoordType)currType; * } * } * * // Toggle Interaction Mode * if (leftController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) * { * int currMode = (int)coordSystem.interactionMode; * currMode++; * currMode = currMode % 5; * if(Enum.IsDefined(typeof(CoordinateSystemInteraction.InteractionMode), currMode)) * { * coordSystem.interactionMode = (CoordinateSystemInteraction.InteractionMode)currMode; * } * } */ // Reposition /* * if (leftController.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) * { * currPos = transform.position; * currLeftPos = leftController.transform.pos; * } * else if (leftController.GetPress(SteamVR_Controller.ButtonMask.Grip)) * { * Vector3 delta = currLeftPos - leftController.transform.pos; * //Vector3 delta = leftController.transform.pos - currLeftPos; * transform.position = currPos + delta; * } */ // Toggle Vector Interactions switch (coordSystem.interactionMode) { case CoordinateSystemInteraction.InteractionMode.Create: if (leftActive == null && leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { leftActive = coordSystem.CreateVector(leftTip.position); } else if (leftActive != null && leftController.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger)) { if (CoordinateSystemInteraction.coordType == CoordinateSystemInteraction.CoordType.Cartesian) { leftActive.CreateInCartesian(); } else { leftActive.CreateInGeneral(); } leftActive = null; } else if (leftActive != null) { leftActive.SetPosition(leftActive.GetStart, leftTip.position); } break; case CoordinateSystemInteraction.InteractionMode.Modify: if (leftActive == null && leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { foreach (MathBox_Vector v in coordSystem.usercreated_list) { if ((v.GetEnd - leftTip.position).magnitude < 0.5) { leftActive = v; break; } } } else if (leftActive != null && leftController.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger)) { if (CoordinateSystemInteraction.coordType == CoordinateSystemInteraction.CoordType.Cartesian) { leftActive.FinishEditInCartesian(); } else { leftActive.FinishEditInGeneral(); } leftActive = null; } else if (leftActive != null) { leftActive.SetPosition(leftActive.GetStart, leftTip.position); } break; case CoordinateSystemInteraction.InteractionMode.Operate: if (coordSystem.selected_vectors.Count < 2 && leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { foreach (MathBox_Vector v in coordSystem.usercreated_list) { if ((v.GetEnd - leftTip.position).magnitude < 0.5) { coordSystem.SelectVector(v); break; } } } else if (coordSystem.selected_vectors.Count == 2 && leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { if (coordSystem.opMode == CoordinateSystemInteraction.OperateMode.Addition) { coordSystem.AddSelected(); } else if (coordSystem.opMode == CoordinateSystemInteraction.OperateMode.CrossProduct) { coordSystem.CrossSelected(); } } else if (leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad)) { if (coordSystem.opMode == CoordinateSystemInteraction.OperateMode.Addition) { coordSystem.opMode = CoordinateSystemInteraction.OperateMode.CrossProduct; } else if (coordSystem.opMode == CoordinateSystemInteraction.OperateMode.CrossProduct) { coordSystem.opMode = CoordinateSystemInteraction.OperateMode.Addition; } } break; /* * case CoordinateSystemInteraction.InteractionMode.Function3D: * if (leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) && activeSurface == null) * { * activeSurface = coordSystem.CreateSurface(); * } * else if(leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) && activeSurface != null) * { * activeSurface = null; * coordSystem.ClearSurface(); * } * break; * case CoordinateSystemInteraction.InteractionMode.Clear: * if (leftController.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) * { * coordSystem.ClearScene(); * } * break; */ } }