Saturday, August 6, 2022

Lesson11: Traversing a Gallery with a First Person Camera

Overview 
As discussed in the  previous article, we saw how First Person Camera is implemented. 

Details
The purpose of  Lesson11 is to demonstrate using First Person Camera.

System  class diagram
The scene class overrides camera with an instance of FPSCamera. 
Implementation
QuadMesh
A new mesh class  QuadMesh is defined for loading vertex data of 3D objects such as walls, floor, ceilings etc. It's used by another new class  QuadObj object for loading vertex data to vertex shader and texture data to the vertex and fragment shaders. 
This class derives from IGeometryMesh class. It contains information about Geometry information and Texture information. 

Quad
QuadObj derives from BaseGeometry class. It renders 3D objects such as walls, floor, ceilings etc. 
Scene
The functionality is implemented in the Scene class derived from BaseScene class.
The three methods Init, DrawScene and Cleanup are overridden as below:
The Init method creates an instance of FPSCamera and populates 3D objects such as walls, floor, cielings etc.
The DrawScene method draws a string and image. 
The message handler for IDOK is called when Apply button is pressed after updates are made in the input dialog. It refreshes the display.

The message handler for IDCANCEL is called when in Cancel button is pressed the input dialog. It calls 
OnCloseWindow to destroy window.

Finally the WM_CLOSE  event is  handled in OnCloseWindow function and the window is destroyed and  application is shutdown when the window is closed or Escape key is pressed. 

Application
Scene class is hosted main.cpp. which creates the scene object and displays it. Message pump is added to process windows messages.

Output
The output looks as shown in the top. 

The Source Code can be accessed from Lesson11: Traversing a Gallery with a First Person Camera
The binaries can be accessed from here.

No comments:

Post a Comment