Obj File Renderer is a program that renders OBJ files to a 2D display using C++ and the SFML Library. In other words, it reads in a 3D model file that consists of the vertices and the faces data of the 3D model, do some fancy rotations, calculate the lighting of each individual faces, then project those points onto the 2D screen.
I decided to write every mathematics part from the ground up based on my understanding of linear algebra and lots of digging through the internet. And I use the SFML library to handle the actual drawing of the triangles.
Currently I am still experimenting with the concept so it still has limited features. In the future I will be constantly adding more stuff such as moveable camera and smoother lighting on the model.
- Originally inspired by the Japanese Minecraft player EMB4 who created the MCHeli Minecraft Mod using .obj 3D models for the vehicles, link to the website: https://www.curseforge.com/minecraft/mc-mods/mcheli-minecraft-helicopter-mod.
- Also Inspired by Andy Sloane from his Donut C program, link to his website: https://www.a1k0n.net/2011/07/20/donut-math.html.
- Massive thanks for professor Craig Schroeder for guiding me and clarifying some confusions I have about the 3D rendering pipeline.
- Implemented the Phong Shading algorithm so the pixel color is calculated based on the interpolated position and normals from the triangle's three vertices. (It looks very pretty much the same as the gouraud shading algorithm because of the gif's low resolution, and the large number of triangles this teapot model has).
- Added a util class for all the helper functions.
- Implemented the Gouraud Shading algorithm so the surfaces looks smoother. The color at each pixel is the combined weight of each color at the triangles' vertices.
- Reworked on how SFML renders the object.
- Added lighting to the surfaces (flat shading), the calculation is based on the angle between the individual faces with respect to the light source using dot product.
- Uses painter's algorithm so the front-facing faces that are behind others will be covered. So the model is not see-through anymore.
- Uses the surface normals to calculate the angle between the individual faces and the camera, so now only the faces that are facing the camera (instead of all of the faces) will be rendered.
- However, this also means that some faces that are facing towards the camera but are behind other front-facing faces will also get rendered.
- Added a obj file parser to read in the data from the file and format it into something the program can use.
- Refractered the code into using custom Vec3d and Vec2d classes instead of 2d arrays, so the code looks cleaner and more scalable.
- Hard coded some simple 3D objects to test out the algorithm.
- Updated the method for inserting the vertices into the buffer.
- Migrated the 3D model renderer from my previous python project "Simple3DModelRenderer" to here using C++ and SFML library for faster speed.
- The ideas are the same, do the rotation for the 3D points, then project those 3D points onto a 2D screen