private void OnRequestScreenshot(VREvent_t vrEvent) { var screenshotHandle = vrEvent.data.screenshot.handle; var screenshotType = (EVRScreenshotType)vrEvent.data.screenshot.type; if (screenshotType == EVRScreenshotType.StereoPanorama) { string previewFilename = GetScreenshotFilename(screenshotHandle, EVRScreenshotPropertyFilenames.Preview); string VRFilename = GetScreenshotFilename(screenshotHandle, EVRScreenshotPropertyFilenames.VR); if (previewFilename == null || VRFilename == null) { return; } // Do the stereo panorama screenshot // Figure out where the view is GameObject screenshotPosition = new GameObject("screenshotPosition"); screenshotPosition.transform.position = SteamVR_Render.Top().transform.position; screenshotPosition.transform.rotation = SteamVR_Render.Top().transform.rotation; screenshotPosition.transform.localScale = SteamVR_Render.Top().transform.lossyScale; SteamVR_Utils.TakeStereoScreenshot(screenshotHandle, screenshotPosition, 32, 0.064f, ref previewFilename, ref VRFilename); // and submit it OpenVR.Screenshots.SubmitScreenshot(screenshotHandle, screenshotType, previewFilename, VRFilename); } }
//Set up required variables private void Start() { m_CameraRig = SteamVR_Render.Top().origin; m_Head = SteamVR_Render.Top().head; m_Speed = 2 * m_WalkDistance; }
void OnRenderImage(RenderTexture src, RenderTexture dest) { if (SteamVR_Render.Top() == this) { int eventID; if (SteamVR_Render.eye == Hmd_Eye.Eye_Left) { // Get gpu started on work early to avoid bubbles at the top of the frame. SteamVR_Utils.QueueEventOnRenderThread(Unity.k_nRenderEventID_Flush); eventID = Unity.k_nRenderEventID_SubmitL; } else { eventID = Unity.k_nRenderEventID_SubmitR; } // Queue up a call on the render thread to Submit our render target to the compositor. SteamVR_Utils.QueueEventOnRenderThread(eventID); } Graphics.SetRenderTarget(dest); SteamVR_Camera.blitMaterial.mainTexture = src; GL.PushMatrix(); GL.LoadOrtho(); SteamVR_Camera.blitMaterial.SetPass(0); GL.Begin(GL.QUADS); GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(-1, 1, 0); GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1, 1, 0); GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1, -1, 0); GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-1, -1, 0); GL.End(); GL.PopMatrix(); }
private void SnapRotation() { float snapValue = 0f; //if (m_RotatePress.GetStateDown(SteamVR_Input_Sources.LeftHand)) //{ //snapValue = -Mathf.Abs(m_RotateIncrement); //} //if (m_RotatePress.GetStateDown(SteamVR_Input_Sources.RightHand)) //{ //snapValue = Mathf.Abs(m_RotateIncrement); //} if (m_SnapRotateButton.GetStateDown(SteamVR_Input_Sources.LeftHand)) { if (m_RotateValue.axis.x <= 0) { snapValue = -Mathf.Abs(m_RotateIncrement); } else { snapValue = Mathf.Abs(m_RotateIncrement); } } transform.RotateAround(SteamVR_Render.Top().head.position, Vector3.up, snapValue); }
void DoClick(object sender, ClickedEventArgs e) { if (teleportOnClick) { // First get the current Transform of the the reference space (i.e. the Play Area, e.g. CameraRig prefab) var t = reference; if (t == null) { return; } // Get the current Y position of the reference space float refY = t.position.y; // Create a plane at the Y position of the Play Area // Then create a Ray from the origin of the controller in the direction that the controller is pointing Plane plane = new Plane(Vector3.up, -refY); Ray ray = new Ray(this.transform.position, transform.forward); // Set defaults bool hasGroundTarget = false; float dist = 0f; if (teleportType == TeleportType.TeleportTypeUseTerrain) // If we picked to use the terrain { RaycastHit hitInfo; TerrainCollider tc = Terrain.activeTerrain.GetComponent <TerrainCollider>(); hasGroundTarget = tc.Raycast(ray, out hitInfo, 1000f); dist = hitInfo.distance; } else if (teleportType == TeleportType.TeleportTypeUseCollider) // If we picked to use the collider { RaycastHit hitInfo; hasGroundTarget = Physics.Raycast(ray, out hitInfo); dist = hitInfo.distance; } else // If we're just staying flat on the current Y axis { // Intersect a ray with the plane that was created earlier // and output the distance along the ray that it intersects hasGroundTarget = plane.Raycast(ray, out dist); } if (hasGroundTarget) { // Get the current Camera (head) position on the ground relative to the world Vector3 headPosOnGround = new Vector3(SteamVR_Render.Top().head.position.x, refY, SteamVR_Render.Top().head.position.z); // We need to translate the reference space along the same vector // that is between the head's position on the ground and the intersection point on the ground // i.e. intersectionPoint - headPosOnGround = translateVector // currentReferencePosition + translateVector = finalPosition t.position = t.position + (ray.origin + (ray.direction * dist)) - headPosOnGround; } } }
private Transform headPostion; // pozicija VR-a private void Start() { characterController = GetComponent <CharacterController>(); //dohvacanje pozicija cameraPosition = SteamVR_Render.Top().origin; headPostion = SteamVR_Render.Top().head; }
void Update() { if (model != null) { model.transform.LookAt(SteamVR_Render.Top().transform.position); model.transform.Rotate(0, 180, 0); } }
private void PlayVRGame() { Transform cameraRig = SteamVR_Render.Top().origin; Transform head = SteamVR_Render.Top().head; //Move the rotation of the rig to the relative position in space Vector3 headRotation = head.rotation.eulerAngles; float rotationForY = 0f; //Adjust for the position in space based on location switch (headRotation.y) { case float angle when(angle < 45f): rotationForY = headRotation.y - ((headRotation.y + 45) * 2) + 180; break; case float angle when(angle < 135f): rotationForY = headRotation.y - ((headRotation.y - 45) * 2); break; case float angle when(angle < 225f): rotationForY = headRotation.y - ((headRotation.y - 135) * 2) + 180; break; case float angle when(angle < 315f): rotationForY = headRotation.y - ((headRotation.y - 225) * 2); break; case float angle when(angle < 360f): rotationForY = headRotation.y - ((headRotation.y - 315) * 2) + 180; break; default: print("Reached default: should not happen"); break; } //Set the new rotation to the area cameraRig.transform.rotation = Quaternion.Euler(cameraRig.transform.rotation.eulerAngles.x, rotationForY, cameraRig.transform.rotation.eulerAngles.z); //Move the position of the character to the relative position in space Vector3 headPosition = cameraRig.position + (cameraRig.position - head.position); headPosition.y = cameraRig.position.y; cameraRig.position = headPosition; }
private void InternalSetQuadViewActive(bool value) { if (value && m_externalCamera == null && !string.IsNullOrEmpty(m_configPath) && File.Exists(m_configPath)) { // don't know why SteamVR_ExternalCamera must be instantiated from the prefab // when create SteamVR_ExternalCamera using AddComponent, errors came out when disabling var prefab = Resources.Load <GameObject>("SteamVR_ExternalCamera"); if (prefab == null) { Debug.LogError("SteamVR_ExternalCamera prefab not found!"); } else { var ctrlMgr = Instantiate(prefab); var extCam = ctrlMgr.transform.GetChild(0); extCam.gameObject.name = "SteamVR External Camera"; extCam.SetParent(transform, false); DestroyImmediate(extCam.GetComponent <SteamVR_TrackedObject>()); DestroyImmediate(ctrlMgr); m_externalCamera = extCam.GetComponent <SteamVR_ExternalCamera>(); SteamVR_Render.instance.externalCamera = m_externalCamera; // resolve config file m_externalCamera.enabled = false; m_externalCamera.configPath = m_configPath; m_externalCamera.ReadConfig(); m_externalCamera.enabled = true; // to preserve sceneResolutionScale on enabled // resolve RenderTexture m_externalCamera.AttachToCamera(SteamVR_Render.Top()); var w = Screen.width / 2; var h = Screen.height / 2; var cam = m_externalCamera.GetComponentInChildren <Camera>(); if (cam.targetTexture == null || cam.targetTexture.width != w || cam.targetTexture.height != h) { var tex = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32, QualitySettings.activeColorSpace == ColorSpace.Linear ? RenderTextureReadWrite.Linear : RenderTextureReadWrite.Default); tex.antiAliasing = QualitySettings.antiAliasing == 0 ? 1 : QualitySettings.antiAliasing; cam.targetTexture = tex; } } } if (m_externalCamera != null) { m_externalCamera.gameObject.SetActive(value); if (value) { VivePose.AddNewPosesListener(this); } else { VivePose.RemoveNewPosesListener(this); } } }
// Helper to create (or reuse if possible) each of our different overlay types. private ulong GetOverlayHandle(string overlayName, Transform transform, float widthInMeters = 1.0f) { ulong handle = OpenVR.k_ulOverlayHandleInvalid; var overlay = OpenVR.Overlay; if (overlay == null) { return(handle); } var key = SteamVR_Overlay.key + "." + overlayName; var error = overlay.FindOverlay(key, ref handle); if (error != EVROverlayError.None) { error = overlay.CreateOverlay(key, overlayName, ref handle); } if (error == EVROverlayError.None) { overlay.ShowOverlay(handle); overlay.SetOverlayAlpha(handle, alpha); overlay.SetOverlayWidthInMeters(handle, widthInMeters); // D3D textures are upside-down in Unity to match OpenGL. if (SteamVR.instance.textureType == ETextureType.DirectX) { var textureBounds = new VRTextureBounds_t(); textureBounds.uMin = 0; textureBounds.vMin = 1; textureBounds.uMax = 1; textureBounds.vMax = 0; overlay.SetOverlayTextureBounds(handle, ref textureBounds); } // Convert from world space to tracking space using the top-most camera. var vrcam = (loadingScreenDistance == 0.0f) ? SteamVR_Render.Top() : null; if (vrcam != null && vrcam.origin != null) { var offset = new SteamVR_Utils.RigidTransform(vrcam.origin, transform); offset.pos.x /= vrcam.origin.localScale.x; offset.pos.y /= vrcam.origin.localScale.y; offset.pos.z /= vrcam.origin.localScale.z; var t = offset.ToHmdMatrix34(); overlay.SetOverlayTransformAbsolute(handle, SteamVR_Render.instance.trackingSpace, ref t); } else { var t = new SteamVR_Utils.RigidTransform(transform).ToHmdMatrix34(); overlay.SetOverlayTransformAbsolute(handle, SteamVR_Render.instance.trackingSpace, ref t); } } return(handle); }
private void SetScale(float scale) { this.scale = scale; SteamVR_Camera steamVR_Camera = SteamVR_Render.Top(); if (steamVR_Camera != null) { steamVR_Camera.origin.localScale = new Vector3(scale, scale, scale); } }
protected virtual void Start() { this.name = "PlayerObject_" + this.name; adjustYForTerrain = false; eyeCamera = SteamVR_Render.Top().GetComponent <Transform>(); InitHeadsetCollisionListener(); enableTeleport = true; }
// Start is called before the first frame update void Start() { head = SteamVR_Render.Top().head; rb = GetComponent <Rigidbody>(); player = GetComponent <CapsuleCollider>(); vision = GetComponent <SteamVR_Camera>(); LeftHand = GetComponentInChildren <Transform>(); RightHand = GetComponentInChildren <Transform>(); velocity.y = Mathf.Clamp(velocity.y, 0, 100); }
void SetScale(float scale) { this.scale = scale; var tracker = SteamVR_Render.Top(); if (tracker != null) { tracker.origin.localScale = new Vector3(scale, scale, scale); } }
// Start is called before the first frame update private void Start() { head = SteamVR_Render.Top().head; rb = GetComponent <Rigidbody>(); jumpCounter = Mathf.Clamp(jumpCounter, 0, maxJumpCounter); gravity = Mathf.Clamp(gravity, 0, maxGravity); velocity.y = Mathf.Clamp(velocity.y, 0, maxGravity); velocity.x = Mathf.Clamp(velocity.x, -maxSpeed, maxSpeed); velocity.z = Mathf.Clamp(velocity.z, -maxSpeed, maxSpeed); }
void Move() { Plane plane = new Plane(Vector3.up, -player.position.y); Ray ray = new Ray(this.transform.position, transform.forward); var dist = 0f; var hasGroundTarget = plane.Raycast(ray, out dist); if (hasGroundTarget) { Vector3 headPosOnGround = new Vector3(SteamVR_Render.Top().head.localPosition.x, 0.0f, SteamVR_Render.Top().head.localPosition.z); player.position = ray.origin + ray.direction * dist - new Vector3(player.GetChild(0).localPosition.x, 0f, player.GetChild(0).localPosition.z) - headPosOnGround; } }
private void Start() { controllerR = handR.GetComponent <HandInteractionController>(); poseR = handR.GetComponent <SteamVR_Behaviour_Pose>(); controllerL = handL.GetComponent <HandInteractionController>(); poseL = handL.GetComponent <SteamVR_Behaviour_Pose>(); cameraRig = SteamVR_Render.Top().origin; head = SteamVR_Render.Top().head; characterControllerMover = new CharacterControllerMover(charController, cameraRig, head, 0.1f, 0.2f); }
// Start is called before the first frame update private void Start() { cameraRig = SteamVR_Render.Top().origin; head = SteamVR_Render.Top().head; if (leftHand == null) { Debug.Log("Error: Left hand reference not assigned."); } if (rightHand == null) { Debug.Log("Error: Right hand reference not assigned."); } }
private bool GetTargetPosition(out Vector3 targetPosition) { var t = Reference; if (!t) { targetPosition = Vector3.zero; return(false); } var ray = new Ray(transform.position, transform.forward); bool hasGroundTarget; float dist; switch (TeleportType) { case TeleportType.TeleportTypeUseTerrain: RaycastHit terrainHitInfo; var tc = Terrain.activeTerrain.GetComponent <TerrainCollider>(); hasGroundTarget = tc.Raycast(ray, out terrainHitInfo, 1000f); dist = terrainHitInfo.distance; break; case TeleportType.TeleportTypeUseCollider: RaycastHit colliderHitInfo; hasGroundTarget = Physics.Raycast(ray, out colliderHitInfo); dist = colliderHitInfo.distance; break; case TeleportType.TeleportTypeUseZeroY: var refY = t.position.y; var plane = new Plane(Vector3.up, -refY); hasGroundTarget = plane.Raycast(ray, out dist); break; default: throw new ArgumentOutOfRangeException(); } if (!hasGroundTarget) { targetPosition = Vector3.zero; return(false); } var headPosOnGround = new Vector3(SteamVR_Render.Top().head.localPosition.x, 0.0f, SteamVR_Render.Top().head.localPosition.z); targetPosition = ray.origin + ray.direction * dist - new Vector3(t.GetChild(0).localPosition.x, 0f, t.GetChild(0).localPosition.z) - headPosOnGround; return(true); }
public void ShowMenu() { var overlay = SteamVR_Overlay.instance; if (overlay == null) { return; } var texture = overlay.texture as RenderTexture; if (texture == null) { Debug.LogError("Menu requires overlay texture to be a render texture."); return; } SaveCursorState(); /*# if !UNITY_WSA_10_0 * Cursor.visible = true; * Cursor.lockState = CursorLockMode.None; #endif */ this.overlay = overlay; uvOffset = overlay.uvOffset; distance = overlay.distance; // If an existing camera is rendering into the overlay texture, we need // to temporarily disable it to keep it from clearing the texture on us. var cameras = Object.FindObjectsOfType(typeof(Camera)) as Camera[]; foreach (var cam in cameras) { if (cam.enabled && cam.targetTexture == texture) { overlayCam = cam; overlayCam.enabled = false; break; } } var tracker = SteamVR_Render.Top(); if (tracker != null) { scale = tracker.origin.localScale.x; } }
void OnRenderImage(RenderTexture src, RenderTexture dest) { if (SteamVR_Render.Top() == this) { int eventID; if (SteamVR_Render.eye == EVREye.Eye_Left) { // Get gpu started on work early to avoid bubbles at the top of the frame. //OpenVR.Compositor.ClearLastSubmittedFrame(); GL.IssuePluginEvent(SteamVR.Unity.k_nRenderEventID_Flush); eventID = SteamVR.Unity.k_nRenderEventID_SubmitL; } else { eventID = SteamVR.Unity.k_nRenderEventID_SubmitR; } // Queue up a call on the render thread to Submit our render target to the compositor. GL.IssuePluginEvent(eventID); } Graphics.SetRenderTarget(dest); SteamVR_Camera.blitMaterial.mainTexture = src; GL.PushMatrix(); GL.LoadOrtho(); SteamVR_Camera.blitMaterial.SetPass(0); GL.Begin(GL.QUADS); GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(-1, 1, 0); GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1, 1, 0); GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1, -1, 0); GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-1, -1, 0); GL.End(); GL.PopMatrix(); /*Texture_t tex = new Texture_t(); * tex.eColorSpace = EColorSpace.Linear; * tex.eType = ETextureType.DirectX; * tex.handle = dest.GetNativeTexturePtr(); * VRTextureBounds_t bounds = new VRTextureBounds_t(); * bounds.vMin = bounds.uMin = 0; * bounds.vMax = bounds.uMax = 1; * OpenVR.Compositor.Submit(EVREye.Eye_Left, ref tex, ref bounds, EVRSubmitFlags.Submit_Default); * OpenVR.Compositor.Submit(EVREye.Eye_Right, ref tex, ref bounds, EVRSubmitFlags.Submit_Default);*/ Graphics.SetRenderTarget(null); }
// Update is called once per frame void Update() { var vrcam = SteamVR_Render.Top(); Ray ray = new Ray(vrcam.head.position, vrcam.head.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000)) { if (hit.collider.tag == "focusUmbrella" && correctPosUmbrella && (GameObject.Find("Controller (left)").GetComponent <PickupParent> ().touchpadDown || GameObject.Find("Controller (right)").GetComponent <PickupParent> ().touchpadDown)) { Debug.Log("Umbrella found!"); realUmbrella.SetActive(true); puzzleUmbrella.SetActive(false); } if (hit.collider.tag == "focusBucket" && correctPosBucket && (GameObject.Find("Controller (left)").GetComponent <PickupParent> ().touchpadDown || GameObject.Find("Controller (right)").GetComponent <PickupParent> ().touchpadDown)) { Debug.Log("Bucket found!"); realBucket.SetActive(true); puzzleBucket.SetActive(false); } if (hit.collider.tag == "focusRake" && correctPosRake && (GameObject.Find("Controller (left)").GetComponent <PickupParent> ().touchpadDown || GameObject.Find("Controller (right)").GetComponent <PickupParent> ().touchpadDown)) { Debug.Log("Rake found!"); realRake.SetActive(true); puzzleRake.SetActive(false); } if (hit.collider.tag == "focusSled" && correctPosSled && (GameObject.Find("Controller (left)").GetComponent <PickupParent> ().touchpadDown || GameObject.Find("Controller (right)").GetComponent <PickupParent> ().touchpadDown)) { Debug.Log("Sled found!"); realSled.SetActive(true); puzzleSled.SetActive(false); } if (hit.collider.tag == "focusShovel" && correctPosShovel && (GameObject.Find("Controller (left)").GetComponent <PickupParent> ().touchpadDown || GameObject.Find("Controller (right)").GetComponent <PickupParent> ().touchpadDown)) { Debug.Log("Shovel found!"); realShovel.SetActive(true); puzzleShovel.SetActive(false); } } if (EndGame.summerSolved && EndGame.winterSolved && EndGame.springSolved && EndGame.fallSolved) { if (!portalThreePlayed) { portal.SetActive(true); //StartCoroutine ("PortalOpen"); portalThreePlayed = true; } } }
private void TeleportToPoint() { IsTeleporting = true; Transform RigTransform = SteamVR_Render.Top().origin; Vector3 HeadPos = SteamVR_Render.Top().head.position; // //Transform RigTransform = Rig.transform; //Vector3 HeadPos = Head.transform.position; // float HeadYpos = SteamVR_Render.Top().head.transform.localPosition.y; Vector3 TranslateVector = Pointer.transform.position - HeadPos; TranslateVector.y += HeadYpos; StartCoroutine(MoveRig(RigTransform, TranslateVector)); }
private void tryTeleport() { if (!m_HasPosition || m_IsTeleportoting) { return; } Vector3 headPosition = SteamVR_Render.Top().head.position; Transform cameraRig = SteamVR_Render.Top().origin; Vector3 groundPosition = new Vector3(headPosition.x, cameraRig.position.y, headPosition.z); Vector3 translateVector = m_Pointer.transform.position - groundPosition; StartCoroutine(MoveRig(cameraRig, translateVector)); }
private void TryTeleport() { if (!m_HasPosition || m_IsTeleporting || m_HandScript.m_HasInteractable) { return; } Vector3 headPosition = SteamVR_Render.Top().head.position; Vector3 groundPosition = new Vector3(headPosition.x, m_Player.position.y, headPosition.z); Vector3 translateVector = m_Pointer.transform.position - groundPosition; // Move StartCoroutine(MovePlayer(translateVector)); }
private void TryTeleport() { //Check for vlid positio and if already teleporting if (!HasPosition || IsTelePorting) { Debug.Log("Teleport Failed : HasPosition (" + HasPosition + "), IsTeleporting (" + IsTelePorting + ")"); return; } Transform cameraRig = SteamVR_Render.Top().origin; Vector3 headPosition = SteamVR_Render.Top().head.position; Vector3 groundPosition = new Vector3(headPosition.x, cameraRig.position.y, headPosition.z); Vector3 traslateVector = Pointer.transform.position - groundPosition; StartCoroutine(MoveRig(cameraRig, traslateVector)); }
public void TryTeleport() { if (hasPosition == false || isTeleporting) { return; } Transform cameraRig = SteamVR_Render.Top().origin; Vector3 headPosition = SteamVR_Render.Top().head.position; Vector3 groundPosition = new Vector3(headPosition.x, cameraRig.position.y, headPosition.z); Vector3 translateVector = pointer.transform.position - groundPosition; StartCoroutine(MoveRig(cameraRig, translateVector)); }
private void UpdateOverlay() { var overlay = OpenVR.Overlay; if (overlay == null) { return; } if (OverlayTexture != null) { var error = overlay.ShowOverlay(_handle); if (error == EVROverlayError.InvalidHandle || error == EVROverlayError.UnknownOverlay) { if (overlay.FindOverlay(Key + gameObject.GetInstanceID(), ref _handle) != EVROverlayError.None) { return; } } var tex = new Texture_t { handle = OverlayTexture.GetNativeTexturePtr(), eType = SteamVR.instance.graphicsAPI, eColorSpace = EColorSpace.Auto }; overlay.SetOverlayColor(_handle, 1f, 1f, 1f); overlay.SetOverlayTexture(_handle, ref tex); overlay.SetOverlayAlpha(_handle, Alpha); var textureBounds = new VRTextureBounds_t { uMin = (0 + UvOffset.x) * UvOffset.z, vMin = (1 + UvOffset.y) * UvOffset.w, uMax = (1 + UvOffset.x) * UvOffset.z, vMax = (0 + UvOffset.y) * UvOffset.w }; overlay.SetOverlayTextureBounds(_handle, ref textureBounds); var vrcam = SteamVR_Render.Top(); var offset = new SteamVR_Utils.RigidTransform(OverlayReference.transform, transform); offset.pos.x /= OverlayReference.transform.localScale.x; offset.pos.y /= OverlayReference.transform.localScale.y; offset.pos.z /= OverlayReference.transform.localScale.z; var t = offset.ToHmdMatrix34(); overlay.SetOverlayTransformTrackedDeviceRelative(_handle, 0, ref t); } else { overlay.HideOverlay(_handle); } }
// Token: 0x06000D9C RID: 3484 RVA: 0x00055E50 File Offset: 0x00054050 private ulong GetOverlayHandle(string overlayName, Transform transform, float widthInMeters = 1f) { ulong num = 0UL; CVROverlay overlay = OpenVR.Overlay; if (overlay == null) { return(num); } string pchOverlayKey = SteamVR_Overlay.key + "." + overlayName; EVROverlayError evroverlayError = overlay.FindOverlay(pchOverlayKey, ref num); if (evroverlayError != EVROverlayError.None) { evroverlayError = overlay.CreateOverlay(pchOverlayKey, overlayName, ref num); } if (evroverlayError == EVROverlayError.None) { overlay.ShowOverlay(num); overlay.SetOverlayAlpha(num, this.alpha); overlay.SetOverlayWidthInMeters(num, widthInMeters); if (SteamVR.instance.textureType == ETextureType.DirectX) { VRTextureBounds_t vrtextureBounds_t = default(VRTextureBounds_t); vrtextureBounds_t.uMin = 0f; vrtextureBounds_t.vMin = 1f; vrtextureBounds_t.uMax = 1f; vrtextureBounds_t.vMax = 0f; overlay.SetOverlayTextureBounds(num, ref vrtextureBounds_t); } SteamVR_Camera steamVR_Camera = (this.loadingScreenDistance == 0f) ? SteamVR_Render.Top() : null; if (steamVR_Camera != null && steamVR_Camera.origin != null) { SteamVR_Utils.RigidTransform rigidTransform = new SteamVR_Utils.RigidTransform(steamVR_Camera.origin, transform); rigidTransform.pos.x = rigidTransform.pos.x / steamVR_Camera.origin.localScale.x; rigidTransform.pos.y = rigidTransform.pos.y / steamVR_Camera.origin.localScale.y; rigidTransform.pos.z = rigidTransform.pos.z / steamVR_Camera.origin.localScale.z; HmdMatrix34_t hmdMatrix34_t = rigidTransform.ToHmdMatrix34(); overlay.SetOverlayTransformAbsolute(num, SteamVR_Render.instance.trackingSpace, ref hmdMatrix34_t); } else { HmdMatrix34_t hmdMatrix34_t2 = new SteamVR_Utils.RigidTransform(transform).ToHmdMatrix34(); overlay.SetOverlayTransformAbsolute(num, SteamVR_Render.instance.trackingSpace, ref hmdMatrix34_t2); } } return(num); }
//void DoClick(object sender, ClickedEventArgs e) void DoClick() { GameObject go = Fsm.GetOwnerDefaultTarget(controller); var i = -1; if ((int)trackedObj.index > i++) { var t = reference; if (t == null) { return; } float refY = t.position.y; Plane plane = new Plane(Vector3.up, -refY); Ray ray = new Ray(go.transform.position, go.transform.forward); bool hasGroundTarget = false; float dist = 0f; if (teleportType == TeleportType.TeleportTypeUseTerrain) { RaycastHit hitInfo; TerrainCollider tc = Terrain.activeTerrain.GetComponent <TerrainCollider>(); hasGroundTarget = tc.Raycast(ray, out hitInfo, 1000f); dist = hitInfo.distance; } else if (teleportType == TeleportType.TeleportTypeUseCollider) { RaycastHit hitInfo; Physics.Raycast(ray, out hitInfo); dist = hitInfo.distance; } else { hasGroundTarget = plane.Raycast(ray, out dist); } if (hasGroundTarget) { Vector3 headPosOnGround = new Vector3(SteamVR_Render.Top().head.localPosition.x, 0.0f, SteamVR_Render.Top().head.localPosition.z); t.position = ray.origin + ray.direction * dist - new Vector3(t.GetChild(0).localPosition.x, 0f, t.GetChild(0).localPosition.z) - headPosOnGround; Fsm.Event(sendEvent); } } }