Example #1
0
        public void GetCulledVertices_Test()
        {
            Chunk chunk = new Chunk();

            //Covering left and right of a block.
            chunk.SetBlock(new Vector3(5, 5, 5), BlockType.Dirt);
            chunk.SetBlock(new Vector3(4, 5, 5), BlockType.Dirt);
            chunk.SetBlock(new Vector3(6, 5, 5), BlockType.Dirt);

            int usedVertCount = 0;
            var result        = BlockMesh.GetCulledVertices(chunk.SidesExposedToAir(new Vector3(5, 5, 5)), out usedVertCount,
                                                            new Vector3(0, 0, 0)).ToList();

            Assert.AreEqual(new Vector3[]
            {
                new Vector3(-0.5f, 0.5f, 0.5f),   //Left Top Front 7
                new Vector3(0.5f, 0.5f, 0.5f),    //Right Top Front 6
                new Vector3(0.5f, 0.5f, -0.5f),   //Right Top Back 2
                new Vector3(-0.5f, 0.5f, -0.5f),  //Left Top Back 3
                new Vector3(-0.5f, -0.5f, -0.5f), //Left Bottom Back 0
                new Vector3(0.5f, -0.5f, -0.5f),  //Right Bottom Back 1
                new Vector3(0.5f, -0.5f, 0.5f),   //Right Bottom Front 5
                new Vector3(-0.5f, -0.5f, 0.5f),  //Left Bottom Front 4
                new Vector3(-0.5f, -0.5f, -0.5f), //Left Bottom Back 0
                new Vector3(0.5f, -0.5f, -0.5f),  //Right Bottom Back 1
                new Vector3(0.5f, 0.5f, -0.5f),   //Right Top Back 2
                new Vector3(-0.5f, 0.5f, -0.5f),  //Left Top Back 3
                new Vector3(-0.5f, -0.5f, 0.5f),  //Left Bottom Front 4
                new Vector3(0.5f, -0.5f, 0.5f),   //Right Bottom Front 5
                new Vector3(0.5f, 0.5f, 0.5f),    //Right Top Front 6
                new Vector3(-0.5f, 0.5f, 0.5f)    //Left Top Front 7
            }, result);

            Assert.AreEqual(16, usedVertCount);
        }