protected virtual void UpdateVRNodeTracked() { if (QuickVRManager._handTrackingMode == QuickVRManager.HandTrackingMode.Hands) { Transform tObject = _vrNodeHand.GetTrackedObject().transform; tObject.localPosition = Vector3.zero; tObject.localRotation = Quaternion.identity; bool isTrackedPos = OVRPlugin.GetNodePositionTracked(_ovrNodeHand); if (isTrackedPos) { _vrNodeHand.transform.localPosition = OVRPlugin.GetNodePose(_ovrNodeHand, OVRPlugin.Step.Render).ToOVRPose().position; } bool isTrackedRot = OVRPlugin.GetNodeOrientationTracked(_ovrNodeHand); if (isTrackedRot) { _vrNodeHand.transform.localRotation = OVRPlugin.GetNodePose(_ovrNodeHand, OVRPlugin.Step.Render).ToOVRPose().orientation; if (IsLeft()) { tObject.LookAt(tObject.transform.position + _vrNodeHand.transform.right, -_vrNodeHand.transform.up); } else { tObject.LookAt(tObject.transform.position - _vrNodeHand.transform.right, _vrNodeHand.transform.up); } } //vrNode.SetTracked(isTrackedPos || isTrackedRot); _vrNodeHand.SetTracked(IsDataHighConfidence); UpdateVRNodeFingers(); } }
void Update() { OVRPose p = OVRPlugin.GetNodePose(OVRPlugin.Node.DeviceObjectZero, OVRPlugin.Step.Render).ToOVRPose(); if (OVRPlugin.GetNodePositionTracked(OVRPlugin.Node.DeviceObjectZero)) { this.transform.position = p.position + positionOffset; } if (OVRPlugin.GetNodeOrientationTracked(OVRPlugin.Node.DeviceObjectZero)) { this.transform.rotation = p.orientation * rotationOffset; } }
public bool GetDeviceTransformByRole_Oculus(DeviceRole role, out Vector3 position, out Quaternion rotation) { OVRPlugin.Node node; switch (role) { case DeviceRole.Head: node = OVRPlugin.Node.Head; break; case DeviceRole.LeftHand: node = OVRPlugin.Node.HandLeft; break; case DeviceRole.RightHand: node = OVRPlugin.Node.HandRight; break; default: position = Vector3.zero; rotation = Quaternion.identity; return(false); } if (OVRPlugin.GetNodePositionTracked(node) && OVRPlugin.GetNodeOrientationTracked(node)) { OVRPlugin.Posef pose = OVRPlugin.GetNodePose(node, OVRPlugin.Step.Render); position = new Vector3(pose.Position.x, pose.Position.y, pose.Position.z); rotation = new Quaternion(pose.Orientation.x, pose.Orientation.y, pose.Orientation.z, pose.Orientation.w); return(true); } else { position = Vector3.zero; rotation = Quaternion.identity; return(false); } }