Пример #1
0
        protected virtual void OnCalibrateVRNodeFoot(QuickVRNode node)
        {
            Transform          ikTarget = GetIKSolver((HumanBodyBones)node.GetRole())._targetLimb;
            QuickTrackedObject tObject  = node.GetTrackedObject();

            tObject.transform.rotation = ikTarget.rotation;
        }
Пример #2
0
        protected virtual void UpdateVRNodeTracked()
        {
            if (QuickVRManager._handTrackingMode == QuickVRManager.HandTrackingMode.Hands)
            {
                Transform tObject = _vrNodeHand.GetTrackedObject().transform;
                tObject.localPosition = Vector3.zero;
                tObject.localRotation = Quaternion.identity;

                bool isTrackedPos = OVRPlugin.GetNodePositionTracked(_ovrNodeHand);
                if (isTrackedPos)
                {
                    _vrNodeHand.transform.localPosition = OVRPlugin.GetNodePose(_ovrNodeHand, OVRPlugin.Step.Render).ToOVRPose().position;
                }

                bool isTrackedRot = OVRPlugin.GetNodeOrientationTracked(_ovrNodeHand);
                if (isTrackedRot)
                {
                    _vrNodeHand.transform.localRotation = OVRPlugin.GetNodePose(_ovrNodeHand, OVRPlugin.Step.Render).ToOVRPose().orientation;

                    if (IsLeft())
                    {
                        tObject.LookAt(tObject.transform.position + _vrNodeHand.transform.right, -_vrNodeHand.transform.up);
                    }
                    else
                    {
                        tObject.LookAt(tObject.transform.position - _vrNodeHand.transform.right, _vrNodeHand.transform.up);
                    }
                }

                //vrNode.SetTracked(isTrackedPos || isTrackedRot);
                _vrNodeHand.SetTracked(IsDataHighConfidence);

                UpdateVRNodeFingers();
            }
        }
Пример #3
0
        protected virtual void OnCalibrateVRNodeHips(QuickVRNode node)
        {
            QuickTrackedObject tObjectHead = _vrPlayArea.GetVRNode(HumanBodyBones.Head).GetTrackedObject();
            QuickTrackedObject tObjectHips = node.GetTrackedObject();

            tObjectHips.transform.position = new Vector3(tObjectHead.transform.position.x, tObjectHips.transform.position.y, tObjectHead.transform.position.z);
        }
Пример #4
0
        protected virtual IEnumerator CoUpdate()
        {
            //Wait for the node of the head to be created.
            QuickUnityVR hTracking = GetComponent <QuickUnityVR>();
            QuickVRNode  nodeHead  = null;

            while (nodeHead == null)
            {
                nodeHead = _vrPlayArea.GetVRNode(HumanBodyBones.Head);
                yield return(null);
            }
            _trackedObject = nodeHead.GetTrackedObject();

            while (true)
            {
                //Debug.Log("disp = " + disp.ToString("f3"));

                CoUpdateTrackedNode();

                //Wait for a new sample
                yield return(StartCoroutine(CoUpdateSample()));

                CoUpdateTargetLinearVelocity();

                //Check the real displacement of the user in the room. If it is big enough, the contribution
                //of the WiP is ignored.
                Vector3 disp = Vector3.Scale(_headTracking.GetDisplacement(), Vector3.forward + Vector3.right);

                if (disp.magnitude > 0.005f)
                {
                    _rigidBody.velocity = Vector3.Scale(_rigidBody.velocity, Vector3.up);
                    Init();
                }
            }
        }
Пример #5
0
        protected virtual void OnDrawGizmos()
        {
            Gizmos.color = Color.green;
            foreach (var pair in _vrNodes)
            {
                QuickVRNode n = pair.Value;
                if (n.IsTracked())
                {
                    DebugExtension.DrawCoordinatesSystem(n.transform.position, n.transform.right, n.transform.up, n.transform.forward, 0.05f);

                    float   s     = 0.0125f;
                    Vector3 cSize = Vector3.one * s;

                    Gizmos.matrix = n.transform.localToWorldMatrix;
                    Gizmos.DrawCube(Vector3.zero, cSize);
                    QuickTrackedObject tObject = n.GetTrackedObject();
                    if (tObject.transform.localPosition != Vector3.zero)
                    {
                        Gizmos.DrawSphere(tObject.transform.localPosition, s * 0.5f);
                        Gizmos.DrawLine(Vector3.zero, tObject.transform.localPosition);
                    }
                    Gizmos.matrix = Matrix4x4.identity;
                }
            }
        }
Пример #6
0
        protected virtual void CoUpdateTrackedNode()
        {
            QuickVRNode hipsNode = _vrPlayArea.GetVRNode(HumanBodyBones.Hips);

            if (hipsNode)
            {
                QuickTrackedObject tObject = hipsNode.IsTracked()? hipsNode.GetTrackedObject() : _vrPlayArea.GetVRNode(HumanBodyBones.Head).GetTrackedObject();
                if (tObject != _trackedObject)
                {
                    _trackedObject = tObject;

                    Init();
                }
            }
        }
Пример #7
0
        public override void Calibrate()
        {
            base.Calibrate();

            transform.localScale = Vector3.one;

            _footprints.translationOffset  = Vector3.zero;
            _footprints.transform.rotation = transform.rotation;

            _vrPlayArea.Calibrate();

            float rotAngle = Vector3.SignedAngle(_vrPlayArea.GetUserForward(), transform.forward, transform.up);

            _vrPlayArea.transform.Rotate(transform.up, rotAngle, Space.World);

            //Set the offset of the TrackedObject of the head
            QuickVRNode node   = _vrPlayArea.GetVRNode(HumanBodyBones.Head);
            Vector3     offset = GetIKSolver(IKBone.Head)._targetLimb.position - node.GetTrackedObject().transform.position;

            _vrPlayArea.transform.position += offset;
        }
Пример #8
0
 protected virtual void UpdateIKTargetRotFromUser(QuickVRNode node, HumanBodyBones boneID)
 {
     GetIKSolver(boneID)._targetLimb.rotation = node.GetTrackedObject().transform.rotation;
 }
Пример #9
0
 protected virtual void OnCalibrateVRNodeHead(QuickVRNode node)
 {
     node.GetTrackedObject().transform.localPosition = _headOffset;
 }