示例#1
0
		private void ParsePolylist(
			XElement mesh, MeshSkinAndMaterials skinAndMaterials, SeparateStreamsMesh dstMesh, XElement element)
		{
			var meshInputs = this.ParseInputs(element);

			
			int[] vcount = new int[meshInputs.Count];
			this.ParseIntArray(element.ElementValue(this.schema.vcountName), vcount);
			var points = vcount.Sum(a => a);
			var firstSize = vcount[0];
			bool isAllTheSame = vcount.All(i => i == firstSize);

			int[] p = new int[points * meshInputs.Stride];
			this.ParseIntArray(element.ElementValue(this.schema.pName), p);

			var subMesh = dstMesh.CreateSubmesh();
			subMesh.Material = skinAndMaterials.GetAnyMaterialFor(element.AttributeValue(this.schema.materialAttributeName));

			var streamList = StreamListOrderedByOffset(meshInputs, subMesh);

			//if (isAllTheSame)
			//{
			//	if (firstSize == 3)
			//	{
			//		subMesh.VertexSourceType = VertexSourceType.TrianleList;
			//		this.ParseElements(p, subMesh, meshInputs, points);
			//		return;
			//	}
			//	if (firstSize == 4)
			//	{
			//		subMesh.VertexSourceType = VertexSourceType.QuadList;
			//		this.ParseElements(p, subMesh, meshInputs, points);
			//		return;
			//	}
			//}

			subMesh.VertexSourceType = VertexSourceType.TriangleList;
			int startIndex = 0;
			for (int polygonIndex = 0; polygonIndex < vcount.Length; ++polygonIndex)
			{
				for (int i = 2; i < vcount[polygonIndex]; i++)
				{
					AddVertex(p, 0, streamList, meshInputs.Stride);
					AddVertex(p, i-1, streamList, meshInputs.Stride);
					AddVertex(p, i , streamList, meshInputs.Stride);
				}
				startIndex += vcount[polygonIndex];
			}
		}
示例#2
0
		private void ParseTriangles(
			XElement mesh, MeshSkinAndMaterials skinAndMaterials, SeparateStreamsMesh dstMesh, XElement element)
		{
			var meshInputs = this.ParseInputs(element);
			
			int[] p = new int[meshInputs.Count * meshInputs.Stride * 3];
			this.ParseIntArray(element.ElementValue(this.schema.pName), p);

			var subMesh = dstMesh.CreateSubmesh();
			subMesh.Material = skinAndMaterials.GetAnyMaterialFor(element.AttributeValue(this.schema.materialAttributeName));
			subMesh.VertexSourceType = VertexSourceType.TriangleList;

			var streamList = StreamListOrderedByOffset(meshInputs, subMesh);

			for (int polygonIndex = 0; polygonIndex < meshInputs.Count; ++polygonIndex)
			{
				AddVertex(p, polygonIndex*3, streamList, meshInputs.Stride);
				AddVertex(p, polygonIndex * 3+1, streamList, meshInputs.Stride);
				AddVertex(p, polygonIndex * 3+2, streamList, meshInputs.Stride);
			}
		}
示例#3
0
		private void ParsePolygons( MeshSkinAndMaterials skinAndMaterials, SeparateStreamsMesh dstMesh, XElement element)
		{
			var meshInputs =  this.ParseInputs(element);
			var subMesh = dstMesh.CreateSubmesh();
			subMesh.Material = skinAndMaterials.GetAnyMaterialFor(element.AttributeValue(this.schema.materialAttributeName));
			subMesh.VertexSourceType = VertexSourceType.TriangleList;

			var streamList = StreamListOrderedByOffset(meshInputs, subMesh);
			foreach (var polygon in element.Elements(this.schema.pName))
			{
				var list = this.ParseIntList(polygon.Value);
				int numElements = list.Count / meshInputs.Stride;

				for (int i=1; i<numElements-1; ++i)
				{
					AddVertex(list, 0, streamList, meshInputs.Stride);
					AddVertex(list, i, streamList, meshInputs.Stride);
					AddVertex(list, i+1, streamList, meshInputs.Stride);
				}
			}
		}