/// <summary> /// <para>The current position of the requested VRNode.</para> /// </summary> /// <param name="node">Node index.</param> /// <returns> /// <para>Position of node local to its tracking space.</para> /// </returns> public static Vector3 GetLocalPosition(VRNode node) { Vector3 vector; INTERNAL_CALL_GetLocalPosition(node, out vector); return(vector); }
// Token: 0x060037B7 RID: 14263 RVA: 0x0011C1F4 File Offset: 0x0011A5F4 private Transform ConfigureEyeAnchor(Transform root, VRNode eye) { string str = (eye != VRNode.CenterEye) ? ((eye != VRNode.LeftEye) ? "Right" : "Left") : "Center"; string text = str + this.eyeAnchorName; Transform transform = base.transform.Find(root.name + "/" + text); if (transform == null) { transform = base.transform.Find(text); } if (transform == null) { string name = this.legacyEyeAnchorName + eye.ToString(); transform = base.transform.Find(name); } if (transform == null) { transform = new GameObject(text).transform; } transform.name = text; transform.parent = root; transform.localScale = Vector3.one; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; return(transform); }
/// <summary> /// <para>The current rotation of the requested VRNode.</para> /// </summary> /// <param name="node">Node index.</param> /// <returns> /// <para>Rotation of node local to its tracking space.</para> /// </returns> public static Quaternion GetLocalRotation(VRNode node) { Quaternion quaternion; INTERNAL_CALL_GetLocalRotation(node, out quaternion); return(quaternion); }
public static Vector3 GetLocalPosition(VRNode node) { Vector3 result; InputTracking.INTERNAL_CALL_GetLocalPosition(node, out result); return(result); }
/// <summary> /// <para>The current position of the requested VRNode.</para> /// </summary> /// <param name="node">Node index.</param> /// <returns> /// <para>Position of node local to its tracking space.</para> /// </returns> public static Vector3 GetLocalPosition(VRNode node) { Vector3 vector3; InputTracking.INTERNAL_CALL_GetLocalPosition(node, out vector3); return(vector3); }
/// <summary> /// /// </summary> public virtual void SetAnchor(VRNode node, Transform value, bool canAdd) { int i = 0, imax = m_Anchors.Length; for (; i < imax; ++i) { if (m_Anchors[i].key == node) { m_Anchors[i].value = value; return; } } // if (canAdd) { NodeTransformPair[] newAnchors = new NodeTransformPair[imax + 1]; i = imax; while (i-- > 0) { newAnchors[i] = m_Anchors[i]; } newAnchors[imax] = new NodeTransformPair { key = node, value = value }; m_Anchors = newAnchors; } }
public static Quaternion GetLocalRotation(VRNode node) { Quaternion result; InputTracking.INTERNAL_CALL_GetLocalRotation(node, out result); return(result); }
/// <summary> /// /// </summary> public static void SetAnchor(VRNode node, Transform value) { if (main == null) { return; } main.SetAnchor(node, value, true); }
// Token: 0x060038ED RID: 14573 RVA: 0x001223FC File Offset: 0x001207FC public void OverrideOverlayTextureInfo(Texture srcTexture, IntPtr nativePtr, VRNode node) { int num = (node != VRNode.RightEye) ? 0 : 1; this.textures[num] = srcTexture; this.cachedTextures[num] = srcTexture; this.texNativePtrs[num] = nativePtr; }
public static Quaternion GetLocalRotation(VRNode node) { if (node != VRNode.Head) { Debug.LogError("GetLocalRotation for other than head"); } return(instance.transform.localRotation); }
/// <summary> /// /// </summary> public static Transform GetAnchor(VRNode node) { if (main == null) { return(null); } return(main.GetAnchor(node, null)); }
private void ConfigureCamera(GameObject node, VRNode eye, HMD_Config hmdConfig) { // adjust camera X-positions based on IPD float xDir = 0; if (eye == VRNode.LeftEye) { xDir = -1; } else if (eye == VRNode.RightEye) { xDir = +1; } // shift camera sideways considering any offset orientation node.transform.localPosition = (node.transform.localRotation * Vector3.right) * ((hmdConfig.IPD / 2) * xDir); foreach (Camera cam in node.GetComponents <Camera>()) { // Setup perspective projection, with aspect ratio matches viewport float top = (float)Mathf.Tan(Mathf.Deg2Rad * hmdConfig.FieldOfView / 2) * cam.nearClipPlane; float bottom = -top; float left = cam.aspect * bottom / 2; float right = -left; // apply centre offset and adapt viewport float offX = hmdConfig.xOffset * (left - right) / 2; if (eye == VRNode.LeftEye) { cam.rect = new Rect(0.0f, 0, 0.5f, 1); } else if (eye == VRNode.RightEye) { cam.rect = new Rect(0.5f, 0, 0.5f, 1); offX = -offX; } else { cam.rect = new Rect(0.0f, 0, 1.0f, 1); offX = 0; } // calculate off-centre projection matrix Matrix4x4 projectionMatrix = cam.projectionMatrix; CalculateProjectionMatrix(ref projectionMatrix, left + offX, right + offX, top, bottom, cam.nearClipPlane, cam.farClipPlane); cam.projectionMatrix = projectionMatrix; // add distortion filter LensDistortion distortion = cam.GetComponent <LensDistortion>(); if (distortion == null) { distortion = cam.gameObject.AddComponent <LensDistortion>(); distortion.DistortionShader = Shader.Find("VR/LensDistortion"); } distortion.ApplyConfig(hmdConfig); distortion.ScaleIn = 1.1f; // TODO: Hardcoded values > calculate automatically distortion.ScaleOut = 0.82f; // TODO: Hardcoded values > calculate automatically } }
/// <summary> /// /// </summary> public virtual Transform GetAnchor(VRNode node, Transform defaultValue) { for (int i = 0, imax = m_Anchors.Length; i < imax; ++i) { if (m_Anchors[i].key == node) { return(m_Anchors[i].value); } } return(defaultValue); }
public void OverrideOverlayTextureInfo(Texture srcTexture, IntPtr nativePtr, VRNode node) { int num = (node != VRNode.RightEye) ? 0 : 1; if (this.textures.Length <= num) { return; } this.textures[num] = srcTexture; this.texturePtrs[num] = nativePtr; this.isOverridePending = true; }
protected virtual void Start() { // if (checkParent) { Transform p = VRContext.GetAnchor(VRNode.TrackingSpace); if (p != null) { target.SetParent(p, true); } } // m_ControllerInput = ControllerInputManager.instance.GetControllerInput(source); VRNode node = VRNode.None; switch (source) { case ControllerType.LeftController: node = VRNode.LeftHand; break; case ControllerType.RightController: node = VRNode.RightHand; break; } if (node != VRNode.None) { VRContext.SetAnchor(node, target); } // if (m_ControllerInput != null && canRecenter) { // Like SteamVR,hmd and controllers don't need to reset yaw angle. canRecenter = !m_ControllerInput.isAbsRotation; } // if (canRecenter) { // Invoke Recenter() on VRContext recenter event. VRContext ctx = VRContext.main; if (ctx != null) { ctx.onRecenter += Recenter; } } // return; // TODO: enabled = false; UpdatePoses.instance.onUpdatePoses += Update; }
// Token: 0x060037EB RID: 14315 RVA: 0x0011D018 File Offset: 0x0011B418 private void ConfigureEyeDesc(VRNode eye) { if (!OVRManager.isHmdPresent) { return; } OVRPlugin.Sizei eyeTextureSize = OVRPlugin.GetEyeTextureSize((OVRPlugin.Eye)eye); OVRPlugin.Frustumf eyeFrustum = OVRPlugin.GetEyeFrustum((OVRPlugin.Eye)eye); this.eyeDescs[(int)eye] = new OVRDisplay.EyeRenderDesc { resolution = new Vector2((float)eyeTextureSize.w, (float)eyeTextureSize.h), fov = 57.29578f * new Vector2(eyeFrustum.fovX, eyeFrustum.fovY) }; }
bool isRightHand; //Is this sword in the right hand? void Start() { //Get a reference to the animator component on the sword child object anim = GetComponentInChildren <Animator> (); //Determine if this is the right hand or not by examining the parent VRObjectTracking script VRNode node = transform.parent.GetComponent <VRObjectTracking> ().node; if (node == VRNode.RightHand) { isRightHand = true; } //Invoke the enable method after a delay. This is done so that the sword speed isn't being measured //as soon as the scene starts. After the first frame, VR tracking becomes enabled which will make //the sword position jump and have a high speed Invoke("Enable", initialDelay); }
/// <summary> /// /// </summary> public static Transform GetAnchor(VRNode node) { if (main == null) { // switch (node) { case VRNode.CenterEye: if (Camera.main != null) { return(Camera.main.transform); } break; } // return(null); } return(main.GetAnchor(node, null)); }
public virtual Vector3 EmulatePosition(VRNode node) { switch (node) { case VRNode.LeftHand: case VRNode.RightHand: Vector3 pos = m_HandPosition[(int)(node - VRNode.LeftHand)]; Transform centerEyeAnchor = VRContext.GetAnchor(VRNode.CenterEye); if (centerEyeAnchor != null) { Transform trackingSpace = VRContext.GetAnchor(VRNode.TrackingSpace); Quaternion bodyRotation = Quaternion.Euler(new Vector3(0.0f, centerEyeAnchor.eulerAngles.y, 0.0f)); pos = centerEyeAnchor.position + bodyRotation * pos + ((trackingSpace == null?Quaternion.identity:trackingSpace.rotation) * GetRotation((int)(node - VRNode.LeftHand))) * (Vector3.forward * m_HandLength[(int)(node - VRNode.LeftHand)]); // TODO : if (trackingSpace != null) { pos = trackingSpace.InverseTransformPoint(pos); } } else { pos = pos + GetRotation((int)(node - VRNode.LeftHand)) * (Vector3.forward * m_HandLength[(int)(node - VRNode.LeftHand)]); } return(pos); break; case VRNode.LeftHand + 2: return(Vector3.up * (VRContext.trackingOrigin == TrackingOrigin.EyeLevel?0: // Keep zero. XDevicePlugin.GetFloat(m_Handle, XDevicePlugin.kField_TrackerHeight, 0.0f))); // From ground. break; default: return(Vector3.zero); break; } }
public static Vector3 GetLocalPosition(VRNode node) { throw new NotImplementedException("なにこれ"); }
public static extern Quaternion GetLocalRotation(VRNode node);
private static extern void INTERNAL_CALL_GetLocalRotation(VRNode node, out Quaternion value);
public static Quaternion GetLocalRotation(VRNode node) { throw new NotImplementedException("なにこれ"); }
private void ConfigureCamera(GameObject node, VRNode eye, HMD_Config hmdConfig) { // adjust camera X-positions based on IPD float xDir = 0; if (eye == VRNode.LeftEye) { xDir = -1; } else if (eye == VRNode.RightEye) { xDir = +1; } // shift camera sideways considering any offset orientation node.transform.localPosition = (node.transform.localRotation * Vector3.right) * ((hmdConfig.IPD / 2) * xDir); foreach (Camera cam in node.GetComponents<Camera>()) { // Setup perspective projection, with aspect ratio matches viewport float top = (float)Mathf.Tan(Mathf.Deg2Rad * hmdConfig.FieldOfView / 2) * cam.nearClipPlane; float bottom = -top; float left = cam.aspect * bottom / 2; float right = -left; // apply centre offset and adapt viewport float offX = hmdConfig.xOffset * (left - right) / 2; if (eye == VRNode.LeftEye) { cam.rect = new Rect(0.0f, 0, 0.5f, 1); } else if (eye == VRNode.RightEye) { cam.rect = new Rect(0.5f, 0, 0.5f, 1); offX = -offX; } else { cam.rect = new Rect(0.0f, 0, 1.0f, 1); offX = 0; } // calculate off-centre projection matrix Matrix4x4 projectionMatrix = cam.projectionMatrix; CalculateProjectionMatrix(ref projectionMatrix, left + offX, right + offX, top, bottom, cam.nearClipPlane, cam.farClipPlane); cam.projectionMatrix = projectionMatrix; // add distortion filter LensDistortion distortion = cam.GetComponent<LensDistortion>(); if (distortion == null) { distortion = cam.gameObject.AddComponent<LensDistortion>(); distortion.DistortionShader = Shader.Find("VR/LensDistortion"); } distortion.ApplyConfig(hmdConfig); distortion.ScaleIn = 1.1f; // TODO: Hardcoded values > calculate automatically distortion.ScaleOut = 0.82f; // TODO: Hardcoded values > calculate automatically } }
private static extern void INTERNAL_CALL_GetLocalPosition(VRNode node, out Vector3 value);
public static Vector3 GetLocalPosition(VRNode node) { throw new NotSupportedException("InputTracking has been moved. Use UnityEngine.XR.InputTracking instead."); }
public static Quaternion GetLocalRotation(VRNode node) { return(Quaternion.identity); }
public static void UpdateTrackedDevice(VRNode nodeType, Vector3 position, Quaternion rotation) { VRTestMock.INTERNAL_CALL_UpdateTrackedDevice(nodeType, ref position, ref rotation); }
public static extern void AddTrackedDevice(VRNode nodeType);
private static extern void INTERNAL_CALL_UpdateTrackedDevice(VRNode nodeType, ref Vector3 position, ref Quaternion rotation);
private static void InvokeTrackingEvent(InputTracking.TrackingStateEventType eventType, VRNode nodeType, long uniqueID, bool tracked) { VRNodeState obj = default(VRNodeState); obj.uniqueID = (ulong)uniqueID; obj.nodeType = nodeType; obj.tracked = tracked; Action <VRNodeState> action; switch (eventType) { case InputTracking.TrackingStateEventType.NodeAdded: action = InputTracking.nodeAdded; break; case InputTracking.TrackingStateEventType.NodeRemoved: action = InputTracking.nodeRemoved; break; case InputTracking.TrackingStateEventType.TrackingAcquired: action = InputTracking.trackingAcquired; break; case InputTracking.TrackingStateEventType.TrackingLost: action = InputTracking.trackingLost; break; default: throw new ArgumentException("TrackingEventHandler - Invalid EventType: " + eventType); } if (action != null) { action(obj); } }
private static extern void INTERNAL_CALL_GetLocalPosition(VRNode node, out Vector3 value);
public static extern Vector3 GetLocalPosition(VRNode node);
/// <summary> /// <para>The current position of the requested VRNode.</para> /// </summary> /// <param name="node">Node index.</param> /// <returns> /// <para>Position of node local to its tracking space.</para> /// </returns> public static Vector3 GetLocalPosition(VRNode node) { Vector3 vector; INTERNAL_CALL_GetLocalPosition(node, out vector); return vector; }
public static Vector3 GetLocalPosition(VRNode node) { return(Vector3.zero); }
/// <summary> /// <para>The current rotation of the requested VRNode.</para> /// </summary> /// <param name="node">Node index.</param> /// <returns> /// <para>Rotation of node local to its tracking space.</para> /// </returns> public static Quaternion GetLocalRotation(VRNode node) { Quaternion quaternion; INTERNAL_CALL_GetLocalRotation(node, out quaternion); return quaternion; }
/// <summary> /// <para>The current position of the requested VRNode.</para> /// </summary> /// <param name="node">Node index.</param> /// <returns> /// <para>Position of node local to its tracking space.</para> /// </returns> public static Vector3 GetLocalPosition(VRNode node) { Vector3 vector3; InputTracking.INTERNAL_CALL_GetLocalPosition(node, out vector3); return vector3; }
private static extern void INTERNAL_CALL_GetLocalRotation(VRNode node, out Quaternion value);