Working with a 3D camera and basic user interaction
To debug a graphical application, it is very helpful to be able to navigate and move around within a 3D scene using a keyboard or mouse. Graphics APIs themselves are not familiar with concepts of cameras and user interaction, so we have to implement a camera model that will convert user input into a view matrix usable by Vulkan. In this recipe, we will learn how to create a simple yet extensible 3D camera implementation and use it to enhance the functionality of our Vulkan examples.
Getting ready
The source code for this recipe can be found in Chapter04/05_Camera
. The camera classes are declared and implemented in the file shared/Camera.h
.
How to do it...
Our camera implementation will calculate a view matrix and a 3D position point based on the selected dynamic model. Let’s look at the steps:
- First, let us implement the
Camera
class, which will represent our main API to work with a 3D camera. The...