コード例 #1
0
        public static bool Update(this MotionControllerInfo currentController, InteractionSourceState sourceState,
                                  InteractionSourceNode nodeType, bool updatePosition = true, bool updateRotation = false)
        {
            Vector3 newPosition;
            bool    retValPosition = false, retValRotation = false;

            if (updatePosition && (retValPosition = sourceState.sourcePose.TryGetPosition(out newPosition, nodeType)))
            {
#if DEBUG
                if (newPosition.IsDebugValid())
#endif
                {
                    currentController.ControllerParent.transform.localPosition = newPosition;
                }
#if DEBUG
                else
                {
                    Debug.Log("Skipping newPosition:" + newPosition.ToString());
                }
#endif
            }
            Quaternion newRotation;
            if (updateRotation && (retValRotation = sourceState.sourcePose.TryGetRotation(out newRotation, nodeType)))
            {
                currentController.ControllerParent.transform.localRotation = newRotation;
            }

            // TraceHelper.Log(string.Format("{0}:Pos{1},Rot{2}", nodeType, newPosition, newRotation));
            // TraceHelper.Assert( retValPosition && retValRotation, "Update should not fail");
            return(retValRotation && retValPosition);
        }
コード例 #2
0
        public bool TryGetUp(out Vector3 up, InteractionSourceNode node = InteractionSourceNode.Grip)
        {
            Quaternion rotation;
            bool       ret = TryGetRotation(out rotation, node);

            up = rotation * Vector3.up;
            return(ret);
        }
コード例 #3
0
        public bool TryGetRight(out Vector3 right, InteractionSourceNode node = InteractionSourceNode.Grip)
        {
            Quaternion rotation;
            bool       ret = TryGetRotation(out rotation, node);

            right = rotation * Vector3.right;
            return(ret);
        }
コード例 #4
0
        public bool TryGetForward(out Vector3 forward, InteractionSourceNode node = InteractionSourceNode.Grip)
        {
            Quaternion rotation;
            bool       ret = TryGetRotation(out rotation, node);

            forward = rotation * Vector3.forward;
            return(ret);
        }
コード例 #5
0
 public bool TryGetRotation(out Quaternion rotation, InteractionSourceNode node = InteractionSourceNode.Grip)
 {
     if (node == InteractionSourceNode.Grip)
     {
         rotation = m_GripRotation;
         return((m_Flags & InteractionSourcePoseFlags.HasGripRotation) != 0);
     }
     else
     {
         rotation = m_PointerRotation;
         return((m_Flags & InteractionSourcePoseFlags.HasPointerRotation) != 0);
     }
 }
コード例 #6
0
 public bool TryGetPosition(out Vector3 position, InteractionSourceNode node)
 {
     if (node == InteractionSourceNode.Grip)
     {
         position = m_GripPosition;
         return((m_Flags & InteractionSourcePoseFlags.HasGripPosition) != 0);
     }
     else
     {
         position = m_PointerPosition;
         return((m_Flags & InteractionSourcePoseFlags.HasPointerPosition) != 0);
     }
 }
コード例 #7
0
        public bool TryGetRotation(out Quaternion rotation, InteractionSourceNode node = InteractionSourceNode.Grip)
        {
            bool result;

            if (node == InteractionSourceNode.Grip)
            {
                rotation = this.m_GripRotation;
                result   = ((this.m_Flags & InteractionSourcePoseFlags.HasGripRotation) != InteractionSourcePoseFlags.None);
            }
            else
            {
                rotation = this.m_PointerRotation;
                result   = ((this.m_Flags & InteractionSourcePoseFlags.HasPointerRotation) != InteractionSourcePoseFlags.None);
            }
            return(result);
        }
コード例 #8
0
        public bool TryGetPosition(out Vector3 position, InteractionSourceNode node)
        {
            bool result;

            if (node == InteractionSourceNode.Grip)
            {
                position = this.m_GripPosition;
                result   = ((this.m_Flags & InteractionSourcePoseFlags.HasGripPosition) != InteractionSourcePoseFlags.None);
            }
            else
            {
                position = this.m_PointerPosition;
                result   = ((this.m_Flags & InteractionSourcePoseFlags.HasPointerPosition) != InteractionSourcePoseFlags.None);
            }
            return(result);
        }