Computer Graphics II - HW 2 - Dynamic Cube Mapping

     Hi everyone, in this post, I will talk about my second assignment in CENG469 course, which is cubemapping. Firstly, I will explain how I implement the homework, then I will talk about issues that I faced during the implementation. So, let's begin!


Flight Simulator

In this assignment, we were expected to implement environment mapping and reflection capabilities using cubemaps in OpenGL. Normally, the expected end product of this assignment is a drivable car. However, I want to fly an airplane, because why not :) It is also mentioned in the homework text that we are free to implement our own design choices. Then, I start to create the flight simulator. 

Firstly, as a challenge to myself, I want to build an abstract renderer like a mini-game engine, not just a single file program. Since I am dealing with an application with a renderer in my senior project, I wanted this homework codebase to look like this. :)

Then, I created corresponding classes:

  • Camera.h: helps to show our scene :)
  • Mesh.h: store mesh data in buffers
  • Shader.h: create shaders, and send uniform data to corresponding shaders
  • Renderer.h: bind those buffers as shader attributes, and render with index buffers, load textures
  • UAV.h: whole flight mechanisms calculated here
  • SkyBox.h whole skybox calculations done here

Secondly, I started to search suitable 3D obj files to my scene. However, since the obj file parser from the given SampleGL codebase only render faces with 3 vertices, whenever I found a mesh has more than that so I cannot use it. It is again a design decision, should I change my obj file parse or should I edit 3D meshes that I found on the internet. Of course, the easy way is that editing the mesh files :D. I solved this problem by using MeshLab. (Oh god, I love MeshLab) As a note, by using MeshLab you can also swap axises of meshes pretty easily. When you choose "export as mesh" option in MeshLab, and choose obj file, you will see this exporting window. Once you disable "Polygonal" option, the mesh you exported will be suitable for SampleGL obj parser. 


MeshLab Exporter

Thirdly, since I wanted to create a flight simulation, I should learn some aircraft mechanics formulation. I spent some time on learning flight mechansim then I found this beautiful resource https://aircraftflightmechanics.com/AircraftPerformance/GlidingFlight.html  which gives you very detail about aircraft system. Since I am not going create a real flight simulator :D I just need to learn very basic terms like lift, drag, thrust etc. 


Aircraft Flight Mechanics

Once I learn the basics of the terms, I started to implement on UAV class. (Initially I have intend to fly UAV drone that's why I named the class UAV, I feel lazy  to change the name, keep it like that.). Of course, it is not easy to implement these calculations. The simulation is not stable right now, I need to spend more time on the improvements.


Flight Movement


After finishing on the physics calculation, I started to implement cubemap. Since I need reflectance mesh with my F16 model. Firstly, I open f16 model in Blender and seperate the canopy part from the model. Then, I exported as obj file and do the MeshLab trick steps again.

Seperate canopy from F16

After that, the canopy reflects its environment.



Issues:

  • I rendered mesh with red color. I couldn't understand first, after 2 days I figured it out.

Reddish mesh

 Like in the first homework, I wrote "rgb" order wrongly again :( This time in fragment shader not in the parser function.




  • I think I have a problem with creating dynamic cubemap. However, I couldn't find it where the problem is :( Since today is the deadline I leave it as it is. 






As a conclusion, this assignment has allowed me to gain a deeper understanding of environment mapping, framebuffers, and depth buffers. By implementing these techniques via OpenGL, I will be able to create visually stunning scenes. The skills and knowledge I have acquired from this assignment will undoubtedly be useful in my future projects and endeavors in the field of computer graphics.

Here is the final gameplay video:

The scenario is landing the F16 on the airport. 
 







Comments

Popular posts from this blog

Leveling Up Raven: BVH, Transformations, and Instancing

Raven: The Beginning of My Ray Tracing Journey

Enhancing Raven: Multisampling and Distribution Ray Tracing