A Simple Mesh Viewer Tutorial with C++ Source
The mesh models are represented as a list of triangles, each triangle has three vertices, three normals, three texture coordinates. The vertex may have
color information as well. The data structure is called triangle soup. The viewer support two formats, obj file and m file.
Polygonal Rendering Mode
The simple viewer can do flat shading, smooth shading and wireframe rendering. The hot keys for three modes are 'f' for flat shading, 's' for smooth shading and 'w' for wireframe mode.
|Flat shading: 'f' key
||Smooth shading: 's' key
||Wireframe: 'w' key
The viewer can render both 3D geometry of the surface, or the 2D texture parameter of the surface. Press 'g' to toggle different geometry mode.
|3D Surface Geometry ||2D Parameter Geometry|
There are three texture modes, no texture, texture blends with the shading, texture replaces the shading. By press 't' to toggle through the texture modes.
The simple mesh viewer uses arcball interface, left mouse button for rotation, right mouse button for zoom in/out, middle mouse button for translation.
The simple mesh viewer uses glut32 on windows and OpenGL. It is written in generic C++ and has been successfully compiled on both Windows and Ubuntu platforms.
The code is written in C++ using VisualStudio on Windows platform.
- Download the SimpleViewer.zip file, unzip it.
- Enter SimpleViewer/Viewer/Test directory, double click on Test.sln file. Compile the project using Visual Studio.
- The output is SimpleViewer/bin/SimpleViewer.exe
- Go to SimpleViewer/demo/ directory, double click on view_test.bat
If you encounter any problem during the compilation and running the code, please contact the author David Gu at $email@example.com$.