예제 #1
0
        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);
        }
예제 #2
0
        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--;
            }
        }
예제 #3
0
 public void AddModel(MapGeometryModel model)
 {
     this.Models.Add(model);
 }