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)); }
private string GetUniqueChunkName() { int chunkPositionX = chunkData.GetWorldX(); int chunkPositionY = chunkData.GetWorldY(); string prefix = "Opaque Chunk: "; return(prefix + chunkPositionX + ", " + chunkPositionY); }
public IEnumerator WorldPositionCanBeSet() { VisualChunkData testCandidate = new VisualChunkData(); testCandidate.SetWorldPosition(5, 9); yield return(null); Assert.That(testCandidate.GetWorldX(), Is.EqualTo(5)); Assert.That(testCandidate.GetWorldY(), Is.EqualTo(9)); }
private ChunkMesh CreateChunkMesh(VisualChunkData chunkData) { ChunkMesh result = new ChunkMesh(chunkData); result.SetMaterial(opaqueChunkMaterial); result.SetRootTransform(transform); Vector3 chunkPosition = new Vector3(chunkData.GetWorldX() * StandardIslandPresenter.CHUNK_EDGE_LENGTH_IN_BLOCKS * 0.5f, 0, chunkData.GetWorldY() * StandardIslandPresenter.CHUNK_EDGE_LENGTH_IN_BLOCKS * 0.5f); result.SetPosition(chunkPosition); return(result); }
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)); }
public void TestThatIslandIsPresentedInChunks() { Island toRender = new Island(64); toRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(15, 0, 15)); toRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(16, 0, 15)); toRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(15, 0, 16)); toRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(16, 0, 16)); StandardIslandPresenter testCandidate = new StandardIslandPresenter(); testCandidate.PresentIsland(toRender); VisualChunkData lastRenderedChunkData = ChunkRendererMock.GetLastRenderChunkCallData(); Assert.That(lastRenderedChunkData.GetWorldX(), Is.EqualTo(1)); }