obj-loader
obj-loader copied to clipboard
Wavefront .obj loader&viewer with GUI controls. Written in C++/OpenGL, supports .mtl.
Object Viewer
- Zhang Qiuyi, 12330402
Dependencies
- glm(with some modification, included as source code)
- fltk(a win32 build is included)
What is it?
A Wavefront .obj viwer, with .mtl support and GUI.

Operations
Menu
File/Open: open a .obj file(it will automatically load related .mtl files)File/Quit: quitFlat: use flat shadingSmooth: use smooth shadingLight1: toggle light 1Light2: toggle light 2Reset camera: reset the camera(in case you get lost)
Mouse drag
- Left button: rotate the object
- Middle button: translate the object
- Right button: zoom in/out on the object
Note: If you can't see the object after opening it, try using your mouse to adjust the camera. It may be that the object is too big/small or placed too far/close.
Preview
Flat shading:

Light 1:

Light 2:

Flower:

Vase:

Castle:

F-16:

File structure
- doc // report goes here
- include // header files
- lib // static libraries
- data // sample .obj and .mtl files
- src // source code
- screenshots // screenshots
// dynamic library for the prebuilt executable
- freeglut.dll
- hw4.sln // VS2013 project file
- hw4.exe // prebuilt executable
- README.md // you are reading it :)
About the executable
The executable hw4.exe is built for Windows with VS2013. If you have VS2013 installed(which means you have libraries like msvcr120.dll installed), you can run the executable directly. Otherwise you need to build it from source.
How to build it?
If you are using VS2013, just open hw4.sln and build the hw4 target. If you are using VS2015, you can try to do this too.
If you are using VS2012 or other versions of VS, follow this steps:
- Create a new project from the existing code(make sure it's a console application instead of a windowed application), include all
.cppand.hfiles - Make sure VC++ will include
.\includein itsINCLUDEenvironment variable(e.g. OpenProperties -> Configuration Properties -> VC++ Directories -> Include Directoriesand add.\include) - Make sure VC++ will include
.\libin itsINCLUDEenvironment variable(e.g. OpenProperties -> Configuration Properties -> VC++ Directories -> Library Directoriesand add.\lib) - The linker needs to link these libraries(e.g. Open
Properties -> Configuration Properties -> Linker -> Additional Dependenciesand add them):
fltk.libfltkgl.libfreeglut.libopengl32.libglu32.lib
- Make sure the executable will be output to the project directory(e.g. Open
Properties -> Configuration Properties -> Generaland setOutput Directoryto$(SolutionDir)\). - Build the
hw4target.
Warning: this program needs C++11 support(e.g. smart pointers), so an ancient VS might not be able to build it.
Troubleshooting
If you can't build the program using the FLTK included in the project, you need to build it again. Follow the steps in this link, and copy the FL folder(containing header files) into include/, and all built .libs into lib/.