Mesh Viewer Aug 26, 2006
This week I completed the third stage of my sample program. It's based off the triangle selection but adds texturing and simple lighting. While texturing and lighting aren't something I planned to demonstrate, it's a required step before the next stage when I start adding the intended functionality. What that functionality is will remain a mystery =)
Textures
I've included a .TGA(Targa image) loader as texture.cpp. I wrote it specifically for 24-bit uncompressed images, although it could be easily expanded to read more possible TGA formats if necessary. The renderinterface.cpp has also been updated to support rendering with a texture.
Lighting
You can see a screenshot of the mesh head at this link. In the program lighting is turned on at menu->view->lighting. You'll notice some lighting seems, this is because it just calculates a normal per vertex based on adjacent triangles. A seem appears where vertices at the same exact position are split because adjacent triangles contain separate texture UVs. Ideally these seems would be unrelated to the UVs, and the user would specify them himself/herself using smoothing groups. The normals are calculated from mesh data in two steps. First, the normal for each triangle face is calculated using the cross product of the triangle edges. Then the normal at each vertex is calculated by averaging the normals of the adjacent triangles and renormalizing them. Download
Sample3-Mesh_Viewer.zip (60KB) : The source code for this sample program. It is in C++ uses OpenGL and a Win32 GUI. It includes project files for Microsoft Visual C++ 2005 and MSVC++6.0. The zip also includes meshhead2.dat and headdiff.tga. To learn exactly what this example program contains, and more about using it, check out the readme.txt |