当前位置: 首页>>代码示例>>C#>>正文


C# Mesh.CreateMeshEdge方法代码示例

本文整理汇总了C#中Mesh.CreateMeshEdge方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.CreateMeshEdge方法的具体用法?C# Mesh.CreateMeshEdge怎么用?C# Mesh.CreateMeshEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mesh的用法示例。


在下文中一共展示了Mesh.CreateMeshEdge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateWireFrameTriangle

		public void CreateWireFrameTriangle()
		{
			Mesh testMesh = new Mesh();
			Vertex leftVertexBottom = testMesh.CreateVertex(-1, 0, 0);
			Vertex rightVertexBottom = testMesh.CreateVertex(1, 0, 0);
			Vertex centerVertexTop = testMesh.CreateVertex(0, 0, 2);

			// create the first mesh edge and check stuff
			MeshEdge meshEdge0 = testMesh.CreateMeshEdge(leftVertexBottom, rightVertexBottom);
			Assert.IsTrue(meshEdge0.VertexOnEnd[0] == leftVertexBottom);
			Assert.IsTrue(meshEdge0.firstFaceEdge == null);
			Assert.IsTrue(meshEdge0.NextMeshEdgeFromEnd[0] == meshEdge0.NextMeshEdgeFromEnd[1]);
			Assert.IsTrue(meshEdge0.NextMeshEdgeFromEnd[0] == meshEdge0);
			Assert.IsTrue(meshEdge0.VertexOnEnd[1] == rightVertexBottom);
			Assert.IsTrue(meshEdge0.NextMeshEdgeFromEnd[1] == meshEdge0);

			// create the second mesh edge and check stuff
			MeshEdge meshEdge1 = testMesh.CreateMeshEdge(rightVertexBottom, centerVertexTop);
			Assert.IsTrue(meshEdge0.VertexOnEnd[0] == leftVertexBottom);
			Assert.IsTrue(meshEdge0.firstFaceEdge == null);
			Assert.IsTrue(meshEdge0.NextMeshEdgeFromEnd[0] == meshEdge0);
			Assert.IsTrue(meshEdge0.VertexOnEnd[1] == rightVertexBottom);
			Assert.IsTrue(meshEdge0.NextMeshEdgeFromEnd[1] == meshEdge1);

			Assert.IsTrue(meshEdge1.VertexOnEnd[0] == rightVertexBottom);
			Assert.IsTrue(meshEdge1.firstFaceEdge == null);
			Assert.IsTrue(meshEdge1.NextMeshEdgeFromEnd[0] == meshEdge0);
			Assert.IsTrue(meshEdge1.VertexOnEnd[1] == centerVertexTop);
			Assert.IsTrue(meshEdge1.NextMeshEdgeFromEnd[1] == meshEdge1);

			// create the third mesh edge and test
			MeshEdge meshEdge2 = testMesh.CreateMeshEdge(centerVertexTop, leftVertexBottom);
			Assert.IsTrue(meshEdge0.VertexOnEnd[0] == leftVertexBottom);
			Assert.IsTrue(meshEdge0.VertexOnEnd[1] == rightVertexBottom);
			Assert.IsTrue(meshEdge0.firstFaceEdge == null);
			Assert.IsTrue(meshEdge0.NextMeshEdgeFromEnd[0] == meshEdge2);
			Assert.IsTrue(meshEdge0.NextMeshEdgeFromEnd[1] == meshEdge1);

			Assert.IsTrue(meshEdge1.VertexOnEnd[0] == rightVertexBottom);
			Assert.IsTrue(meshEdge1.VertexOnEnd[1] == centerVertexTop);
			Assert.IsTrue(meshEdge1.firstFaceEdge == null);
			Assert.IsTrue(meshEdge1.NextMeshEdgeFromEnd[0] == meshEdge0);
			Assert.IsTrue(meshEdge1.NextMeshEdgeFromEnd[1] == meshEdge2);

			Assert.IsTrue(meshEdge2.VertexOnEnd[0] == centerVertexTop);
			Assert.IsTrue(meshEdge2.VertexOnEnd[1] == leftVertexBottom);
			Assert.IsTrue(meshEdge2.firstFaceEdge == null);
			Assert.IsTrue(meshEdge2.NextMeshEdgeFromEnd[0] == meshEdge1);
			Assert.IsTrue(meshEdge2.NextMeshEdgeFromEnd[1] == meshEdge0);

			SaveDebugInfo(testMesh);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:52,代码来源:MeshTests.cs

示例2: 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);

//.........这里部分代码省略.........
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:101,代码来源:MeshTests.cs

示例3: MergeVertices

		public void MergeVertices()
		{
			{
				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(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 });

//.........这里部分代码省略.........
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:101,代码来源:MeshTests.cs


注:本文中的Mesh.CreateMeshEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。