void OnPreCull() { if (_core != null) { // Specify the correct eye. ZSCore.Eye eye = ZSCore.Eye.Left; if (_core.AreEyesSwapped()) { eye = ZSCore.Eye.Right; } if (_core.CurrentCamera != null && _stereoRig != null) { // Grab the current monoscopic camera's transform and apply it // to the ZSStereoRig. _stereoRig.transform.position = _core.CurrentCamera.transform.position; _stereoRig.transform.rotation = _core.CurrentCamera.transform.rotation; _stereoRig.transform.localScale = _core.CurrentCamera.transform.localScale; } // Calculate left camera's transform. Matrix4x4 viewMatrixInverse = ZSCore.ConvertFromRightToLeft(_core.GetViewMatrix(eye).inverse); transform.localPosition = viewMatrixInverse.GetColumn(3); transform.localRotation = Quaternion.LookRotation(viewMatrixInverse.GetColumn(2), viewMatrixInverse.GetColumn(1)); // Set the left camera's projection matrix. gameObject.camera.projectionMatrix = _core.GetProjectionMatrix(eye); } GL.IssuePluginEvent((int)ZSCore.GlPluginEventType.RenderTargetLeft); }
void OnPreCull() { if (_core != null) { // Specify the correct eye. ZSCore.Eye eye = ZSCore.Eye.Right; if (_core.AreEyesSwapped()) { eye = ZSCore.Eye.Left; } // Calculate right camera's transform. Matrix4x4 viewMatrixInverse = ZSCore.ConvertFromRightToLeft(_core.GetViewMatrix(eye).inverse); transform.localPosition = viewMatrixInverse.GetColumn(3); transform.localRotation = Quaternion.LookRotation(viewMatrixInverse.GetColumn(2), viewMatrixInverse.GetColumn(1)); // Set the right camera's projection matrix. gameObject.GetComponent <Camera>().projectionMatrix = _core.GetProjectionMatrix(eye); } GL.IssuePluginEvent((int)ZSCore.GlPluginEventType.RenderTargetRight); }
void OnPreCull() { if (_core != null) { // Specify the correct eye. ZSCore.Eye eye = ZSCore.Eye.Center; // Calculate right camera's transform. Matrix4x4 viewMatrixInverse = ZSCore.ConvertFromRightToLeft(_core.GetViewMatrix(eye).inverse); transform.localPosition = viewMatrixInverse.GetColumn(3); transform.localRotation = Quaternion.LookRotation(viewMatrixInverse.GetColumn(2), viewMatrixInverse.GetColumn(1)); // Set the right camera's projection matrix. gameObject.GetComponent <Camera>().projectionMatrix = _core.GetProjectionMatrix(eye); } // Signal that the frame is done and reset the Unity's OpenGl state. GL.IssuePluginEvent((int)ZSCore.GlPluginEventType.FrameDone); GL.IssuePluginEvent((int)ZSCore.GlPluginEventType.DisableStereo); GL.InvalidateState(); gameObject.GetComponent <Camera>().enabled = false; }