Ejemplo n.º 1
0
 private Model(BlockbenchModel json, Dictionary <ModelObjectInfo, List <ObjFace> > objects, IList <ObjVertex> verts, IList <ObjVector3> normals, IList <ObjVector3> uvs)
 {
     _json    = json;
     _objects = objects;
     _verts   = verts;
     _normals = normals;
     _uvs     = uvs;
 }
Ejemplo n.º 2
0
        public static Model FromFile(string filename)
        {
            ExpectFile($"{filename}.json");
            ExpectFile($"{filename}.obj");

            var json = BlockbenchModel.FromFile($"{filename}.json");
            var obj  = ObjFile.FromFile($"{filename}.obj");

            var objects = obj
                          .Faces
                          .GroupBy(face => new ModelObjectInfo(face.ObjectName, face.MaterialName))
                          .ToDictionary(grouping => grouping.Key, grouping => grouping.ToList());

            var verts   = obj.Vertices;
            var normals = obj.VertexNormals;
            var uvs     = obj.TextureVertices;

            return(new Model(json, objects, verts, normals, uvs));
        }