示例#1
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);
        }
示例#2
0
        protected virtual void OnCalibrateVRNodeFoot(QuickVRNode node)
        {
            Transform          ikTarget = GetIKSolver((HumanBodyBones)node.GetRole())._targetLimb;
            QuickTrackedObject tObject  = node.GetTrackedObject();

            tObject.transform.rotation = ikTarget.rotation;
        }
示例#3
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();
                }
            }
        }
示例#4
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;
                }
            }
        }
示例#5
0
        protected virtual IEnumerator CoUpdate()
        {
            _trackedObject = _vrPlayArea.GetVRNode(HumanBodyBones.Head).GetTrackedObject();

            while (true)
            {
                CoUpdateTrackedNode();

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

                CoUpdateTargetLinearVelocity();
            }
        }
示例#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
 protected virtual void Awake()
 {
     _trackedObject = transform.CreateChild("__TrackedObject__").gameObject.GetOrCreateComponent <QuickTrackedObject>();
 }