I have recently been doing significant work with processing 3D meshes and associated textures. Today I have extracted the Wavefront OBJ parser I’m using into a seperate library and posted the code for others to use.
If you are not familiar with the Obj spec, this is a great reference:
The main entry point to the library is via the Obj class. Parsing and writing files is very simple.
// Initialize var obj = new Obj(); // Read Wavefront OBJ file obj.LoadObj([input path]); // Write OBJ file obj.WriteObjFile([output path]);
When an OBJ file is loaded all of its faces, vertices, and UV’s are accessible to you in IEnumerables of types Face, Vertex, and TextureVertex. All of these elemental types are based on IType, so adding support for additional parts of the OBJ format is quite simple.
You can use this library as a start to basic mesh manipulation. For example, cropping a mesh is as simple as removing all vertices and faces outside of a specific boundary, and updating indexes appropriately, then writing the file back out.