Closed
Description
Required Skills: C++
Difficulty: Medium
Currently, we let the camera move freely in the scene. This can result in the camera accidently moving away from the visible map terrain. It would be better if we could set the boundaries of the camera movement according to the current size of the map, so that the camera can't be moved outside of the play area. This should be implemented for the CameraManager
and not for the camera class itself!
Tasks:
- Add 4 boundary values using the
float
type to theCameraManager
class. For testing purposes, you can hardcode these 4 positions at the start:- south west:
12.25f
(min x axis coordinate) - south east:
32.25f
(max x axis coordinate) - north west:
12.25f
(max z axis corrdinate) - north east:
-8.25f
(min z axis coordinate)
- south west:
- Check if the camera position is within those boundaries when the camera is moved by the camera manager. If the camera is moved outside of the boundaries, the value should be clamped to the respective min and max values. You can use
std::clamp
for this purpose. - Set the camera boundaries during initialization of the camera manager (you may use hardcoded values).
Note that the position the camera is at is different from the position the camera looks at! When we want to set boundaries, we usually want to set boundaries based on what the camera can look at. However this also means that we have to convert look-at coordinates to is-at (camera position) first. You can check how the camera dies this by checking out theCamera::look_at_scene(..)
method. - (optional; Difficulty: High) Set the camera boundaries from the game simulation using the map size. This requires you to pass the map size across thread boundaries, so you need to understand the C++ thread model.
Further Reading
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
✅ Done
Status
renderer