示例#1
0
    public static Quaternion GetRotation(ViveHand hand)
    {
        GetInstance();

        if (!IsValid(hand))
        {
            return(Quaternion.identity);
        }

        var obj = hand == ViveHand.Left ? inst.leftObj : inst.rightObj;

        return(obj.transform.rotation);
    }
示例#2
0
    public static Vector3 GetPosition(ViveHand hand)
    {
        GetInstance();

        if (!IsValid(hand))
        {
            return(Vector3.zero);
        }

        var obj = hand == ViveHand.Left ? inst.leftObj : inst.rightObj;

        return(obj.transform.position);
    }
示例#3
0
    public static Vector3 GetAngularVelocity(ViveHand hand)
    {
        GetInstance();

        if (!IsValid(hand))
        {
            return(Vector3.zero);
        }

        var dev = hand == ViveHand.Left ? inst.leftDevice : inst.rightDevice;

        return(dev.angularVelocity);
    }
示例#4
0
    public static Vector2 GetTouchPoint(ViveHand hand)
    {
        GetInstance();

        if (!IsValid(hand))
        {
            return(Vector2.zero);
        }

        var dev = hand == ViveHand.Left ? inst.leftDevice : inst.rightDevice;

        return(dev.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad));
    }
示例#5
0
    public static float GetTriggerValue(ViveHand hand)
    {
        GetInstance();

        if (!IsValid(hand))
        {
            return(0f);
        }

        var dev = hand == ViveHand.Left ? inst.leftDevice : inst.rightDevice;

        return(dev.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger).x);
    }
示例#6
0
    public static bool GetButtonUp(ViveHand hand, ViveButton button)
    {
        GetInstance();

        if (!IsValid(hand))
        {
            return(false);
        }

        var dev = hand == ViveHand.Left ? inst.leftDevice : inst.rightDevice;

        return(dev.GetPressUp((ulong)button));
    }
示例#7
0
    public static Transform GetTransform(ViveHand hand)
    {
        GetInstance();

        if (!IsValid(hand))
        {
            return(inst.transform);
        }

        var obj = hand == ViveHand.Left ? inst.leftObj : inst.rightObj;

        return(obj.transform);
    }
示例#8
0
    public static void Vibrate(ViveHand hand, float strength, float duration)
    {
        GetInstance();

        if (!IsValid(hand))
        {
            return;
        }

        var dev = hand == ViveHand.Left ? inst.leftDevice : inst.rightDevice;

        inst.StartCoroutine(VibrationCoroutine(dev, (ushort)(strength * 3999), duration));
        //dev.TriggerHapticPulse((ushort)(strength * 3999));
    }
示例#9
0
 public override void StopInteract(ViveHand hand)
 {
     if (fj = hand.GetComponent <FixedJoint>())
     {
         objectToGrab.isKinematic = prevKinematicValue;
         if (objectToGrab.useGravity)
         {
             objectToGrab.velocity        = hand.Velocity();
             objectToGrab.angularVelocity = hand.AngularVelocity();
         }
         fj.connectedBody = null;
         Destroy(fj);
     }
     interacted = false;
     hand.UnmakeBusy();
 }
示例#10
0
 private void UpdateHandPosition(ViveHand hand)
 {
     if (body)
     {
         handX = body.transform.InverseTransformPoint(hand.transform.position).x;
         handY = body.transform.InverseTransformPoint(hand.transform.position).y;
     }
     else
     {
         if (!debugDisplayed)
         {
             Debug.Log("No SliderBody was registered on slider " + name + "!");
             debugDisplayed = true;
         }
     }
 }
示例#11
0
    public override void StartInteract(ViveHand hand)
    {
        if (objectToGrab)
        {
            fj               = hand.gameObject.AddComponent <FixedJoint>();
            fj.breakForce    = 20000;
            fj.breakTorque   = 20000;
            fj.connectedBody = objectToGrab;

            prevKinematicValue       = objectToGrab.isKinematic;
            objectToGrab.isKinematic = false;

            interacted = true;

            hand.MakeBusy();
        }
    }
示例#12
0
    public static bool IsValid(ViveHand hand)
    {
        GetInstance();

        if (hand == ViveHand.Unknown)
        {
            return(false);
        }

        var dev = hand == ViveHand.Left ? inst.leftDevice : inst.rightDevice;

        if (dev == null)
        {
            return(false);
        }

        return(dev.valid);
    }
示例#13
0
 public override void StopInteract(ViveHand hand)
 {
     interacted = false;
     grabbingHand = null;
     pressed = false;
 }
示例#14
0
 public abstract void StartInteractDelayed(ViveHand hand);
示例#15
0
 public override void StopInteract(ViveHand hand)
 {
     interacted = false;
     Unpress();
 }
示例#16
0
 // Use this for initialization
 void Start()
 {
     hand = ViveInput.GetHand(gameObject.transform.parent.parent.gameObject);
     line = GetComponent <LineRenderer>();
 }
示例#17
0
 public override void StartInteract(ViveHand hand)
 {
     interacted = true;
     Press();
 }
示例#18
0
 public override void StartInteractDelayed(ViveHand hand)
 {
 }
示例#19
0
 // Use this for initialization
 void Start()
 {
     hand = ViveInput.GetHand(gameObject);
     cols = new Collider[10];
 }
示例#20
0
 public override void StartInteract(ViveHand hand)
 {
     interacted = true;
     grabbingHand = hand;
     pressed = true;
 }
示例#21
0
 public abstract void StopInteract(ViveHand hand);