コード例 #1
0
        public IEnumerator FlattenedUvCoordinatesAreCalculatedFromTemporaryBuffer()
        {
            VisualChunkData testCandidate = new VisualChunkData();

            float[] uvCoordinates       = { 0.4f, 1.5f };
            float[] secondUvCoordinates = { 9.1f, 4.4f };
            float[] thirdUvCoordinates  = { 7.7f, 8.3f };

            testCandidate.SetUpWithNumberOfBlocksInChunk(3);
            testCandidate.AddUvCoordinatesToTemporaryBuffer(uvCoordinates);
            testCandidate.AddUvCoordinatesToTemporaryBuffer(secondUvCoordinates);
            testCandidate.AddUvCoordinatesToTemporaryBuffer(thirdUvCoordinates);
            testCandidate.AddNormalsToTemporaryBuffer(new float[0]);
            testCandidate.AddNormalsToTemporaryBuffer(new float[0]);
            testCandidate.AddNormalsToTemporaryBuffer(new float[0]);
            testCandidate.AddIndicesToTemporaryBuffer(new int[0]);
            testCandidate.AddIndicesToTemporaryBuffer(new int[0]);
            testCandidate.AddIndicesToTemporaryBuffer(new int[0]);
            testCandidate.AddVerticesToTemporaryBuffer(new float[0]);
            testCandidate.AddVerticesToTemporaryBuffer(new float[0]);
            testCandidate.AddVerticesToTemporaryBuffer(new float[0]);

            testCandidate.BuildChunkData();
            float[] result = testCandidate.GetUvCoordinates();

            yield return(null);

            Assert.That(result.Length, Is.EqualTo(6));
            Assert.That(result[0], Is.EqualTo(0.4f));
            Assert.That(result[1], Is.EqualTo(1.5f));
            Assert.That(result[2], Is.EqualTo(9.1f));
            Assert.That(result[3], Is.EqualTo(4.4f));
            Assert.That(result[4], Is.EqualTo(7.7f));
            Assert.That(result[5], Is.EqualTo(8.3f));
        }
コード例 #2
0
        private void UpdateGeometryUvs(Mesh mesh)
        {
            float[] flatUvs = chunkData.GetUvCoordinates();

            Vector2[] uvsAsVectors = RenderingTypeConverter.ConvertFlatFloatArrayToVector2Array(flatUvs);
            mesh.SetUVs(0, uvsAsVectors);
        }
コード例 #3
0
        public void TestThatRenderingBlocksInOnePointOneChunkIsDoneProperly()
        {
            Island islandToRender = new Island(31);

            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(18, 2, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(19, 2, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(18, 2, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(19, 2, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(18, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(19, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(18, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(19, 1, 19));

            ChunkPresenter testCandidate = new ChunkPresenter();

            testCandidate.PresentChunk(islandToRender, 1, 1);

            VisualChunkData lastRenderedChunkData = ChunkRendererMock.GetLastRenderChunkCallData();

            Assert.That(lastRenderedChunkData, Is.Not.Null);
            Assert.That(lastRenderedChunkData.GetWorldX(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetWorldY(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetVertices().Length, Is.EqualTo(288));
            Assert.That(lastRenderedChunkData.GetIndices().Length, Is.EqualTo(144));
            Assert.That(lastRenderedChunkData.GetNormals().Length, Is.EqualTo(288));
            Assert.That(lastRenderedChunkData.GetUvCoordinates().Length, Is.EqualTo(192));
        }
コード例 #4
0
        public void TestThatCoveredMiddleBlockIsNotRendered()
        {
            Island islandToRender = new Island(46);

            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 20));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 20));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 20));

            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 20));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 20));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 20));

            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 20));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 20));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 20));

            ChunkPresenter testCandidate = new ChunkPresenter();

            testCandidate.PresentChunk(islandToRender, 2, 1);

            VisualChunkData lastRenderedChunkData = ChunkRendererMock.GetLastRenderChunkCallData();

            Assert.That(lastRenderedChunkData, Is.Not.Null);
            Assert.That(lastRenderedChunkData.GetWorldX(), Is.EqualTo(2));
            Assert.That(lastRenderedChunkData.GetWorldY(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetVertices().Length, Is.EqualTo(648));
            Assert.That(lastRenderedChunkData.GetIndices().Length, Is.EqualTo(324));
            Assert.That(lastRenderedChunkData.GetNormals().Length, Is.EqualTo(648));
            Assert.That(lastRenderedChunkData.GetUvCoordinates().Length, Is.EqualTo(432));
        }