public HandObjectState onUpdated(Vector3 pos, Quaternion rot, float up, float foward) { obj.transform.position = pos + obj.transform.up * up + obj.transform.forward * foward; obj.transform.rotation = rot; HandObjectState state = HandObjectState.None; if (dragflag) { state = HandObjectState.DragUpdate; } else if (pressflag) { if (Vector3.Distance(presspos, obj.transform.position) > DragDistance) { state = HandObjectState.DragStart; dragflag = true; if (objectcontrol != null) { objectcontrol.onReleased(); } } else if (Time.time - presstime > HoldTriggerTime) { state = HandObjectState.Hold; pressflag = false; if (objectcontrol != null) { objectcontrol.onReleased(); } } } return(state); }
public HandObjectState onReleased() { HandObjectState state = HandObjectState.None; if (Time.time - presstime < PressIntervalTime) { state = (Time.time - taptime < PressIntervalTime) ? HandObjectState.DoubleTap : HandObjectState.Tap; } taptime = Time.time; pressflag = false; dragflag = false; if (objectcontrol != null) { objectcontrol.onReleased(); } return(state); }
private void onReleased(HandsInteractionManager.HandPointClass hand) { HandObjectClass obj; if (HandObjects.TryGetValue(hand.id, out obj)) { HandObjectState state = obj.onReleased(); foreach (var item in HandObjects.Values) { if (item.GetPress()) { return; } } if (multipressflag) { if (Time.time - multipresstime < PressIntervalTime) { if (Time.time - multitaptime < PressIntervalTime) { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.MultiDoubleTap); } } else { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.MultiTap); } } } multipressflag = false; multitaptime = Time.time; } else { if (state == HandObjectState.Tap) { if (obj.GetShiftFlag() == false) { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.SelectTap); } } else { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.GripTap); } } } else if (state == HandObjectState.DoubleTap) { if (obj.GetShiftFlag() == false) { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.SelectDoubleTap); } } else { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.GripDoubleTap); } } } } } if (HandControllerEndEvent != null) { HandControllerEndEvent(); } }
private void onUpdated(HandsInteractionManager.HandPointClass hand) { HandObjectClass obj; if (HandObjects.TryGetValue(hand.id, out obj)) { HandObjectState state = obj.onUpdated(hand.pos, hand.rot, Offset_up, Offset_foward); int dragcount = 0; Vector3[] pos = new Vector3[2]; Quaternion[] rot = new Quaternion[2]; foreach (var item in HandObjects.Values) { if (item.GetPress()) { pos[dragcount] = item.GetPosition(); rot[dragcount] = item.GetRotation(); dragcount++; } } if (dragcount == 2) { if (Time.time - multipresstime > PressIntervalTime) { if (multihandflag == false) { if (HandControllerStartEvent != null) { HandControllerStartEvent(HandControllerState.MultiDrag, pos[0], rot[0], pos[1], rot[1]); } multihandflag = true; } else { if (HandControllerUpdateEvent != null) { HandControllerUpdateEvent(HandControllerState.MultiDrag, pos[0], rot[0], pos[1], rot[1]); } } } obj.SetHandObjectControlRelease(); } else { if (multihandflag) { if (dragcount == 0) { multihandflag = false; } } else { if (state == HandObjectState.Hold) { if (obj.GetShiftFlag() == false) { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.SelectHold); } } else { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.GripHold); } } } else if (state == HandObjectState.DragStart) { if (obj.GetShiftFlag() == false) { if (HandControllerStartEvent != null) { HandControllerStartEvent(HandControllerState.SelectDrag, obj.GetPosition(), obj.GetRotation(), null, null); } } else { if (HandControllerStartEvent != null) { HandControllerStartEvent(HandControllerState.GripDrag, obj.GetPosition(), obj.GetRotation(), null, null); } } } else if (state == HandObjectState.DragUpdate) { if (obj.GetShiftFlag() == false) { if (HandControllerUpdateEvent != null) { HandControllerUpdateEvent(HandControllerState.SelectDrag, obj.GetPosition(), obj.GetRotation(), null, null); } } else { if (HandControllerUpdateEvent != null) { HandControllerUpdateEvent(HandControllerState.GripDrag, obj.GetPosition(), obj.GetRotation(), null, null); } } } } } } }