本文整理汇总了C#中Mesh.FindMeshEdges方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.FindMeshEdges方法的具体用法?C# Mesh.FindMeshEdges怎么用?C# Mesh.FindMeshEdges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.FindMeshEdges方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MeshEdgeSplitAndUnsplitTests
public void MeshEdgeSplitAndUnsplitTests()
{
// split edge and create vert (not part of a polygon, just a wire mesh)
{
Mesh testMesh = new Mesh();
Vertex leftVertex = testMesh.CreateVertex(-1, 0, 0);
Vertex rightVertex = testMesh.CreateVertex(1, 0, 0);
MeshEdge edgeToSplit = testMesh.CreateMeshEdge(leftVertex, rightVertex);
Assert.IsTrue(edgeToSplit.VertexOnEnd[0] == leftVertex, "The edgeToSplit is connected the way we expect.");
Assert.IsTrue(edgeToSplit.VertexOnEnd[1] == rightVertex, "The edgeToSplit is connected the way we expect.");
Assert.IsTrue(leftVertex.firstMeshEdge == edgeToSplit, "First edge of left vertex is the edge.");
Assert.IsTrue(rightVertex.firstMeshEdge == edgeToSplit, "First edge of right vertex is the edge.");
MeshEdge edgeCreatedDuringSplit;
Vertex vertexCreatedDuringSplit;
testMesh.SplitMeshEdge(edgeToSplit, out vertexCreatedDuringSplit, out edgeCreatedDuringSplit);
Assert.IsTrue(edgeToSplit.VertexOnEnd[1] == vertexCreatedDuringSplit);
Assert.IsTrue(edgeToSplit.NextMeshEdgeFromEnd[0] == edgeToSplit);
Assert.IsTrue(edgeToSplit.NextMeshEdgeFromEnd[1] == edgeCreatedDuringSplit);
Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[0] == vertexCreatedDuringSplit, "The edgeCreatedDuringSplit is connected the way we expect.");
Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[1] == rightVertex, "The edgeCreatedDuringSplit is connected the way we expect.");
Assert.IsTrue(vertexCreatedDuringSplit.firstMeshEdge == edgeCreatedDuringSplit, "First edge of new vertex is the edge we split.");
Assert.IsTrue(edgeCreatedDuringSplit.NextMeshEdgeFromEnd[0] == edgeToSplit, "The next edge is the one we created.");
Assert.IsTrue(edgeCreatedDuringSplit.NextMeshEdgeFromEnd[1] == edgeCreatedDuringSplit, "The other side is connected to itself.");
testMesh.UnsplitMeshEdge(edgeToSplit, vertexCreatedDuringSplit);
Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[0] == null && edgeCreatedDuringSplit.VertexOnEnd[1] == null, "The edgeCreatedDuringSplit is no longer connected to Vertices.");
Assert.IsTrue(edgeToSplit.VertexOnEnd[0] == leftVertex, "The unsplit edge is connected back the way it was.");
Assert.IsTrue(edgeToSplit.VertexOnEnd[1] == rightVertex, "The unsplit edge is connected back the way it was.");
}
// split a polygon's edge and create vert
{
Mesh testMesh = new Mesh();
Vertex leftVertex = testMesh.CreateVertex(-1, 0, 1);
Vertex rightVertex = testMesh.CreateVertex(1, 0, 1);
Vertex topVertex = testMesh.CreateVertex(-1, 0, -1);
Face newFace = testMesh.CreateFace(new Vertex[] { rightVertex, topVertex, leftVertex });
Assert.IsTrue(newFace.normal == Vector3.UnitY);
Assert.IsTrue(newFace.NumVertices == 3, "We have a 3 vertex face.");
Assert.IsTrue(newFace.FaceEdgeLoopIsGood());
MeshEdge edgeToSplit = testMesh.FindMeshEdges(leftVertex, rightVertex)[0];
Assert.IsTrue(edgeToSplit.VertexOnEnd[0] == leftVertex, "The edgeToSplit is connected the way we expect.");
Assert.IsTrue(edgeToSplit.VertexOnEnd[1] == rightVertex, "The edgeToSplit is connected the way we expect.");
MeshEdge edgeCreatedDuringSplit;
Vertex vertexCreatedDuringSplit;
SaveDebugInfo(testMesh);
testMesh.SplitMeshEdge(edgeToSplit, out vertexCreatedDuringSplit, out edgeCreatedDuringSplit);
SaveDebugInfo(testMesh);
Assert.IsTrue(newFace.NumVertices == 4, "After SplitEdge it is a 4 vertex face.");
Assert.IsTrue(newFace.FaceEdgeLoopIsGood());
Assert.IsTrue(edgeCreatedDuringSplit.firstFaceEdge != null, "First face edge is connected.");
Assert.IsTrue(edgeCreatedDuringSplit.firstFaceEdge.meshEdge == edgeCreatedDuringSplit, "The new face edge is connected to the created mesh edge.");
Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[0] != null && edgeCreatedDuringSplit.VertexOnEnd[1] != null, "The edgeCreatedDuringSplit is connected to Vertices.");
Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[0].GetConnectedMeshEdges().Contains(edgeCreatedDuringSplit), "The vertex connected to this mesh edege contains this mesh edge.");
//Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[1].GetConnectedMeshEdges().Contains(edgeCreatedDuringSplit), "The vertex connected to this mesh edege contains this mesh edge.");
testMesh.UnsplitMeshEdge(edgeToSplit, vertexCreatedDuringSplit);
Assert.IsTrue(newFace.FaceEdgeLoopIsGood());
Assert.IsTrue(newFace.NumVertices == 3, "Back to 3 after UnsplitEdge.");
Assert.IsTrue(edgeCreatedDuringSplit.firstFaceEdge == null, "First face edge is disconnected.");
Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[0] == null && edgeCreatedDuringSplit.VertexOnEnd[1] == null, "The edgeCreatedDuringSplit is no longer connected to Vertices.");
Assert.IsTrue(edgeToSplit.VertexOnEnd[0] == leftVertex, "The unsplit edge is connected back the way it was.");
Assert.IsTrue(edgeToSplit.VertexOnEnd[1] == rightVertex, "The unsplit edge is connected back the way it was.");
// split again then unsplit the created edge rather than the original edge
testMesh.SplitMeshEdge(edgeToSplit, out vertexCreatedDuringSplit, out edgeCreatedDuringSplit);
testMesh.UnsplitMeshEdge(edgeCreatedDuringSplit, vertexCreatedDuringSplit);
Assert.IsTrue(newFace.FaceEdgeLoopIsGood());
Assert.IsTrue(newFace.NumVertices == 3, "Back to 3 after UnsplitEdge.");
Assert.IsTrue(edgeToSplit.firstFaceEdge == null, "First face edge is disconnected.");
Assert.IsTrue(edgeToSplit.VertexOnEnd[0] == null && edgeToSplit.VertexOnEnd[1] == null, "The edgeToSplit is no longer connected to Vertices.");
Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[0] == leftVertex, "The unsplit edge is connected back the way it was.");
Assert.IsTrue(edgeCreatedDuringSplit.VertexOnEnd[1] == rightVertex, "The unsplit edge is connected back the way it was.");
}
// make sure that the data on FaceEdges is correct (split the center edge of an extruded plus).
{
// make an extruded pluss sign.
Mesh testMesh = new Mesh();
Vertex centerVertex = testMesh.CreateVertex(0, 0, 0);
Vertex leftVertex = testMesh.CreateVertex(-1, 0, 0);
Vertex rightVertex = testMesh.CreateVertex(1, 0, 0);
Vertex frontVertex = testMesh.CreateVertex(0, -1, 0);
Vertex backVertex = testMesh.CreateVertex(0, 1, 0);
//.........这里部分代码省略.........
示例2: MergeMeshEdges
public void MergeMeshEdges()
{
{
Mesh testMesh = new Mesh();
Vertex leftVertexBottom = testMesh.CreateVertex(-1, 0, 0);
Vertex centerVertexBottom = testMesh.CreateVertex(0, 0, 0);
Vertex centerVertexTop = testMesh.CreateVertex(0, 0, 1);
Face leftFace = testMesh.CreateFace(new Vertex[] { leftVertexBottom, centerVertexBottom, centerVertexTop });
SaveDebugInfo(testMesh);
Vertex rightVertexBottom = testMesh.CreateVertex(1, 0, 0);
Face rightFace = testMesh.CreateFace(new Vertex[] { centerVertexBottom, rightVertexBottom, centerVertexTop }, CreateOption.CreateNew);
SaveDebugInfo(testMesh);
foreach (MeshEdge meshEdge in testMesh.MeshEdges)
{
Assert.IsTrue(meshEdge.firstFaceEdge != null);
}
Assert.IsTrue(testMesh.MeshEdges.Count == 6);
Assert.IsTrue(testMesh.FindMeshEdges(centerVertexTop, centerVertexBottom).Count == 2);
testMesh.MergeMeshEdges();
SaveDebugInfo(testMesh);
Assert.IsTrue(testMesh.MeshEdges.Count == 5);
}
}
示例3: MeshFaceSplitAndUnspiltTests
public void MeshFaceSplitAndUnspiltTests()
{
{
// centerVertexTop (0, 0, 2)
//
//
//
//
// leftVertexBottom (-1, 0, 0) centerVertexBottom (0, 0, 0) rightVertexBottom (1, 0, 0)
Mesh testMesh = new Mesh();
Vertex leftVertexBottom = testMesh.CreateVertex(-1, 0, 0);
Vertex centerVertexBottom = testMesh.CreateVertex(0, 0, 0);
Vertex rightVertexBottom = testMesh.CreateVertex(1, 0, 0);
Vertex centerVertexTop = testMesh.CreateVertex(0, 0, 1);
Face originalFace = testMesh.CreateFace(new Vertex[] { leftVertexBottom, centerVertexBottom, rightVertexBottom, centerVertexTop });
SaveDebugInfo(testMesh);
// *
// / \
// / \
// / \
// / \
// *----*----*
Assert.IsTrue(testMesh.FindMeshEdges(leftVertexBottom, centerVertexBottom).Count == 1);
MeshEdge firstFaceEdgeMeshEdge = testMesh.FindMeshEdges(leftVertexBottom, centerVertexBottom)[0];
Assert.IsTrue(originalFace.firstFaceEdge.meshEdge == firstFaceEdgeMeshEdge);
Assert.IsTrue(originalFace.NumVertices == 4, "The original face has 4 vertices.");
MeshEdge edgeLeftCenter = testMesh.FindMeshEdges(leftVertexBottom, centerVertexBottom)[0];
MeshEdge edgeCenterRight = testMesh.FindMeshEdges(centerVertexBottom, rightVertexBottom)[0];
MeshEdge edgeTopLeft = testMesh.FindMeshEdges(centerVertexTop, leftVertexBottom)[0];
MeshEdge edgeRightTop = testMesh.FindMeshEdges(centerVertexTop, rightVertexBottom)[0];
Assert.IsTrue(edgeTopLeft.NextMeshEdgeFromEnd[0] == edgeRightTop);
Assert.IsTrue(edgeTopLeft.NextMeshEdgeFromEnd[1] == edgeLeftCenter);
Assert.IsTrue(centerVertexBottom.GetConnectedMeshEdgesCount() == 2);
string connectionInfoBeforeSplit = testMesh.GetConnectionInfoAsString();
// split the face and test the result
Face faceCreatedDuringSplit;
MeshEdge meshEdgeCreatedDuringSplit;
testMesh.SplitFace(originalFace, centerVertexBottom, centerVertexTop, out meshEdgeCreatedDuringSplit, out faceCreatedDuringSplit);
SaveDebugInfo(testMesh);
// *
// /|\
// / | \
// / | \
// / | \
// *----*----*
testMesh.Validate();
//Debug.Write(testMesh.GetConnectionInfoAsString());
Assert.IsTrue(meshEdgeCreatedDuringSplit.VertexOnEnd[0] == centerVertexBottom);
Assert.IsTrue(meshEdgeCreatedDuringSplit.VertexOnEnd[1] == centerVertexTop);
Assert.IsTrue(edgeLeftCenter.NextMeshEdgeFromEnd[1] == meshEdgeCreatedDuringSplit);
Assert.IsTrue(edgeTopLeft.NextMeshEdgeFromEnd[1] == edgeLeftCenter);
Assert.IsTrue(originalFace.firstFaceEdge.meshEdge == meshEdgeCreatedDuringSplit);
Assert.IsTrue(originalFace.NumVertices == 3, "The original face now has 3 vertices.");
Assert.IsTrue(centerVertexBottom.GetConnectedMeshEdgesCount() == 3);
Assert.IsTrue(meshEdgeCreatedDuringSplit.GetNumFacesSharingEdge() == 2, "The edge we split on now has 2 faces attached to it.");
Assert.IsTrue(centerVertexBottom.GetConnectedMeshEdgesCount() == 3, "The vertex we split on should now have 3 mesh edges attached to it.");
Assert.IsTrue(centerVertexTop.GetConnectedMeshEdgesCount() == 3, "The vertex we split on should now have 3 mesh edges attached to it.");
Assert.IsTrue(leftVertexBottom.GetConnectedMeshEdgesCount() == 2, "The original vertices should still have 2 mesh edges attached to them.");
Assert.IsTrue(rightVertexBottom.GetConnectedMeshEdgesCount() == 2, "The original vertices should still have 2 mesh edges attached to them.");
Assert.IsTrue(faceCreatedDuringSplit.NumVertices == 3, "The created now has 3 vertices.");
// Unsplit the faces keeping the original face, and test the result.
testMesh.UnsplitFace(originalFace, faceCreatedDuringSplit, meshEdgeCreatedDuringSplit);
SaveDebugInfo(testMesh);
// *
// / \
// / \
// / \
// / \
// *----*----*
string connectionInfoAfterUnsplit = testMesh.GetConnectionInfoAsString();
testMesh.Validate();
foreach (FaceEdge faceEdge in originalFace.FaceEdges())
{
// make sure none of them are connected to the deleted MeshEdge
Assert.IsTrue(faceEdge.meshEdge != meshEdgeCreatedDuringSplit);
Assert.IsTrue(faceEdge.meshEdge.NextMeshEdgeFromEnd[0] != meshEdgeCreatedDuringSplit);
Assert.IsTrue(faceEdge.meshEdge.NextMeshEdgeFromEnd[1] != meshEdgeCreatedDuringSplit);
}
//Debug.Write(testMesh.GetConnectionInfoAsString());
Assert.IsTrue(originalFace.NumVertices == 4, "The original face is back to 4 vertices.");
Assert.IsTrue(meshEdgeCreatedDuringSplit.firstFaceEdge == null, "The data for the deleted edge is all null to help debugging.");
Assert.IsTrue(meshEdgeCreatedDuringSplit.VertexOnEnd[0] == null, "The data for the deleted edge is all null to help debugging.");
Assert.IsTrue(meshEdgeCreatedDuringSplit.NextMeshEdgeFromEnd[0] == null, "The data for the deleted edge is all null to help debugging.");
Assert.IsTrue(meshEdgeCreatedDuringSplit.VertexOnEnd[1] == null, "The data for the deleted edge is all null to help debugging.");
Assert.IsTrue(meshEdgeCreatedDuringSplit.NextMeshEdgeFromEnd[1] == null, "The data for the deleted edge is all null to help debugging.");
Assert.IsTrue(faceCreatedDuringSplit.firstFaceEdge == null, "The data for the deleted face is all null to help debugging.");
Assert.IsTrue(centerVertexBottom.GetConnectedMeshEdgesCount() == 2, "The vertex we split on should now have 2 mesh edges attached to it.");
Assert.IsTrue(centerVertexTop.GetConnectedMeshEdgesCount() == 2, "The vertex we split on should now have 2 mesh edges attached to it.");
}
//.........这里部分代码省略.........
示例4: MergeVertices
//.........这里部分代码省略.........
Vertex leftVertexTop = testMesh.CreateVertex(-1, 0, 2);
Vertex centerVertexMiddle2 = testMesh.CreateVertex(0, 0, 1, CreateOption.CreateNew);
Vertex rightVertexTop = testMesh.CreateVertex(1, 0, 2);
MeshEdge meshEdgeTopLeftCenter = testMesh.CreateMeshEdge(leftVertexTop, centerVertexMiddle2);
MeshEdge meshEdgeTopCenterRight = testMesh.CreateMeshEdge(centerVertexMiddle2, rightVertexTop);
MeshEdge meshEdgeTopRightLeft = testMesh.CreateMeshEdge(rightVertexTop, leftVertexTop);
Assert.IsTrue(meshEdgeBottomRightCenter.VertexOnEnd[1] == centerVertexMiddle1);
Assert.IsTrue(meshEdgeTopLeftCenter.VertexOnEnd[1] == centerVertexMiddle2);
SaveDebugInfo(testMesh);
testMesh.MergeVertices(centerVertexMiddle1, centerVertexMiddle2);
Assert.IsTrue(!testMesh.Vertices.ContainsVertex(centerVertexMiddle2));
Assert.IsTrue(meshEdgeBottomRightCenter.VertexOnEnd[1] == centerVertexMiddle1);
Assert.IsTrue(meshEdgeBottomCenterLeft.VertexOnEnd[0] == centerVertexMiddle1);
Assert.IsTrue(meshEdgeTopLeftCenter.VertexOnEnd[1] == centerVertexMiddle1);
Assert.IsTrue(meshEdgeTopCenterRight.VertexOnEnd[0] == centerVertexMiddle1);
int connectedCount = 0;
foreach (MeshEdge meshEdge in centerVertexMiddle1.ConnectedMeshEdges())
{
connectedCount++;
}
Assert.IsTrue(connectedCount == 4);
SaveDebugInfo(testMesh);
}
{
Mesh testMesh = new Mesh();
Vertex leftVertexBottom = testMesh.CreateVertex(-1, 0, 0);
Vertex rightVertexBottom = testMesh.CreateVertex(1, 0, 0);
Vertex centerVertexMiddle1 = testMesh.CreateVertex(0, 0, 1);
MeshEdge meshEdgeBottomLeftRight = testMesh.CreateMeshEdge(leftVertexBottom, rightVertexBottom);
MeshEdge meshEdgeBottomRightCenter = testMesh.CreateMeshEdge(rightVertexBottom, centerVertexMiddle1);
MeshEdge meshEdgeBottomCenterLeft = testMesh.CreateMeshEdge(centerVertexMiddle1, leftVertexBottom);
Vertex leftVertexTop = testMesh.CreateVertex(-1, 0, 2);
Vertex centerVertexMiddle2 = testMesh.CreateVertex(0, 0, 1, CreateOption.CreateNew);
Vertex rightVertexTop = testMesh.CreateVertex(1, 0, 2);
MeshEdge meshEdgeTopLeftCenter = testMesh.CreateMeshEdge(leftVertexTop, centerVertexMiddle2);
MeshEdge meshEdgeTopCenterRight = testMesh.CreateMeshEdge(centerVertexMiddle2, rightVertexTop);
MeshEdge meshEdgeTopRightLeft = testMesh.CreateMeshEdge(rightVertexTop, leftVertexTop);
Assert.IsTrue(meshEdgeBottomRightCenter.VertexOnEnd[1] == centerVertexMiddle1);
Assert.IsTrue(meshEdgeTopLeftCenter.VertexOnEnd[1] == centerVertexMiddle2);
SaveDebugInfo(testMesh);
testMesh.MergeVertices(centerVertexMiddle2, centerVertexMiddle1);
Assert.IsTrue(testMesh.Vertices.ContainsVertex(centerVertexMiddle2));
Assert.IsTrue(meshEdgeBottomRightCenter.VertexOnEnd[1] == centerVertexMiddle2);
Assert.IsTrue(meshEdgeBottomCenterLeft.VertexOnEnd[0] == centerVertexMiddle2);
Assert.IsTrue(meshEdgeTopLeftCenter.VertexOnEnd[1] == centerVertexMiddle2);
Assert.IsTrue(meshEdgeTopCenterRight.VertexOnEnd[0] == centerVertexMiddle2);
int connectedCount = 0;
foreach (MeshEdge meshEdge in centerVertexMiddle2.ConnectedMeshEdges())
{
connectedCount++;
}
Assert.IsTrue(connectedCount == 4);
SaveDebugInfo(testMesh);
}
{
Mesh testMesh = new Mesh();
Vertex leftVertexBottom = testMesh.CreateVertex(-1, 0, 0);
Vertex rightVertexBottom = testMesh.CreateVertex(1, 0, 0);
Vertex centerVertexMiddle1 = testMesh.CreateVertex(0, 0, 1);
Face bottomFace = testMesh.CreateFace(new Vertex[] { leftVertexBottom, rightVertexBottom, centerVertexMiddle1 });
Vertex leftVertexTop = testMesh.CreateVertex(-1, 0, 2);
Vertex centerVertexMiddle2 = testMesh.CreateVertex(0, 0, 1, CreateOption.CreateNew);
Vertex rightVertexTop = testMesh.CreateVertex(1, 0, 2);
Face top = testMesh.CreateFace(new Vertex[] { leftVertexTop, centerVertexMiddle2, rightVertexTop });
MeshEdge meshEdgeBottomRightCenter = testMesh.FindMeshEdges(leftVertexBottom, centerVertexMiddle1)[0];
MeshEdge meshEdgeTopLeftCenter = testMesh.FindMeshEdges(leftVertexTop, centerVertexMiddle2)[0];
Assert.IsTrue(meshEdgeBottomRightCenter.VertexOnEnd[0] == centerVertexMiddle1);
Assert.IsTrue(meshEdgeTopLeftCenter.VertexOnEnd[1] == centerVertexMiddle2);
SaveDebugInfo(testMesh);
testMesh.MergeVertices();
SaveDebugInfo(testMesh);
}
}