mirror of
https://github.com/PashaBibko/The-Mobius-Line.git
synced 2026-04-04 01:49:07 +00:00
Portal rendering works
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ public class PortalCamera : MonoBehaviour
|
|||||||
|
|
||||||
// Private members //
|
// Private members //
|
||||||
|
|
||||||
public PortalManager m_DisplayPortal;
|
PortalManager m_DisplayPortal;
|
||||||
PortalManager m_CapturePortal;
|
PortalManager m_CapturePortal;
|
||||||
|
|
||||||
RenderTexture m_RenderTexture;
|
RenderTexture m_RenderTexture;
|
||||||
@@ -16,9 +16,16 @@ public class PortalCamera : MonoBehaviour
|
|||||||
|
|
||||||
Camera m_Camera;
|
Camera m_Camera;
|
||||||
|
|
||||||
|
Vector3 m_Rot;
|
||||||
|
|
||||||
// Initialistion function for the camera
|
// Initialistion function for the camera
|
||||||
public void InitCamera(MeshRenderer renderer, PortalManager creator)
|
public void InitCamera(MeshRenderer renderer, PortalManager creator, Vector3 rot)
|
||||||
{
|
{
|
||||||
|
Debug.Log(rot);
|
||||||
|
|
||||||
|
//
|
||||||
|
m_Rot = rot;
|
||||||
|
|
||||||
//
|
//
|
||||||
m_CapturePortal = creator.Linked();
|
m_CapturePortal = creator.Linked();
|
||||||
m_DisplayPortal = creator;
|
m_DisplayPortal = creator;
|
||||||
@@ -50,10 +57,10 @@ public class PortalCamera : MonoBehaviour
|
|||||||
Transform t = m_CapturePortal.transform.parent;
|
Transform t = m_CapturePortal.transform.parent;
|
||||||
transform.parent.position = (t.position) + (-t.forward * offset.z) + (t.up * offset.y) + (-t.right * offset.x);
|
transform.parent.position = (t.position) + (-t.forward * offset.z) + (t.up * offset.y) + (-t.right * offset.x);
|
||||||
|
|
||||||
//
|
// Calculate angle stuff
|
||||||
float angle = Quaternion.Angle(m_DisplayPortal.transform.parent.rotation, m_CapturePortal.transform.parent.rotation);
|
float angle = Quaternion.Angle(m_DisplayPortal.transform.parent.rotation, m_CapturePortal.transform.parent.rotation);
|
||||||
Quaternion rotDif = Quaternion.AngleAxis(angle, Vector3.up);
|
Quaternion rotDif = Quaternion.AngleAxis(angle, Vector3.up);
|
||||||
Vector3 newCamDir = rotDif * CameraController.Instance().transform.forward;
|
Vector3 newCamDir = rotDif * CameraController.Instance().transform.forward;
|
||||||
transform.parent.rotation = Quaternion.LookRotation(newCamDir, Vector3.up);
|
transform.parent.eulerAngles = Quaternion.LookRotation(newCamDir, Vector3.up).eulerAngles + m_Rot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ public class PortalManager : MonoBehaviour
|
|||||||
|
|
||||||
[Header("Points")]
|
[Header("Points")]
|
||||||
[SerializeField] Transform m_PlayerPoint;
|
[SerializeField] Transform m_PlayerPoint;
|
||||||
[SerializeField] Transform m_Pos;
|
|
||||||
[SerializeField] Transform m_Rot;
|
|
||||||
|
|
||||||
PortalManager m_OtherManager;
|
PortalManager m_OtherManager;
|
||||||
PortalCamera m_PortalCamera;
|
PortalCamera m_PortalCamera;
|
||||||
@@ -36,7 +34,7 @@ public class PortalManager : MonoBehaviour
|
|||||||
m_PortalCamera = cam.GetComponentInChildren<PortalCamera>();
|
m_PortalCamera = cam.GetComponentInChildren<PortalCamera>();
|
||||||
|
|
||||||
// Initialises the camera so it renders to the portal and not the screen
|
// Initialises the camera so it renders to the portal and not the screen
|
||||||
m_PortalCamera.InitCamera(m_PortalRenderer, this);
|
m_PortalCamera.InitCamera(m_PortalRenderer, this, transform.parent.localEulerAngles * 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates is called every frame
|
// Updates is called every frame
|
||||||
|
|||||||
Reference in New Issue
Block a user