Adding camera animations and motion
Besides having a user-controlled free camera, it is convenient to be able to position and move the camera programmatically inside a 3D scene. In this recipe, we will show how to do this using a 3D camera framework from the Working with a 3D camera and basic user interaction recipe. We will draw a combo box using ImGui to select between two camera modes: a first-person free camera and a fixed camera moving to a user-specified point settable from the user interface.
Getting ready
The full source code for this recipe can be found in Chapter4/VK01_DemoApp
. Implementations of camera-related functionality are located in shared/Camera.h
.
How to do it...
Let's look at how to programmatically control our 3D camera using a simple ImGui-based user interface:
- First, we need to define the camera positioners attached to the camera – just a bunch of global variables:
glm::vec3 cameraPos(0.0f, 0.0f, 0.0f); glm::vec3 cameraAngles(-45...