public static Mesh Construct(FromBoundingRegion metaResource) { Mesh mesh = new Mesh { MeshType = MeshType.Indexed, VertexStreamLayout = Vertex.Position3Normal3Texcoord3.Instance, }; mesh.NVertices = metaResource.BoundingRegion.Data.Nodes.Length * 3; List <Vertex.Position3Normal3Texcoord3> verts = new List <Vertex.Position3Normal3Texcoord3>(); foreach (var v in metaResource.BoundingRegion.Data.Nodes) { foreach (var p in v.polygon.Reverse()) { verts.Add( new Vertex.Position3Normal3Texcoord3( p, Vector3.UnitZ, Vector3.Zero) ); } } mesh.VertexBuffer = new VertexBuffer <Vertex.Position3Normal3Texcoord3>(verts.ToArray()); mesh.NFaces = metaResource.BoundingRegion.Data.Nodes.Length; List <int> indices = new List <int>(); int i = 0; foreach (var v in metaResource.BoundingRegion.Data.Nodes) { foreach (var p in v.polygon) { indices.Add(i++); } } mesh.IndexBuffer = new IndexBuffer(indices.ToArray()); return(mesh); }
public static Mesh Construct(FromBoundingRegion metaResource) { Mesh mesh = new Mesh { MeshType = MeshType.Indexed, VertexStreamLayout = Vertex.Position3Normal3Texcoord3.Instance, }; mesh.NVertices = metaResource.BoundingRegion.Data.Nodes.Length * 3; List<Vertex.Position3Normal3Texcoord3> verts = new List<Vertex.Position3Normal3Texcoord3>(); foreach(var v in metaResource.BoundingRegion.Data.Nodes) { foreach(var p in v.polygon.Reverse()) verts.Add( new Vertex.Position3Normal3Texcoord3( p, Vector3.UnitZ, Vector3.Zero) ); } mesh.VertexBuffer = new VertexBuffer<Vertex.Position3Normal3Texcoord3>(verts.ToArray()); mesh.NFaces = metaResource.BoundingRegion.Data.Nodes.Length; List<int> indices = new List<int>(); int i = 0; foreach (var v in metaResource.BoundingRegion.Data.Nodes) { foreach (var p in v.polygon) indices.Add(i++); } mesh.IndexBuffer = new IndexBuffer(indices.ToArray()); return mesh; }