Ejemplo n.º 1
0
        private void AllignWrist(HandData handData, float offset)
        {
            Debug.Log("Calibrated a hand.");
            WristTransform.rotation = handData.GetWristRotation(DeviceType);

            HandData.TrackingValues.HandYawOffset[DeviceType] = offset;
        }
Ejemplo n.º 2
0
        // Use this for initialization
        public virtual void Awake()
        {
            if (HandData == null)
            {
                HandData = Component.FindObjectOfType <HandData>();
            }
            if (HandData == null)
            {
                Debug.Log("HandManager must have HandData");
            }

            StartCoroutine(InitializeHand(device_type_t.GLOVE_LEFT));
            StartCoroutine(InitializeHand(device_type_t.GLOVE_RIGHT));

            // Show the created hands as public variable
            Hands = _hands.Values.ToList();

            // Parent the ManusVR prefab to the SteamVR prefab
            if (!_cameraRig)
            {
                if (Camera.main != null)
                {
                    _cameraRig = Camera.main.transform.root;
                }
                Debug.LogWarning("CameraRig reference not set, automatically retrieved root transform of main camera. To avoid usage of wrong transform, consider setting this reference.");
            }
            transform.root.parent = _cameraRig;
        }
Ejemplo n.º 3
0
        public virtual void FixedUpdate()
        {
            int debugFrameCounter = Time.frameCount;

            if (HandManager.ApplyWristRotation)
            {
                RotateWrist();
            }
            if (HandManager.ApplyThumbRotation)
            {
                RotateThumb();
            }

            MoveWrist();

            //Only update fingers if data has been received
            if (!HandData.HasReceivedData(DeviceType == device_type_t.GLOVE_LEFT
                ? GloveLaterality.GLOVE_LEFT
                : GloveLaterality.GLOVE_RIGHT))
            {
                return;
            }
            foreach (var finger in FingerControllers)
            {
                for (int i = 1; i <= 3; i++)
                {
                    finger.Value.RotatePhalange(i, HandData.GetFingerRotation(finger.Key, DeviceType, i));
                }
            }
        }
Ejemplo n.º 4
0
        public virtual void FixedUpdate()
        {
            if (HandManager.ApplyWristRotation)
            {
                RotateWrist();
            }
            if (HandManager.ApplyThumbRotation)
            {
                RotateThumb();
            }

            MoveWrist();

            if (!HandData.ValidOutput(DeviceType))
            {
                return;
            }
            foreach (var finger in FingerControllers)
            {
                for (int i = 1; i <= 3; i++)
                {
                    finger.Value.RotatePhalange(i, HandData.GetFingerRotation(finger.Key, DeviceType, i));
                }
            }
        }
Ejemplo n.º 5
0
        public virtual Quaternion ThumbRotation()
        {
            var thumbRotation = HandData.ValidOutput(DeviceType)
                ? HandManager.HandData.GetThumbRotation(DeviceType)
                : _lastThumbRotation;

            _lastThumbRotation = thumbRotation;
            return(Quaternion.Euler(0.0f, HandData.TrackingValues.HandYawOffset[DeviceType], 0.0f) * thumbRotation);
        }
Ejemplo n.º 6
0
        protected virtual Quaternion ThumbRotation()
        {
            var thumbRotation = HandData.ValidOutput(DeviceType)
                ? HandManager.HandData.GetThumbRotation(DeviceType)
                : _lastThumbRotation;

            _lastThumbRotation = thumbRotation;
            return(thumbRotation);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Tell the wrist to rotate to a given rotation
 /// </summary>
 protected virtual void RotateWrist()
 {
     Wrist.RotateWrist(HandData.CalibratedWristRotation(DeviceType));
 }