Last active
February 10, 2018 04:18
-
-
Save Kailang/366e45d2ddf835087638176858877593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.XR; | |
public class TestK : MonoBehaviour { | |
public Transform headTrans, lHandTrans, rHandTrans; | |
void OnDrawGizmosSelected() { | |
if (OVRManager.tracker == null) return; | |
OVRPose tracker = OVRManager.tracker.GetPose(); | |
var trackerAnchorLocalPosition = tracker.position; | |
var trackerAnchorLocalRotation = tracker.orientation; | |
DrawAnchor (trackerAnchorLocalPosition, trackerAnchorLocalRotation); | |
var centerEyeAnchorLocalPosition = InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye); | |
var centerEyeAnchorLocalRotation = InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye); | |
DrawAnchor (centerEyeAnchorLocalPosition, centerEyeAnchorLocalRotation); | |
headTrans.localPosition = centerEyeAnchorLocalPosition; | |
headTrans.localRotation = centerEyeAnchorLocalRotation; | |
var leftEyeAnchorLocalPosition = InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftEye); | |
var leftEyeAnchorLocalRotation = InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.LeftEye); | |
var rightEyeAnchorLocalPosition = InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.RightEye); | |
var rightEyeAnchorLocalRotation = InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.RightEye); | |
var leftHandAnchorLocalPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch); | |
var leftHandAnchorLocalRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch); | |
DrawAnchor (leftHandAnchorLocalPosition, leftHandAnchorLocalRotation); | |
lHandTrans.localPosition = leftHandAnchorLocalPosition; | |
lHandTrans.localRotation = leftHandAnchorLocalRotation; | |
var leftHandIndexTriggerTouch = OVRInput.Get(OVRInput.RawTouch.LIndexTrigger | |
var rightHandAnchorLocalPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch); | |
var rightHandAnchorLocalRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch); | |
DrawAnchor (rightHandAnchorLocalPosition, rightHandAnchorLocalRotation); | |
rHandTrans.localPosition = rightHandAnchorLocalPosition; | |
rHandTrans.localRotation = rightHandAnchorLocalRotation; | |
} | |
void DrawAnchor(Vector3 position, Quaternion rotation) { | |
Gizmos.color = Color.green; | |
Gizmos.DrawWireSphere (position, 0.1f); | |
Gizmos.color = Color.red; | |
Gizmos.DrawRay (position, rotation * Vector3.forward * 0.5f); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment