Load OBJ

Page last edited 3,701 days ago
From Artisan
Jump to navigation Jump to search

We now have a .obj file parser pushed to our repository. If you want to see the source code for yourself, it can be located here on github.

Instructions for use:

  • Reference the .dll or reference the project directly as usual.
  • Create the ObjLoaderFactory object:
   
       var objLoaderFactory = new ObjLoaderFactory();
       var objLoader = objLoaderFactory.Create();
   
  • Open .obj file with a FileStream object (remember to surround with a try/catch):
   
       var fileStream = new FileStream("model.obj",FileMode.Open);
       var result = objLoader.Load(fileStream);
   

The LoadResult object contains the loaded model in this form:

   
       public class LoadResult 
       {
           public IList<Vertex> Vertices { get; set; }
           public IList<Texture> Textures { get; set; }
           public IList<Normal> Normals { get; set; }
           public IList<Group> Groups { get; set; }
           public IList<Material> Materials { get; set; }
       }