/// <inheritdoc/> public void RebuildFace(Topology.Face face, DynamicMesh.IIndexedVertexAttributes vertexAttributes) { foreach (var edge in face.edges) { _addCornerVertices(edge, vertexAttributes); } }
/// <inheritdoc/> public void BuildFace(Topology.Face face, DynamicMesh.IIndexedVertexAttributes vertexAttributes, IList <int> triangleIndices) { int neighborCount = face.neighborCount; int currentOuterVertexIndex = vertexAttributes.index; if (_ringDepth > 1) { int nextOuterVertexIndex = currentOuterVertexIndex + _ringDepth; for (int neighborIndex = 1; neighborIndex < neighborCount; ++neighborIndex) { int outerDepthIndex = 0; for (int innerDepthIndex = 1; innerDepthIndex < _ringDepth; ++innerDepthIndex) { triangleIndices.Add(currentOuterVertexIndex + outerDepthIndex); triangleIndices.Add(nextOuterVertexIndex + outerDepthIndex); triangleIndices.Add(currentOuterVertexIndex + innerDepthIndex); triangleIndices.Add(currentOuterVertexIndex + innerDepthIndex); triangleIndices.Add(nextOuterVertexIndex + outerDepthIndex); triangleIndices.Add(nextOuterVertexIndex + innerDepthIndex); outerDepthIndex = innerDepthIndex; } currentOuterVertexIndex = nextOuterVertexIndex; nextOuterVertexIndex += _ringDepth; } // Triangles that wrap-around and reuse the first column of vertices. { nextOuterVertexIndex = vertexAttributes.index; int outerDepthIndex = 0; for (int innerDepthIndex = 1; innerDepthIndex < _ringDepth; ++innerDepthIndex) { triangleIndices.Add(currentOuterVertexIndex + outerDepthIndex); triangleIndices.Add(nextOuterVertexIndex + outerDepthIndex); triangleIndices.Add(currentOuterVertexIndex + innerDepthIndex); triangleIndices.Add(currentOuterVertexIndex + innerDepthIndex); triangleIndices.Add(nextOuterVertexIndex + outerDepthIndex); triangleIndices.Add(nextOuterVertexIndex + innerDepthIndex); outerDepthIndex = innerDepthIndex; } } } int innerRingFirstVertexIndex = vertexAttributes.index + _ringDepth - 1; int innerRingNextVertexIndex = innerRingFirstVertexIndex + _ringDepth; for (int triangleIndex = 2; triangleIndex < neighborCount; ++triangleIndex) { triangleIndices.Add(innerRingFirstVertexIndex); triangleIndices.Add(innerRingNextVertexIndex); innerRingNextVertexIndex += _ringDepth; triangleIndices.Add(innerRingNextVertexIndex); } RebuildFace(face, vertexAttributes); }
/// <inheritdoc/> public void BuildFace(Topology.Face face, DynamicMesh.IIndexedVertexAttributes vertexAttributes, IList <int> triangleIndices) { int neighborCount = face.neighborCount; int currentVertexIndex = vertexAttributes.index; // __(0)__ // __-- | --__ // (1) | (2)__ // \ | / \ --__ // \ A | B / \ --__ // \ | / \ --__ // \ | / \ --__ // \ | / \ --(5) // \ | / \ / // \ | / C \ D / // (3)__ \ / // --__ \ / // --__ \ / // --__ \ / // --__ \ / // --(7) for (int neighborIndex = 0; neighborIndex < neighborCount; ++neighborIndex) { // A (1->0->3) triangleIndices.Add(currentVertexIndex + 1); triangleIndices.Add(currentVertexIndex + 0); triangleIndices.Add(currentVertexIndex + 3); // B (3->0->2) triangleIndices.Add(currentVertexIndex + 3); triangleIndices.Add(currentVertexIndex + 0); triangleIndices.Add(currentVertexIndex + 2); // C (3->2->7) triangleIndices.Add(currentVertexIndex + 3); triangleIndices.Add(currentVertexIndex + 2); triangleIndices.Add(currentVertexIndex + 7); // D (7->2->1) triangleIndices.Add(currentVertexIndex + 7); triangleIndices.Add(currentVertexIndex + 2); triangleIndices.Add(currentVertexIndex + 5); currentVertexIndex += 4; } triangleIndices[triangleIndices.Count - 4] = vertexAttributes.index + 3; triangleIndices[triangleIndices.Count - 3] = vertexAttributes.index + 3; triangleIndices[triangleIndices.Count - 1] = vertexAttributes.index + 1; int forwardVertexIndex = vertexAttributes.index + 3; int backwardVertexIndex = vertexAttributes.index + neighborCount * 4 - 1; int triangleIndex = 2; while (triangleIndex < neighborCount) { triangleIndices.Add(backwardVertexIndex); triangleIndices.Add(forwardVertexIndex); backwardVertexIndex -= 4; triangleIndices.Add(backwardVertexIndex); if (++triangleIndex == neighborCount) { break; } triangleIndices.Add(backwardVertexIndex); triangleIndices.Add(forwardVertexIndex); forwardVertexIndex += 4; triangleIndices.Add(forwardVertexIndex); ++triangleIndex; } RebuildFace(face, vertexAttributes); }