Esempio n. 1
0
 public void OnClick(HandInput Source)
 {
     var selectedObjects = UIManager.Instance.GetSelectedObjects();
     foreach (var item in selectedObjects)
     {
         var rigidbody = item.GetComponent<Rigidbody>();
         if (rigidbody != null)
             rigidbody.AddForce(new Vector3(-100f, 0, 0));
         else
             item.transform.Translate(-0.1f, 0, 0);
     }
 }
Esempio n. 2
0
    void CollectInput(ref HandPose hand, ref ControllerPose controller, ref HandInput i)
    {
        i.handTrigger          = hand.gripFlex;
        i.previousIndexTrigger = i.indexTrigger;
        i.indexTrigger         = hand.indexFlex;

        if (i.indexTrigger >= IndexThreshold && i.previousIndexTrigger < IndexThreshold)
        {
            i.indexPressFrame = context.renderFrame;
        }

        i.isPointing  = true;
        i.isPressingX = controller.button1IsDown;
        i.isPressingY = controller.button2IsDown;
        i.stick       = controller.joystickPosition;
    }
 public void UnregisterDeviceAngularVelocityNotify(HandInput handInput, Action <Vector3> notify)
 {
     deviceAngularVelocityNotifies[(int)handInput].Remove(notify);
 }
 public void RegisterDeviceVelocityNotify(HandInput handInput, Action <Vector3> notify)
 {
     deviceVelocityNotifies[(int)handInput].Add(notify);
 }
 public void UnregisterDeviceRotationNotify(HandInput handInput, Action <Quaternion> notify)
 {
     deviceRotationNotifies[(int)handInput].Remove(notify);
 }
 public void RegisterTriggerCanceledNotify(HandInput handInput, Action notify)
 {
     triggerCanceledNotifies[(int)handInput].Add(notify);
 }
Esempio n. 7
0
 void Awake()
 {
     player     = GameObject.Find("Player").GetComponent <PlayerBehaviour>();
     playerHand = GameObject.Find("PlayerHand").GetComponent <HandBehaviour>();
     handBoard  = playerHand.GetComponent <HandInput>();
 }
Esempio n. 8
0
            public HandsState(Body body)
            {
                CameraSpacePoint handLeft  = body.Joints[JointType.HandLeft].Position;
                CameraSpacePoint handRight = body.Joints[JointType.HandRight].Position;

                wristLeft  = body.Joints[JointType.WristLeft].Position;
                wristRight = body.Joints[JointType.WristRight].Position;
                CameraSpacePoint spineBase = body.Joints[JointType.SpineBase].Position;

                input             = new HandInput();
                input.isLeftGrip  = (body.HandLeftState == HandState.Closed);
                input.isRightGrip = (body.HandRightState == HandState.Closed);

                //select wrist
                if (prime_hand)
                {
                    primeHandy = (int)(wristRight.Y * 100);
                    isRight    = true;
                }
                else
                {
                    primeHandy = (int)(wristLeft.Y * 100);
                    isRight    = false;
                }
                //set left hand position
                float leftDepth = spineBase.Z - handLeft.Z;

                input._LPressExtent = (leftDepth - TOUCH_REGION) / (EMBED_REGION - TOUCH_REGION);
                if (leftDepth > EMBED_REGION)
                {
                    LeftHandPosition = HandPositionZ.EMBED;
                }
                else if (leftDepth > TOUCH_REGION)
                {
                    LeftHandPosition = HandPositionZ.TOUCH;
                }
                else
                {
                    LeftHandPosition = HandPositionZ.UNKNOW;
                }
                //set right hand position
                float rightDepth = spineBase.Z - handRight.Z;

                input._RPressExtent = (rightDepth - TOUCH_REGION) / (EMBED_REGION - TOUCH_REGION);
                if (rightDepth > EMBED_REGION)
                {
                    RightHandPosition = HandPositionZ.EMBED;
                }
                else if (rightDepth > TOUCH_REGION)
                {
                    RightHandPosition = HandPositionZ.TOUCH;
                }
                else
                {
                    RightHandPosition = HandPositionZ.UNKNOW;
                }
                //set left hand state
                LeftHandState = body.HandLeftState;
                //set right hand state
                RightHandState = body.HandRightState;

                //no hand
                if (LeftHandPosition == HandPositionZ.UNKNOW && RightHandPosition == HandPositionZ.UNKNOW)
                {
                    operation      = Operation.no_operation;
                    input._isWhich = 0;
                }
                //single hand
                else if (LeftHandPosition == HandPositionZ.UNKNOW || RightHandPosition == HandPositionZ.UNKNOW)
                {
                    //left hand operate
                    if (LeftHandPosition != HandPositionZ.UNKNOW)
                    {
                        SelectHandPosition = LeftHandPosition;
                        SelectHandState    = LeftHandState;
                        input._isWhich     = 1;
                        isRight            = false;
                    }
                    //right hand operate
                    else
                    {
                        SelectHandPosition = RightHandPosition;
                        SelectHandState    = RightHandState;
                        input._isWhich     = 2;
                        isRight            = true;
                    }
                    //single hand touch region
                    if (SelectHandPosition == HandPositionZ.TOUCH)
                    {
                        if (SelectHandState == HandState.Closed)
                        {
                            if (mouse_click_region)
                            {
                                operation = Operation.left_down;
                            }
                            else
                            {
                                operation = Operation.right_down;
                            }
                        }
                        else
                        {
                            operation = Operation.move;
                        }
                    }
                    //single hand embed region
                    else
                    {
                        if (SelectHandState == HandState.Closed)
                        {
                            if (mouse_click_region)
                            {
                                operation = Operation.right_down;
                            }
                            else
                            {
                                operation = Operation.left_down;
                            }
                        }
                        else
                        {
                            operation = Operation.move;
                        }
                    }
                }
                else
                {
                    //two hand closed will operate wheel
                    input._isWhich = 3;
                    if (LeftHandState == HandState.Closed && RightHandState == HandState.Closed)
                    {
                        if (middle_button_and_wheel)
                        {
                            operation = Operation.wheel;
                        }
                        else
                        {
                            operation = Operation.middle_down;
                        }
                    }
                    //one hand closed
                    else if (LeftHandState == HandState.Closed || RightHandState == HandState.Closed)
                    {
                        if (middle_button_and_wheel)
                        {
                            operation = Operation.middle_down;
                        }
                        else
                        {
                            operation = Operation.wheel;
                        }
                    }
                    else
                    {
                        operation = Operation.move;
                    }
                }
            }
 public void UnregisterPrimaryButtonTouchedNotifies(HandInput handInput, Action notify)
 {
     primaryButtonTouchedNotifies[(int)handInput].Remove(notify);
 }
Esempio n. 10
0
 public void UnregisterThumbstickDirectionNotify(HandInput handInput, Action <Vector2> notify)
 {
     thumbstickDirectionNotifies[(int)handInput].Remove(notify);
 }
Esempio n. 11
0
 public void UnregisterThumbstickTriggeredNotify(HandInput handInput, Action notify)
 {
     thumbstickTriggeredNotifies[(int)handInput].Remove(notify);
 }
Esempio n. 12
0
 public void RegisterThumbstickTriggeredNotify(HandInput handInput, Action notify)
 {
     thumbstickTriggeredNotifies[(int)handInput].Add(notify);
 }
Esempio n. 13
0
 public void UnregisterTriggerStrengthNotify(HandInput handInput, Action <float> notify)
 {
     triggerStrengthNotifies[(int)handInput].Remove(notify);
 }
Esempio n. 14
0
 public void UnregisterTriggerCanceledNotify(HandInput handInput, Action notify)
 {
     triggerCanceledNotifies[(int)handInput].Remove(notify);
 }
Esempio n. 15
0
 public void UnregisterGripTriggeredNotify(HandInput handInput, Action notify)
 {
     gripTriggeredNotifies[(int)handInput].Remove(notify);
 }
Esempio n. 16
0
 public void RegisterGripCanceledNotify(HandInput handInput, Action notify)
 {
     gripCanceledNotifies[(int)handInput].Add(notify);
 }
Esempio n. 17
0
 public void RegisterPrimaryButtonTriggeredNotifies(HandInput handInput, Action notify)
 {
     primaryButtonTriggeredNotifies[(int)handInput].Add(notify);
 }
Esempio n. 18
0
 /// <summary>
 /// Copy hand input content from another instance.
 /// </summary>
 /// <param name="hi">Source hand input instance</param>
 public void Copy(HandInput hi)
 {
     hi.content.CopyTo(content, 0);
 }
Esempio n. 19
0
 public void RegisterSecondaryButtonTouchedNotifies(HandInput handInput, Action notify)
 {
     secondaryButtonTouchedNotifies[(int)handInput].Add(notify);
 }
Esempio n. 20
0
    void TranslateHandPoseToInput(ref OvrAvatarDriver.HandPose handPose, ref OvrAvatarDriver.ControllerPose controllerPose, ref HandInput input)
    {
        input.handTrigger = handPose.gripFlex;

        input.previousIndexTrigger = input.indexTrigger;
        input.indexTrigger         = handPose.indexFlex;

        if (input.indexTrigger >= IndexThreshold && input.previousIndexTrigger < IndexThreshold)
        {
            input.indexPressFrame = context.GetRenderFrame();
        }

        input.pointing = true;

        input.x = controllerPose.button1IsDown;
        input.y = controllerPose.button2IsDown;

        input.stick = controllerPose.joystickPosition;
    }
Esempio n. 21
0
 public void UnregisterSecondaryButtonTriggeredNotifies(HandInput handInput, Action notify)
 {
     secondaryButtonTriggeredNotifies[(int)handInput].Remove(notify);
 }
Esempio n. 22
0
 public void UnregisterDevicePositionNotify(HandInput handInput, Action <Vector3> notify)
 {
     devicePositionNotifies[(int)handInput].Remove(notify);
 }
Esempio n. 23
0
 public void RegisterGripStrengthNotify(HandInput handInput, Action <float> notify)
 {
     gripStrengthNotifies[(int)handInput].Add(notify);
 }