Adding camera animations and motion
Besides having a user-controlled first-person camera, it is convenient to be able to position and move the camera programmatically inside a 3D scene – this is helpful for debugging when we need to organize automatic screenshot tests with camera movement, for example. In this recipe, we will show how to do it and extend our minimalistic 3D camera framework from the previous 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 UI.
Getting ready
The full source code for this recipe is a part of the final demo application for this chapter, and you can find it in Chapter04/06_DemoApp
. Implementations of all new camera-related functionality are located in the shared/Camera.h
file.
How to do it...
Let’s look at how to programmatically control our 3D camera using a simple ImGui-based user interface:
...