コード例 #1
0
        public virtual Vector3 EmulatePosition(VRNode node)
        {
            switch (node)
            {
            case VRNode.LeftHand:
            case VRNode.RightHand:
                Vector3   pos             = m_HandPosition[(int)(node - VRNode.LeftHand)];
                Transform centerEyeAnchor = VRContext.GetAnchor(VRNode.CenterEye);
                if (centerEyeAnchor != null)
                {
                    Transform  trackingSpace = VRContext.GetAnchor(VRNode.TrackingSpace);
                    Quaternion bodyRotation  = Quaternion.Euler(new Vector3(0.0f, centerEyeAnchor.eulerAngles.y, 0.0f));
                    pos = centerEyeAnchor.position + bodyRotation * pos +
                          ((trackingSpace == null?Quaternion.identity:trackingSpace.rotation) * GetRotation((int)(node - VRNode.LeftHand))) *
                          (Vector3.forward * m_HandLength[(int)(node - VRNode.LeftHand)]);
                    // TODO :
                    if (trackingSpace != null)
                    {
                        pos = trackingSpace.InverseTransformPoint(pos);
                    }
                }
                else
                {
                    pos = pos + GetRotation((int)(node - VRNode.LeftHand)) * (Vector3.forward * m_HandLength[(int)(node - VRNode.LeftHand)]);
                }
                return(pos);

                break;

            case VRNode.LeftHand + 2:
                return(Vector3.up * (VRContext.trackingOrigin == TrackingOrigin.EyeLevel?0:                        // Keep zero.
                                     XDevicePlugin.GetFloat(m_Handle, XDevicePlugin.kField_TrackerHeight, 0.0f))); // From ground.

                break;

            default:
                return(Vector3.zero);

                break;
            }
        }