Beispiel #1
0
        public Matrix4x4 GetStereoViewMatrix(StereoscopicEye eye)
        {
            Matrix4x4 matrixx;

            INTERNAL_CALL_GetStereoViewMatrix(this, eye, out matrixx);
            return(matrixx);
        }
 extern public Matrix4x4 GetStereoViewMatrix(StereoscopicEye eye);
Beispiel #3
0
 public void SetStereoViewMatrix(StereoscopicEye eye, Matrix4x4 matrix)
 {
     INTERNAL_CALL_SetStereoViewMatrix(this, eye, ref matrix);
 }
Beispiel #4
0
 private static extern void INTERNAL_CALL_SetStereoViewMatrix(Camera self, StereoscopicEye eye, ref Matrix4x4 matrix);
Beispiel #5
0
 private static extern void INTERNAL_CALL_GetStereoViewMatrix(Camera self, StereoscopicEye eye, out Matrix4x4 value);
Beispiel #6
0
 public Matrix4x4 GetStereoProjectionMatrix(StereoscopicEye eye)
 {
     INTERNAL_CALL_GetStereoProjectionMatrix(this, eye, out Matrix4x4 value);
     return(value);
 }
Beispiel #7
0
 public Matrix4x4 GetStereoNonJitteredProjectionMatrix(StereoscopicEye eye)
 {
     throw new System.NotImplementedException();
 }
 extern public void SetStereoProjectionMatrix(StereoscopicEye eye, Matrix4x4 matrix);
Beispiel #9
0
 public void SetStereoViewMatrix(StereoscopicEye eye, Matrix4x4 matrix)
 {
     INTERNAL_CALL_SetStereoViewMatrix(this, eye, ref matrix);
 }
Beispiel #10
0
 public void CopyStereoDeviceProjectionMatrixToNonJittered(StereoscopicEye eye)
 {
     throw new System.NotImplementedException();
 }
Beispiel #11
0
 private static extern void INTERNAL_CALL_SetStereoViewMatrix(Camera self, StereoscopicEye eye, ref Matrix4x4 matrix);
Beispiel #12
0
 private static extern void INTERNAL_CALL_GetStereoViewMatrix(Camera self, StereoscopicEye eye, out Matrix4x4 value);
Beispiel #13
0
 public Matrix4x4 GetStereoViewMatrix(StereoscopicEye eye)
 {
     Matrix4x4 matrixx;
     INTERNAL_CALL_GetStereoViewMatrix(this, eye, out matrixx);
     return matrixx;
 }
 extern public void CopyStereoDeviceProjectionMatrixToNonJittered(StereoscopicEye eye);
Beispiel #15
0
 public Matrix4x4 GetStereoViewMatrix(StereoscopicEye eye)
 {
     throw new System.NotImplementedException();
 }
 extern public Matrix4x4 GetStereoProjectionMatrix(StereoscopicEye eye);
Beispiel #17
0
 public void SetStereoViewMatrix(StereoscopicEye eye, Matrix4x4 matrix)
 {
     throw new System.NotImplementedException();
 }
 extern public void SetStereoViewMatrix(StereoscopicEye eye, Matrix4x4 matrix);
Beispiel #19
0
        /// <summary>
        /// Update the mesh of the GameObject. The mesh represent the quad where the raymarching algorithm will perform
        /// </summary>
        /// <param name="camera">The camera used to determine the screen boundaries of the raymarching algorithm</param>
        /// <param name="inRT">Will be object be drawn in a render texture?</param>
        private void UpdateMesh(Camera camera, bool inRT)
        {
            Vector2 minScreenPos = new Vector2(1, 1);
            Vector2 maxScreenPos = new Vector2(-1, -1);

            if (camera != null)
            {
                StereoscopicEye[] enumEye = new StereoscopicEye[2];
                enumEye[0] = StereoscopicEye.Left;
                enumEye[1] = StereoscopicEye.Right;

                foreach (StereoscopicEye eye in enumEye)
                {
                    //Determine the part of the object on screen to narrow down the viewport
                    Matrix4x4 mvp = (GL.GetGPUProjectionMatrix(camera.GetStereoProjectionMatrix(eye), inRT) * camera.GetStereoViewMatrix(eye) * transform.localToWorldMatrix);

                    Vector4[] localPos = new Vector4[8];
                    localPos[0] = m_mesh.bounds.min; localPos[0].w = 1.0f;
                    localPos[1] = m_mesh.bounds.max; localPos[1].w = 1.0f;
                    localPos[2] = new Vector4(m_mesh.bounds.min.x, m_mesh.bounds.min.y, m_mesh.bounds.max.z, 1.0f);
                    localPos[3] = new Vector4(m_mesh.bounds.min.x, m_mesh.bounds.max.y, m_mesh.bounds.min.z, 1.0f);
                    localPos[4] = new Vector4(m_mesh.bounds.max.x, m_mesh.bounds.min.y, m_mesh.bounds.min.z, 1.0f);
                    localPos[5] = new Vector4(m_mesh.bounds.max.x, m_mesh.bounds.min.y, m_mesh.bounds.max.z, 1.0f);
                    localPos[6] = new Vector4(m_mesh.bounds.max.x, m_mesh.bounds.max.y, m_mesh.bounds.min.z, 1.0f);
                    localPos[7] = new Vector4(m_mesh.bounds.min.x, m_mesh.bounds.max.y, m_mesh.bounds.max.z, 1.0f);

                    Vector4 screenPos;

                    for (int i = 0; i < 8; i++)
                    {
                        screenPos  = mvp * localPos[i];
                        screenPos /= screenPos.w;
                        //Min
                        if (minScreenPos.x > screenPos.x)
                        {
                            minScreenPos.x = screenPos.x;
                        }
                        if (minScreenPos.y > screenPos.y)
                        {
                            minScreenPos.y = screenPos.y;
                        }

                        //Max
                        if (maxScreenPos.x < screenPos.x)
                        {
                            maxScreenPos.x = screenPos.x;
                        }
                        if (maxScreenPos.y < screenPos.y)
                        {
                            maxScreenPos.y = screenPos.y;
                        }
                    }
                }

                //Screen border
                minScreenPos.x = Math.Max(minScreenPos.x, -1.0f);
                minScreenPos.y = Math.Max(minScreenPos.y, -1.0f);
                maxScreenPos.x = Math.Min(maxScreenPos.x, 1.0f);
                maxScreenPos.y = Math.Min(maxScreenPos.y, 1.0f);

                //Update the mesh
                Vector3[] meshPos = new Vector3[4];
                meshPos[0] = new Vector3(minScreenPos.x, minScreenPos.y, 0);
                meshPos[1] = new Vector3(maxScreenPos.x, minScreenPos.y, 0);
                meshPos[2] = new Vector3(maxScreenPos.x, maxScreenPos.y, 0);
                meshPos[3] = new Vector3(minScreenPos.x, maxScreenPos.y, 0);

                m_mesh.vertices = meshPos;
                m_mesh.UploadMeshData(false);
                //m_screenTextureMesh.vertices = meshPos;
                //m_screenTextureMesh.UploadMeshData(false);
            }
        }