Esempio n. 1
0
        public override Vector3 GetLocalPosition(int node)
        {
            Vector3 position = Vector3.zero;

            if (node == m_Controllers[2].value)
            {
                //
                if (useExperimental)
                {
                    //
                    UpdateState();
                    //
                    XDevicePlugin.GetSmoothPosition(2, ref position);
                    //
                    position.Scale(sensitivity);
                    if (m_UseAnchorProjection && anchor != null)
                    {
                        position = m_AnchorMatrix.MultiplyPoint3x4(position);
                    }
                }
                else
                {
                    position = base.GetLocalPosition(node);
                }
                //
                if (m_CenterEye == null)
                {
                    m_CenterEye = VRContext.GetAnchor(VRNode.CenterEye);
                    m_VRDevice  = VRContext.currentDevice;
                }
                if (m_CenterEye != null && m_VRDevice != null)
                {
                    Quaternion rotation = m_VRDevice.GetRotation();
                    //
                    if (useAutoRecenter)
                    {
                        rotation             = Quaternion.AngleAxis(m_YawOffset, Vector3.up) * rotation;
                        m_VRDevice.yawOffset = m_YawOffset;
                    }
                    else
                    {
                    }
                    //
                    position -= rotation * (m_VRDevice.neckToEye + m_VRDevice.outsideInMarkPose.position);
                }
            }
            else
            {
                //
                if (m_EnableEmulatedHand)
                {
                    if ((XDevicePlugin.GetNodePosition(m_Handle, 0, node, null) & TrackingResult.PositionTracked) == 0)
                    {
                        return(GetEmulatedHandPosition(node));
                    }
                }
                //
                if (useExperimental)
                {
                    //
                    UpdateState();
                    //
                    XDevicePlugin.GetSmoothPosition(node, ref position);
                    //
                    position.Scale(sensitivity);
                    if (m_UseAnchorProjection && anchor != null)
                    {
                        position = m_AnchorMatrix.MultiplyPoint3x4(position);
                    }
                }
                else
                {
                    position = base.GetLocalPosition(node);
                }
                //
            }
            return(position);
        }