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); }
public bool TryGetUp(out Vector3 up, InteractionSourceNode node = InteractionSourceNode.Grip) { Quaternion rotation; bool ret = TryGetRotation(out rotation, node); up = rotation * Vector3.up; return(ret); }
public bool TryGetRight(out Vector3 right, InteractionSourceNode node = InteractionSourceNode.Grip) { Quaternion rotation; bool ret = TryGetRotation(out rotation, node); right = rotation * Vector3.right; return(ret); }
public bool TryGetForward(out Vector3 forward, InteractionSourceNode node = InteractionSourceNode.Grip) { Quaternion rotation; bool ret = TryGetRotation(out rotation, node); forward = rotation * Vector3.forward; return(ret); }
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); } }
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); } }
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); }
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); }