public void CanCreateFieldOfViewPerspectiveMatrix() { const float fieldOfView = MathUtility.PI_OVER_2; Matrix3D projectionMatrix = Matrix3D.CreatePerspectiveFieldOfView(fieldOfView, 1, 1, 200); Matrix otherProjectionMatrix = Matrix.PerspectiveFovRH(fieldOfView, 1, 1, 200); AssertMatricesAreEqual(otherProjectionMatrix, projectionMatrix); }
public void CanTransformPointWithPerspectiveProjection() { const float fieldOfView = MathUtility.PI_OVER_2; Matrix3D actualProjectionMatrix = Matrix3D.CreatePerspectiveFieldOfView(fieldOfView, 1, 1, 200); Matrix expectedProjectionMatrix = Matrix.PerspectiveFovRH(fieldOfView, 1, 1, 200); Point4D actualPoint = new Point4D(100, 100, -100, 1); Vector4 expectedPoint = new Vector4(100, 100, -100, 1); Point4D actualTransformedPoint = actualProjectionMatrix.Transform(actualPoint); Vector4 expectedTransformedPoint = Vector4.Transform(expectedPoint, expectedProjectionMatrix); AssertPointsAreEqual(expectedTransformedPoint, actualTransformedPoint); }
public Renderer(Device device, Model model, int width, int height, Transform3D cameraTransform) { _device = device; _model = model; _cameraTransform = cameraTransform; const float fov = MathUtility.PI_OVER_4; AxisAlignedBoundingBox bounds = _model.SourceScene.Bounds; Vector3D max = bounds.Size; float radius = System.Math.Max(max.X, System.Math.Max(max.Y, max.Z)); _projection = Matrix3D.CreatePerspectiveFieldOfView( fov, width / (float)height, 1.0f, radius * 10); float dist = radius / MathUtility.Sin(fov / 2); _view = Matrix3D.CreateLookAt( bounds.Center + Vector3D.Backward * dist, Vector3D.Forward, Vector3D.Up); }
public override Matrix3D GetProjectionMatrix(float aspectRatio) { return(Matrix3D.CreatePerspectiveFieldOfView(FieldOfView, aspectRatio, NearPlaneDistance, FarPlaneDistance)); }
public double[] GetProjectionMatrix(float aspectRatio) { return(Matrix3D.CreatePerspectiveFieldOfView(MathUtility.PI_OVER_4, aspectRatio, 0.1f, 1000000f).ToArray()); }