Esempio n. 1
0
        public void Planed_Distance()
        {
            Planed plane = new Planed(Vertex3d.UnitZ, 10.0f);

            Assert.AreEqual(-10.0f, plane.GetDistance(new Vertex3d(0.0f, 0.0f, 0.0f)));
            Assert.AreEqual(0.0f, plane.GetDistance(new Vertex3d(0.0f, 0.0f, 10.0f)));
            Assert.AreEqual(+10.0f, plane.GetDistance(new Vertex3d(0.0f, 0.0f, 20.0f)));
        }
Esempio n. 2
0
        public void Planed_NegZPlane()
        {
            Planed plane = new Planed(-Vertex3d.UnitZ, 0.0f);

            // Positive half-space
            Vertex3d[] pointsPosZ =
            {
                new Vertex3d(+1.0f, +1.0f, 1.0f),
                new Vertex3d(+1.0f, -1.0f, 1.0f),
                new Vertex3d(-1.0f, +1.0f, 1.0f),
                new Vertex3d(-1.0f, -1.0f, 1.0f),
            };

            foreach (Vertex3d v in pointsPosZ)
            {
                Assert.IsTrue(plane.GetDistance(v) < 0.0f);
            }

            // Negative half-space
            Vertex3d[] pointsNegZ =
            {
                new Vertex3d(+1.0f, +1.0f, -1.0f),
                new Vertex3d(+1.0f, -1.0f, -1.0f),
                new Vertex3d(-1.0f, +1.0f, -1.0f),
                new Vertex3d(-1.0f, -1.0f, -1.0f),
            };

            foreach (Vertex3d v in pointsNegZ)
            {
                Assert.IsTrue(plane.GetDistance(v) > 0.0f);
            }

            // On-plane
            Vertex3d[] pointsZero =
            {
                new Vertex3d(+1.0f, +1.0f, 0.0f),
                new Vertex3d(+1.0f, -1.0f, 0.0f),
                new Vertex3d(-1.0f, +1.0f, 0.0f),
                new Vertex3d(-1.0f, -1.0f, 0.0f),
            };

            foreach (Vertex3d v in pointsZero)
            {
                Assert.AreEqual(0.0f, plane.GetDistance(v));
            }
        }
Esempio n. 3
0
        // [Test]
        public void Planed_ProjectionFrustum()
        {
            Matrix4x4d projectionMatrix = Matrix4x4d.Perspective(90.0f, 1.0f, 1.0f, 10.0f);
            Matrix4x4d modelMatrix      = Matrix4x4d.Identity;

            Matrix4x4d frustumMatrix = projectionMatrix * modelMatrix;

            Planed planeL = Planed.GetFrustumLeftPlane(frustumMatrix);
            Planed planeR = Planed.GetFrustumRightPlane(frustumMatrix);
            Planed planeB = Planed.GetFrustumBottomPlane(frustumMatrix);
            Planed planeT = Planed.GetFrustumTopPlane(frustumMatrix);

            Planed planeN = Planed.GetFrustumNearPlane(frustumMatrix);

            Assert.IsTrue(planeN.GetDistance(new Vertex3d(0.0f, 0.0f, -5.0f)) > 0.0f);

            Planed planeF = Planed.GetFrustumFarPlane(frustumMatrix);
            // Assert.IsTrue(planeF.GetDistance(new Vertex3d(0.0f, 0.0f, -5.0f)) > 0.0f);
        }