vr ready buttons
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using EscapeRoomEngine.VR.Runtime;
|
||||
using UnityEngine;
|
||||
@@ -32,15 +31,14 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
/// </summary>
|
||||
[SerializeField] public MeshRenderer screen;
|
||||
|
||||
private PlayerCamera _playerCamera;
|
||||
private Player _player;
|
||||
private Camera _camera;
|
||||
private readonly Dictionary<Camera.StereoscopicEye, RenderTexture> _textures = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// get player camera
|
||||
if (Camera.main != null) _playerCamera = Camera.main.GetComponent<PlayerCamera>();
|
||||
else throw new Exception("Main camera has no player camera script set up.");
|
||||
_player = Player.Current;
|
||||
|
||||
// get portal camera
|
||||
_camera = GetComponent<Camera>();
|
||||
@@ -61,7 +59,7 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
private void Render(ScriptableRenderContext scriptableRenderContext, Camera _)
|
||||
{
|
||||
// check whether the portal plane is visible from the player camera
|
||||
var frustumPlanes = GeometryUtility.CalculateFrustumPlanes(_playerCamera.camera);
|
||||
var frustumPlanes = GeometryUtility.CalculateFrustumPlanes(_player.camera);
|
||||
if (!GeometryUtility.TestPlanesAABB(frustumPlanes, portal.linkedPortal.portalCamera.screen.bounds))
|
||||
// don't render this portal if it is not visible
|
||||
return;
|
||||
@@ -86,9 +84,9 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
// position portal camera
|
||||
var m = portal.portalTransform.localToWorldMatrix * Portal.HalfRotation *
|
||||
portal.linkedPortal.portalTransform.worldToLocalMatrix *
|
||||
_playerCamera.GetEyeTransform(eye).localToWorldMatrix;
|
||||
_player.GetEye(eye).localToWorldMatrix;
|
||||
transform.SetPositionAndRotation(m.GetPosition(), m.rotation);
|
||||
_camera.projectionMatrix = _playerCamera.camera.GetStereoProjectionMatrix(eye);
|
||||
_camera.projectionMatrix = _player.camera.GetStereoProjectionMatrix(eye);
|
||||
|
||||
// set camera clip plane to portal (otherwise the wall behind the portal would be rendered)
|
||||
// calculating the clip plane: https://computergraphics.stackexchange.com/a/1506
|
||||
|
||||
Reference in New Issue
Block a user