void Start() { XRDevice.DisableAutoXRCameraTracking(target, true); InputTracking.disablePositionalTracking = true; XRDevice.DisableAutoXRCameraTracking(target, true); Vector3 pos = InputTracking.GetLocalPosition(XRNode.CenterEye); this.transform.position -= pos; }
/// <summary> /// Compute the delayed position and rotation from the history stored in the poseData dictionary. /// </summary> /// <param name="keyindex"></param> /// <param name="timeDelay"></param> /// <returns></returns> private sl.Pose GetValuePosition(int keyindex, float timeDelay) { sl.Pose p = new sl.Pose(); if (poseData.ContainsKey(keyindex)) { //Get the saved position & rotation. p.translation = poseData[keyindex][poseData[keyindex].Count - 1].position; p.rotation = poseData[keyindex][poseData[keyindex].Count - 1].rotation; float idealTS = (Time.time - timeDelay); for (int i = 0; i < poseData[keyindex].Count; ++i) { if (poseData[keyindex][i].timestamp > idealTS) { int currentIndex = i; if (currentIndex > 0) { //Calculate the time between the pose and the delayed pose. float timeBetween = poseData[keyindex][currentIndex].timestamp - poseData[keyindex][currentIndex - 1].timestamp; float alpha = ((Time.time - poseData[keyindex][currentIndex - 1].timestamp) - timeDelay) / timeBetween; //Lerp to the next position based on the time determined above. Vector3 pos = Vector3.Lerp(poseData[keyindex][currentIndex - 1].position, poseData[keyindex][currentIndex].position, alpha); Quaternion rot = Quaternion.Lerp(poseData[keyindex][currentIndex - 1].rotation, poseData[keyindex][currentIndex].rotation, alpha); //Apply new values. p = new sl.Pose(); p.translation = pos; p.rotation = rot; //Add drift correction, but only if the user hasn't disabled it, it's on an actual controller, and the zedRigRoot position won't be affected. if (correctControllerDrift == true && (deviceToTrack == Devices.LeftController || deviceToTrack == Devices.RightController) && (zedManager != null && zedManager.IsStereoRig == true && !zedManager.transform.IsChildOf(transform))) { //Compensate for positional drift by measuring the distance between HMD and ZED rig root (the head's center). #if UNITY_2019_3_OR_NEWER InputDevice head = InputDevices.GetDeviceAtXRNode(XRNode.Head); head.TryGetFeatureValue(CommonUsages.devicePosition, out Vector3 zedhmdposoffset); #else Vector3 zedhmdposoffset = zedRigRoot.position - InputTracking.GetLocalPosition(XRNode.Head); #endif p.translation += zedhmdposoffset; } //Removes used elements from the dictionary. poseData[keyindex].RemoveRange(0, currentIndex - 1); } return(p); } } } return(p); }
void OnTriggerStay(Collider other) { if (other.gameObject.tag == "Grabbable") { if (Input.GetButton("Grab")) { print(InputTracking.GetLocalPosition(NodeType)); other.transform.position = gameObject.transform.position; } } }
private Vector3 GetWorldEyePos(Camera cam, XRNode eye) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Vector3 localPosition = InputTracking.GetLocalPosition(eye); return(parentTransform.MultiplyPoint3x4(localPosition)); }
// Update is called once per frame void Update() { #if UNITY_5_5_OR_NEWER wand1_position = InputTracking.GetLocalPosition(VRNode.LeftHand); wand1_rotation = InputTracking.GetLocalRotation(VRNode.LeftHand); wand2_position = InputTracking.GetLocalPosition(VRNode.RightHand); wand2_rotation = InputTracking.GetLocalRotation(VRNode.RightHand); #endif ProcessVRInput(); }
private void Update() { if (VRDevice.isPresent) { transform.localPosition = InputTracking.GetLocalPosition(node); transform.localRotation = InputTracking.GetLocalRotation(node); System.Collections.Generic.List <VRNodeState> nodeStates = new System.Collections.Generic.List <VRNodeState>(); InputTracking.GetNodeStates(nodeStates); } }
void Update() { if (Input.GetKey("joystick button 4")) { print("ok"); } Vector3 leftPosition = InputTracking.GetLocalPosition(XRNode.LeftHand); Quaternion leftRotation = InputTracking.GetLocalRotation(XRNode.LeftHand); print(leftPosition); }
// Update is called once per frame void Update() { if (Input.GetKeyDown("joystick button 8")) { Manager.Instance.speed += Input.GetAxis("Vertical"); } float speed = Manager.Instance.speed; transform.position = Vector3.Scale(InputTracking.GetLocalPosition(VRNode.Head), new Vector3(speed, 0, speed)); }
private void ModifyDiffPosOfCam() { if (!isActivated) { return; } // modify position of the camera of vive Vector3 trackedLocalCamPos = InputTracking.GetLocalPosition(XRNode.CenterEye); cameraPiv.transform.position = transform.TransformPoint(-trackedLocalCamPos); }
private void Update() { //playerSpace.transform.localPosition = InputTracking.GetLocalPosition (XRNode.TrackingReference); //playerSpace.transform.localRotation = InputTracking.GetLocalRotation (XRNode.TrackingReference); leftHand.transform.localPosition = InputTracking.GetLocalPosition(XRNode.LeftHand); leftHand.transform.localRotation = InputTracking.GetLocalRotation(XRNode.LeftHand); rightHand.transform.localPosition = InputTracking.GetLocalPosition(XRNode.RightHand); rightHand.transform.localRotation = InputTracking.GetLocalRotation(XRNode.RightHand); }
// Update is called once per frame void Update() { m_cameraPositions[0] = transform.parent.TransformPoint(InputTracking.GetLocalPosition(VRNode.LeftEye)); m_cameraPositions[1] = transform.parent.TransformPoint(InputTracking.GetLocalPosition(VRNode.RightEye)); Ray ray1 = new Ray(m_cameraPositions[0], transform.forward * 20); Ray ray2 = new Ray(m_cameraPositions[1], transform.forward * 20); Debug.DrawRay(m_cameraPositions[0], ray1.direction * 20, Color.red); Debug.DrawRay(m_cameraPositions[1], ray2.direction * 20, Color.red); }
void Update() { // InputTracking 은 디바이스 식별자를 주면 자동으로 추적해주는 함수가 있음 // 예) InputTracking.GetLocalPosition(XRNode.LeftEye) 는 왼쪽 눈을 트래킹 // 나의 위치와 회전을 추적 하는 부위(기기)의 위치와 회전으로 설정 transform.localPosition = InputTracking.GetLocalPosition(trackingNode); transform.localRotation = InputTracking.GetLocalRotation(trackingNode); }
// called before performing any physics calculations void FixedUpdate() { currentRotation = InputTracking.GetLocalRotation(XRNode.Head); currentPosition = InputTracking.GetLocalPosition(XRNode.Head); if (firstBuild) { //this.zero(); //this.calibrate(); firstBuild = false; } }
// Token: 0x0600448A RID: 17546 RVA: 0x0016E474 File Offset: 0x0016C874 private void UpdateNativeVRTransforms() { if (this.useNativeVRSupport && this.usedThirdPersonPlayerEyeCenter == null) { this.playerEyeCenterXform.localPosition = InputTracking.GetLocalPosition(VRNode.CenterEye); this.playerLeftEyeXform.localPosition = InputTracking.GetLocalPosition(VRNode.LeftEye); this.playerRightEyeXform.localPosition = InputTracking.GetLocalPosition(VRNode.RightEye); this.playerEyeCenterXform.localRotation = InputTracking.GetLocalRotation(VRNode.CenterEye); this.playerLeftEyeXform.localRotation = InputTracking.GetLocalRotation(VRNode.LeftEye); this.playerRightEyeXform.localRotation = InputTracking.GetLocalRotation(VRNode.RightEye); } }
// Update is called once per frame void Update() { // if (playX != 0 && playZ != 0){ // transform.rotation = new Quaternion(InputTracking.GetLocalPosition(XRNode.Head).z/playZ,0,InputTracking.GetLocalPosition(XRNode.Head).x/playX,0); // } transform.up = InputTracking.GetLocalPosition(XRNode.Head) - planet.position; print(playX); print(playZ); }
// Returns the offset position of the camera private Vector3 TargetsCameraPosition() { float eyeDistance = (InputTracking.GetLocalPosition(VRNode.LeftEye) - InputTracking.GetLocalPosition(VRNode.RightEye)).magnitude * 0.5f; Vector3 offset = Vector3.right * eyeDistance; if (handedness == Handedness.Left) { offset = -offset; } return(cam.position + cam.rotation * offset); }
protected void LateUpdate() { if (forceCustomUpdate) { ManuallyUpdateTemporalWarping(); } else if (VRSettings.enabled) { updateTemporalWarping(InputTracking.GetLocalPosition(VRNode.CenterEye), InputTracking.GetLocalRotation(VRNode.CenterEye)); } }
void Start() { // Make the rigid body not change rotation if (GetComponent <Rigidbody>()) { GetComponent <Rigidbody>().freezeRotation = true; } originalRotation = transform.localRotation; originalVRRotation = InputTracking.GetLocalRotation(VRNode.Head); basePos = this.transform.localPosition; baseOffset = InputTracking.GetLocalPosition(VRNode.Head); }
public void rayCastText() { oclpos = InputTracking.GetLocalPosition(VRNode.CenterEye); Ray ray = new Ray(oclpos, transform.forward); RaycastHit getObj; if (Physics.Raycast(ray, out getObj, 100.0f, mask)) { Debug.Log(getObj.collider.name); } }
void Update() { // Use Unity XR Input when enabled. When using WebVR, updates are performed onControllerUpdate. if (XRDevice.isPresent) { SetVisible(true); if (this.hand == WebVRControllerHand.LEFT) { handNode = XRNode.LeftHand; } if (this.hand == WebVRControllerHand.RIGHT) { handNode = XRNode.RightHand; } if (this.simulate3dof) { transform.position = this.applyArmModel( InputTracking.GetLocalPosition(XRNode.Head), // we use head position as origin InputTracking.GetLocalRotation(handNode), InputTracking.GetLocalRotation(XRNode.Head) ); transform.rotation = InputTracking.GetLocalRotation(handNode); } else { lastPosition = transform.position; transform.localPosition = InputTracking.GetLocalPosition(handNode); transform.localRotation = InputTracking.GetLocalRotation(handNode); velocity.Update((transform.position - lastPosition) / Time.deltaTime); } foreach (WebVRControllerInput input in inputMap.inputs) { if (!input.unityInputIsButton) { if (Input.GetAxis(input.unityInputName) != 0) { SetButtonState(input.actionName, true, Input.GetAxis(input.unityInputName)); } if (Input.GetAxis(input.unityInputName) < 1) { SetButtonState(input.actionName, false, Input.GetAxis(input.unityInputName)); } } } } }
private static PosRot GetXRNodeWorldPosRot(XRNode node) { var pos = InputTracking.GetLocalPosition(node); var rot = InputTracking.GetLocalRotation(node); var roomCenter = BeatSaberUtil.GetRoomCenter(); var roomRotation = BeatSaberUtil.GetRoomRotation(); pos = roomRotation * pos; pos += roomCenter; rot = roomRotation * rot; return(new PosRot(pos, rot)); }
// Update is called once per frame void Update() { TargetHandLeft.transform.position = InputTracking.GetLocalPosition(XRNode.LeftHand); TargetHandRight.transform.position = InputTracking.GetLocalPosition(XRNode.RightHand); Vector3 m = InputTracking.GetLocalPosition(XRNode.Head); Master.transform.position = new Vector3(m.x, 0, m.z); TargetHandLeft.transform.Translate(0, 0, 2, Space.World); TargetHandRight.transform.Translate(0, 0, 2, Space.World); Master.transform.Translate(0, 0, 2, Space.World); }
public Pose GetDevicePose() { var node = XRNode.RightHand; if (StylusHand == Handedness.NonDominant) { node = XRNode.LeftHand; } return(new Pose( InputTracking.GetLocalPosition(node), InputTracking.GetLocalRotation(node) )); }
private void DefaultUpdate() { transform.localPosition = InputTracking.GetLocalPosition(node); transform.localRotation = InputTracking.GetLocalRotation(node); if (_transformOffset != null) { _platformHelper.AdjustPlatformSpecificControllerTransform(node, transform, _transformOffset.positionOffset, _transformOffset.rotationOffset); } else { _platformHelper.AdjustPlatformSpecificControllerTransform(node, transform, Vector3.zero, Vector3.zero); } }
//private LSLOutlet marker; // Use this for initialization void Start() { //marker = FindObjectOfType<LSLMarkerStream>(); LSLTransformOutlet lslTransformOutlet = GetComponent <LSLTransformOutlet>(); startTimeInMilliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; watch = Stopwatch.StartNew(); headVector = InputTracking.GetLocalPosition(XRNode.Head); leftControllerVector = InputTracking.GetLocalPosition(XRNode.LeftHand); rightControllerVector = InputTracking.GetLocalPosition(XRNode.RightHand); print("Starting time:" + startTimeInMilliseconds); }
void Update() { // Read the mouse input axis rotationX += Input.GetAxis("Mouse X") * sensitivityX; rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationX = ClampAngle(rotationX, minimumX, maximumX); rotationY = ClampAngle(rotationY, minimumY, maximumY); Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up); Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, -Vector3.right); transform.localRotation = originalRotation * xQuaternion * yQuaternion * VRRotation(); gameObject.transform.localPosition = basePos - Vector3.ClampMagnitude(InputTracking.GetLocalPosition(VRNode.Head) - baseOffset, maxVrOffset); }
private (Vector3, Quaternion) GetXRNodePosRos(XRNode node) { var pos = InputTracking.GetLocalPosition(node); var rot = InputTracking.GetLocalRotation(node); var roomCenter = mainSettingsModel.roomCenter; var roomRotation = Quaternion.Euler(0, mainSettingsModel.roomRotation, 0); pos = roomRotation * pos; pos += roomCenter; rot = roomRotation * rot; return(pos, rot); }
public void Awake() { mAnim.SetInteger("AttackMode", 1); mDir = InputTracking.GetLocalPosition(VRNode.CenterEye); mDelig._AttackHandler += mDelig.getDamage; mAnim.SetBool("isDead", false); mAnim.SetBool("Left", false); mAnim.SetBool("Right", false); mAnim.SetBool("guard", false); HP = 200; }
protected override void GenerateCurrentStatus() { //Position and Rotation cPos = InputTracking.GetLocalPosition(node); cRot = InputTracking.GetLocalRotation(node); //Buttons cGripAxis = Input.GetAxis((hand == XRHand.Left ? "L" : "R") + "Grip"); cTriggerAxis = Input.GetAxis((hand == XRHand.Left ? "L" : "R") + "Trigger"); string handLabel = this.hand == XRHand.Left ? "L" : "R"; cThumbstickAxis = new Vector2(Input.GetAxis(handLabel + "ThumbstickX"), Input.GetAxis(handLabel + "ThumbstickY"));; cTouchpadAxis = Vector2.zero; }
public void Update() { if (adaptiveResolution) { //Calculate current velocity factor (apply minimal smoothing) Vector3 currentEyePosition = InputTracking.GetLocalPosition(XRNode.LeftEye); velocity3D = (0.02f * velocity3D) + (0.98f * Vector3.Distance(currentEyePosition, lastEyePosition)); lastEyePosition = currentEyePosition; var velocityDivisor = Mathf.Clamp(Mathf.RoundToInt(velocity3D * 100), 1, 4); var distanceDivisor = Mathf.Clamp(Mathf.RoundToInt(currentEyePosition.magnitude / 2), 1, 5); resolutionDivisor = (uint)(velocityDivisor * distanceDivisor); } }