public void TestPracticalSplitScheme(int numSplits, float worldNear, float worldFar, params float[] expectedSplits) { // Act. var splits = FrustumUtility .PracticalSplitScheme(numSplits, worldNear, worldFar) .ToList(); // Assert. Assert.That(splits, Has.Count.EqualTo(numSplits + 1)); Assert.That(splits, Is.EquivalentTo(expectedSplits)); }
public void TestGetWorldSpaceFrustumCorners( float clipSpaceNear, float clipSpaceFar, float expectedX, float expectedY, float expectedZ) { // Arrange. var view = Matrix.CreateLookAt(new Vector3(0, 0, 10), Vector3.Zero, Vector3.Up); var projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4, 1.0f, 0.25f, 10000.0f); var viewProjectionInverse = Matrix.Invert(view * projection); // Act. var corners = FrustumUtility.GetWorldSpaceFrustumCorners( clipSpaceNear, clipSpaceFar, viewProjectionInverse) .ToList(); // Assert. Assert.That(corners, Has.Count.EqualTo(8)); AssertVector3RoughlyEqual(corners[0], new Vector3(expectedX, expectedY, expectedZ)); }