public void WieldVertices_NoUVs() { var mesh = new ProcMesh(); mesh.Vertices.Add(new Vec3(0, 0, 0)); mesh.Vertices.Add(new Vec3(0, 0, 0)); mesh.Vertices.Add(new Vec3(1, 0, 0)); mesh.Vertices.Add(new Vec3(0, 0, 0)); mesh.Normals.Add(new Vec3(0, 1, 0)); mesh.Normals.Add(new Vec3(0, 1, 0)); mesh.Normals.Add(new Vec3(1, 0, 0)); mesh.Normals.Add(new Vec3(0, 1, 0)); mesh.Triangles.Add(0); mesh.Triangles.Add(1); mesh.Triangles.Add(2); mesh.Triangles.Add(3); mesh.WieldVertices(); Assert.AreEqual(2, mesh.Vertices.Count); Assert.AreEqual(new Vec3(0, 0, 0), mesh.Vertices[0]); Assert.AreEqual(new Vec3(1, 0, 0), mesh.Vertices[1]); Assert.AreEqual(2, mesh.Normals.Count); Assert.AreEqual(new Vec3(0, 1, 0), mesh.Normals[0]); Assert.AreEqual(new Vec3(1, 0, 0), mesh.Normals[1]); Assert.AreEqual(0, mesh.UVs.Count); Assert.AreEqual(4, mesh.Triangles.Count); Assert.AreEqual(0, mesh.Triangles[0]); Assert.AreEqual(0, mesh.Triangles[1]); Assert.AreEqual(1, mesh.Triangles[2]); Assert.AreEqual(0, mesh.Triangles[3]); }
public void UnequalMeshCounts() { var mesh = new ProcMesh(); mesh.Vertices.Add(new Vec3(0, 0, 0)); mesh.Vertices.Add(new Vec3(0, 0, 0)); mesh.Vertices.Add(new Vec3(1, 0, 0)); mesh.Vertices.Add(new Vec3(0, 0, 0)); mesh.Normals.Add(new Vec3(0, 1, 0)); mesh.Normals.Add(new Vec3(0, 1, 0)); mesh.UVs.Add(new Vec3(0, 0, 0)); mesh.Triangles.Add(0); mesh.Triangles.Add(1); mesh.Triangles.Add(2); mesh.Triangles.Add(3); Assert.Throws <InvalidOperationException>(() => mesh.WieldVertices()); }
/// <summary> /// Iterates over all the blocks in a chunk and generates quads as needed, finally /// remeshing them into the output mesh when complete. /// </summary> void Remesh() { int chunkSize = m_ChunkProperties.ChunkSize.Value; for (int j = 0; j < 6; j++) { for (int t = 0; t < chunkSize; t++) { bool planeActive = false; for (int a = 0; a < chunkSize; a++) { for (int b = 0; b < chunkSize; b++) { var pos = GetAsBlockCoords(j, t, a, b); if (!CanPlaceQuad(m_ChunkProperties, pos, j)) { continue; } var type = m_ChunkProperties.GetBlock(pos); var texture = type.GetTextureID(j); var rotation = SolveRotation(pos, type.GetRotation(j)); var quad = new GreedyMesher.Quad(rotation, texture); m_GreedyMesher.SetQuad(a, b, quad); planeActive = true; } } if (planeActive) { m_GreedyMesher.Mesh(t, j, m_Mesh); } } } if (m_WieldVertices) { m_Mesh.WieldVertices(); } }