private void Awake() { // Set Projector Callbacks ProjectorInterface.SetOnResizeCallback(ID, OnResize); m_camera = gameObject.AddComponent <Camera>(); m_camera.targetDisplay = 8; }
public void RefreshProjector() { ProjectorInterface.Descriptor desc = ProjectorInterface.GetDescriptor(ID); Debug.Log(desc); ProjectorRenderTexture = new RenderTexture(desc.width, desc.height, 16, UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_UNorm); m_ResizeEvent.Set(); }
private void Update() { if (m_camera != null && m_SetProjectionMatrixEvent.WaitOne(0)) { Debug.Log("Projection Matrix Set"); float width = m_projectorDimensions.Width; float height = m_projectorDimensions.Height; m_camera.targetDisplay = -1; m_camera.stereoTargetEye = StereoTargetEyeMask.None; m_camera.aspect = m_aspectRatio; m_camera.fieldOfView = m_fieldOfViewDeg; m_camera.nearClipPlane = m_projectorInstrinsics.near; m_camera.farClipPlane = m_projectorInstrinsics.far; var projectionMatrix = GetProjectionMatrix(); m_camera.projectionMatrix = ConvertRHtoLH(projectionMatrix); m_camera.enabled = false; // Important, we will call render() } if (m_ResizeEvent.WaitOne(0)) { // Create Render Texture m_camera.targetTexture = ProjectorRenderTexture; m_RenderTargetCreateEvent.Set(); } if (ProjectorRenderTexture && m_RenderTargetCreateEvent.WaitOne(0)) { if (ProjectorRenderTexture.IsCreated()) { ProjectorInterface.SetRenderTexture(ID, ProjectorRenderTexture); } else { m_RenderTargetCreateEvent.Set(); } } }