Пример #1
0
 public static Matrix Invert(Matrix input)
 {
     return(new Matrix(Matrix4x4.Invert(input)));
 }
Пример #2
0
		private void UpdateMatrices()
		{
			if (m_dirty)
			{
				m_viewMatrix = XnaMatrix.CreateLookAt(Position, LookAt, Up);
				m_projectionMatrix = IsPerspective
									 ? XnaMatrix.CreatePerspective(ViewportWidth, ViewportHeight, NearPlane, FarPlane)
									 : XnaMatrix.CreateOrthographic(ViewportWidth, ViewportHeight, NearPlane, FarPlane);
				m_toProjection = PostWorldMatrix * m_viewMatrix * m_projectionMatrix;
				m_invToProjection = m_toProjection.Invert();

				var forward = XnaVector.Normalize(LookAt - Position);
				var position = Position + NearPlane * 1.01f * forward;
				var xAxis = XnaVector.Cross(forward, Up);
				var yAxis = XnaVector.Normalize(XnaVector.Cross(xAxis, forward));
				var mat = XnaMatrix.CreateWorld(position, forward, yAxis);
				var vpWidth = Math.Abs(ViewportWidth);
				var vpHeight = Math.Abs(ViewportHeight);
				m_alignToNearPlane = PostWorldMatrix * XnaMatrix.CreateScale(vpWidth * 0.5f, vpHeight * 0.5f, 1) * mat * PostWorldMatrix.Invert();

				m_dirty = false;
			}
		}