private static IMeshBuilder <MaterialBuilder> BuildMapGeometryMeshStatic(MapGeometryModel model) { var meshBuilder = VERTEX.CreateCompatibleMesh(); foreach (MapGeometrySubmesh submesh in model.Submeshes) { List <MapGeometryVertex> vertices = submesh.GetVertices(); List <ushort> indices = submesh.GetIndices(); MaterialBuilder material = new MaterialBuilder(submesh.Material).WithUnlitShader(); var primitive = meshBuilder.UsePrimitive(material); List <VERTEX> gltfVertices = new List <VERTEX>(); foreach (MapGeometryVertex vertex in vertices) { gltfVertices.Add(CreateVertex(vertex)); } for (int i = 0; i < indices.Count; i += 3) { VERTEX v1 = gltfVertices[indices[i + 0]]; VERTEX v2 = gltfVertices[indices[i + 1]]; VERTEX v3 = gltfVertices[indices[i + 2]]; primitive.AddTriangle(v1, v2, v3); } } return(meshBuilder); }
public MapGeometrySubmesh(BinaryReader br, MapGeometryModel parent) { this.Parent = parent; this.Hash = br.ReadUInt32(); this.Material = Encoding.ASCII.GetString(br.ReadBytes(br.ReadInt32())); this.StartIndex = br.ReadUInt32(); this.IndexCount = br.ReadUInt32(); this.StartVertex = br.ReadUInt32(); //MinVertex this.VertexCount = br.ReadUInt32() + 1; //MaxVertex if (this.StartVertex != 0) { this.StartVertex--; } }
public void AddModel(MapGeometryModel model) { this.Models.Add(model); }