The quick to use single header OBJ loader
OBJ Loader is a simple, header only, .obj model file loader that will take in a path to a file, load it into the Loader class object, then allow you to get the data from each mesh loaded. This will load each mesh within the model with the corresponding data such as vertices, indices, and material. Plus a large array of vertices, indices and materials which you can do whatever you want with.
OBJ Loader was made with compatibility in mind. So you only need the header file to get going as it uses only STD and self made data structures.
All you need to to is copy over the OBJ_Loader.h header file, include it in your solution, and you are good to go. It is located within the source folder.
Examples are found within the examples folder. In order to compile these you will need to link OBJ_Loader.h to the compiler in since it is not included within the example folders.
Quick Use Guide
- Include OBJ_Loader.h: '#include "OBJ_Loader.h"'
- Create a Loader Object: 'objl::Loader loader'
- Load a File Into the Loader Object: 'loader.LoadFile("path_to_object_and_name.obj")'
- Get What you want out of the Mesh Objects: 'cout << loader.LoadedMeshes.MeshName << endl'
Classes & Structures
These are all of the included classes and only the relevant members and methods. There are others to find if you want but these are all you will need to know to operate.
- float X, Y : Position Variables
- float X, Y, Z : Position Variables
- Vector3 Position : Position vector
- Vector3 Normal : Normal vector
- Vector2 TextureCoordinate : Texture Coordinate vector
- std::string name : Name of loaded material
- Vector3 Ka : Ambient color
- Vector3 Kd : Diffuse color
- Vector3 Ks : Specular color
- float Ns : Specular exponent
- float Ni : Optical density
- float d : Dissolve variable
- int illum : Illumination variable
- std::string map_Ka : Ambient texture map name
- std::string map_Kd : Diffuse texture map name
- std::string map_Ks : Specular texture map name
- std::string map_d : Alpha texture map name
- std::string map_bump : Bump map name
- std::string MeshName : The Mesh Name given in the .obj
- std::vector Vertices : Vertex List
- std::vector Indices : Index List
- Material MeshMaterial : Material assigned to this mesh
- bool LoadFile(std::string Path) : Load a file from a path. Return true if found and loaded. Return false if not
- std::vector LoadedMeshes : Loaded Mesh Objects
- std::vector LoadedVertices : Loaded Vertex Objects
- std::vector LoadedIndices : Loaded Index Positions
- std::vector LoadedMaterials : Loaded Material Objects
OBJ Loader uses the MIT license. The MIT license allows free use and modification of the software as long as they provide credit back to me and don't hold me liable for anything that may go wrong. If you want to read the license in full look into the file entitled: LICENSE
- Bug Fixing
- Adding more variables
Version 1.0 (September-13-2016)
- Base Implementation Done
- README Created
- LICENSE Created
- Mesh Index and Vertex Load Implemented
Version 2.0 (September-14-2016)
- Now Reads Material Data