GetFrustumAspectRatio() приватный статический Метод

private static GetFrustumAspectRatio ( Camera camera ) : float
camera UnityEngine.Camera
Результат float
Пример #1
0
 private static bool GetFrustum(Camera camera, Vector3[] near, Vector3[] far, out float frustumAspect)
 {
     frustumAspect = CameraEditor.GetFrustumAspectRatio(camera);
     if ((double)frustumAspect < 0.0)
     {
         return(false);
     }
     if (far != null)
     {
         far[0] = new Vector3(0.0f, 0.0f, camera.farClipPlane);
         far[1] = new Vector3(0.0f, 1f, camera.farClipPlane);
         far[2] = new Vector3(1f, 1f, camera.farClipPlane);
         far[3] = new Vector3(1f, 0.0f, camera.farClipPlane);
         for (int index = 0; index < 4; ++index)
         {
             far[index] = camera.ViewportToWorldPoint(far[index]);
         }
     }
     if (near != null)
     {
         near[0] = new Vector3(0.0f, 0.0f, camera.nearClipPlane);
         near[1] = new Vector3(0.0f, 1f, camera.nearClipPlane);
         near[2] = new Vector3(1f, 1f, camera.nearClipPlane);
         near[3] = new Vector3(1f, 0.0f, camera.nearClipPlane);
         for (int index = 0; index < 4; ++index)
         {
             near[index] = camera.ViewportToWorldPoint(near[index]);
         }
     }
     return(true);
 }
Пример #2
0
 private static bool GetFrustum(Camera camera, Vector3[] near, Vector3[] far, out float frustumAspect)
 {
     frustumAspect = CameraEditor.GetFrustumAspectRatio(camera);
     if (frustumAspect < 0f)
     {
         return(false);
     }
     if (far != null)
     {
         far[0] = new Vector3(0f, 0f, camera.farClipPlane);
         far[1] = new Vector3(0f, 1f, camera.farClipPlane);
         far[2] = new Vector3(1f, 1f, camera.farClipPlane);
         far[3] = new Vector3(1f, 0f, camera.farClipPlane);
         for (int i = 0; i < 4; i++)
         {
             far[i] = camera.ViewportToWorldPoint(far[i]);
         }
     }
     if (near != null)
     {
         near[0] = new Vector3(0f, 0f, camera.nearClipPlane);
         near[1] = new Vector3(0f, 1f, camera.nearClipPlane);
         near[2] = new Vector3(1f, 1f, camera.nearClipPlane);
         near[3] = new Vector3(1f, 0f, camera.nearClipPlane);
         for (int j = 0; j < 4; j++)
         {
             near[j] = camera.ViewportToWorldPoint(near[j]);
         }
     }
     return(true);
 }
Пример #3
0
        private static bool GetFrustum(Camera camera, Vector3[] near, Vector3[] far, out float frustumAspect)
        {
            frustumAspect = CameraEditor.GetFrustumAspectRatio(camera);
            if (frustumAspect < 0f)
            {
                return(false);
            }
            float num3;
            float num4;
            float num5;
            float num6;

            if (!camera.orthographic)
            {
                float num  = Mathf.Tan(camera.fieldOfView * 0.0174532924f * 0.5f);
                float num2 = num * frustumAspect;
                num3 = num2 * camera.farClipPlane;
                num4 = num * camera.farClipPlane;
                num5 = num2 * camera.nearClipPlane;
                num6 = num * camera.nearClipPlane;
            }
            else
            {
                float num  = camera.orthographicSize;
                float num2 = num * frustumAspect;
                num3 = num2;
                num4 = num;
                num5 = num2;
                num6 = num;
            }
            Matrix4x4 matrix4x = Matrix4x4.TRS(camera.transform.position, camera.transform.rotation, Vector3.one);

            if (far != null)
            {
                far[0] = new Vector3(-num3, -num4, camera.farClipPlane);
                far[1] = new Vector3(-num3, num4, camera.farClipPlane);
                far[2] = new Vector3(num3, num4, camera.farClipPlane);
                far[3] = new Vector3(num3, -num4, camera.farClipPlane);
                for (int i = 0; i < 4; i++)
                {
                    far[i] = matrix4x.MultiplyPoint(far[i]);
                }
            }
            if (near != null)
            {
                near[0] = new Vector3(-num5, -num6, camera.nearClipPlane);
                near[1] = new Vector3(-num5, num6, camera.nearClipPlane);
                near[2] = new Vector3(num5, num6, camera.nearClipPlane);
                near[3] = new Vector3(num5, -num6, camera.nearClipPlane);
                for (int j = 0; j < 4; j++)
                {
                    near[j] = matrix4x.MultiplyPoint(near[j]);
                }
            }
            return(true);
        }