Axiom.Core.Frustum.CalculateProjectionParameters C# (CSharp) Method

CalculateProjectionParameters() protected method

protected CalculateProjectionParameters ( Real &vpLeft, Real &vpRight, Real &vpBottom, Real &vpTop ) : void
vpLeft Real
vpRight Real
vpBottom Real
vpTop Real
return void
		protected void CalculateProjectionParameters( out Real vpLeft, out Real vpRight, out Real vpBottom, out Real vpTop )
		{
			if ( _customProjectionMatrix )
			{
				// Convert clipspace corners to camera space
				Matrix4 invProj = _projectionMatrix.Inverse();
				Vector3 topLeft = new Vector3( -0.5f, 0.5f, 0.0f );
				Vector3 bottomRight = new Vector3( 0.5f, -0.5f, 0.0f );

				topLeft = invProj * topLeft;
				bottomRight = invProj * bottomRight;

				vpLeft = topLeft.x;
				vpTop = topLeft.y;
				vpRight = bottomRight.x;
				vpBottom = bottomRight.y;
			}
			else if ( _frustumExtentsManuallySet )
			{
				vpLeft = _left;
				vpRight = _right;
				vpTop = _top;
				vpBottom = _bottom;
			}
			// Calculate general projection parameters
			else if ( ProjectionType == Projection.Perspective )
			{
				// Calculate general projection parameters

				float thetaY = _fieldOfView * 0.5f;
				float tanThetaY = Utility.Tan( thetaY );
				float tanThetaX = tanThetaY * _aspectRatio;

				// Unknown how to apply frustum offset to orthographic camera, just ignore here
				float nearFocal = _nearDistance / _focalLength;
				float nearOffsetX = _frustumOffset.x * nearFocal;
				float nearOffsetY = _frustumOffset.y * nearFocal;
				float half_w = tanThetaX * _nearDistance;
				float half_h = tanThetaY * _nearDistance;

				vpLeft = -half_w + nearOffsetX;
				vpRight = +half_w + nearOffsetX;
				vpBottom = -half_h + nearOffsetY;
				vpTop = +half_h + nearOffsetY;

				_left = vpLeft;
				_right = vpRight;
				_top = vpTop;
				_bottom = vpBottom;
			}
			else //if (ProjectionType == Projection.Orthographic)
			{
				// Unknown how to apply frustum offset to orthographic camera, just ignore here
				float half_w = OrthoWindowWidth * 0.5f;
				float half_h = OrthoWindowHeight * 0.5f;

				vpLeft = -half_w;
				vpRight = +half_w;
				vpBottom = -half_h;
				vpTop = +half_h;

				_left = vpLeft;
				_right = vpRight;
				_top = vpTop;
				_bottom = vpBottom;
			}
		}