Exemplo n.º 1
0
        public static Model3DGroup Load(string path)
        {
            if (path == null)
            {
                return(null);
            }
            Model3DGroup model = null;
            string       ext   = System.IO.Path.GetExtension(path).ToLower();

            switch (ext)
            {
            case ".3ds":
            {
                var r = new StudioReader();
                model = r.Read(path);
                break;
            }

            case ".lwo":
            {
                var r = new LwoReader();
                model = r.Read(path);
                break;
            }

            case ".obj":
            {
                var r = new ObjReader();
                model = r.Read(path);
                break;
            }

            case ".objz":
            {
                var r = new ObjReader();
                model = r.ReadZ(path);
                break;
            }

            case ".stl":
            {
                var r = new StLReader();
                model = r.Read(path);
                break;
            }

            default:
                throw new InvalidOperationException("File format not supported.");
            }
            return(model);
        }
Exemplo n.º 2
0
 public static Model3DGroup Load(string path)
 {
     if (path == null)
         return null;
     Model3DGroup model = null;
     string ext = System.IO.Path.GetExtension(path).ToLower();
     switch (ext)
     {
         case ".3ds":
             {
                 var r = new StudioReader();
                 model = r.Read(path);
                 break;
             }
         case ".lwo":
             {
                 var r = new LwoReader();
                 model = r.Read(path);
                 break;
             }
         case ".obj":
             {
                 var r = new ObjReader();
                 model = r.Read(path);
                 break;
             }
         case ".objz":
             {
                 var r = new ObjReader();
                 model = r.ReadZ(path);
                 break;
             }
         case ".stl":
             {
                 var r = new StLReader();
                 model = r.Read(path);
                 break;
             }
         default:
             throw new InvalidOperationException("File format not supported.");
     }
     return model;
 }
Exemplo n.º 3
0
 private void LoadModel(string filename, MeshFaces faces)
 {
     // load model
     var reader = new ObjReader();
     var objModel = reader.Read(filename, new ModelInfo() { Faces = faces });
     this.DefaultModel = objModel[0].Geometry as MeshGeometry3D;
     this.DefaultModel.Colors = this.DefaultModel.Positions.Select(x => new Color4(1, 0, 0, 1)).ToArray();
 }