FAForever / FAForever/fa-casting-cinematics
Introduce `LookAt` behavior
- Dominant language
- Lua
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Given two points, we can orientate the camera such that it is positioned at position A and looks at position B. We can re-use the [MoveTo](https://github.com/FAForever/fa/blob/Fix/buffer-overflow-01/engine/User/CameraImpl.lua#L48-L54) engine function to try and mimic the LookAt behavior.
We have the following data:
- `origin`, a vector in in world coordinates.
- `target`, a in world coordinates.
- `zoom`, the current zoom level (height) of the camera. This is technically the `y` coordinate of the origin.
With that we need to make the camera look at the `target` position. We can do that by computing:
- The heading of the `orientationHPR` parameter of [MoveTo](https://github.com/FAForever/fa/blob/Fix/buffer-overflow-01/engine/User/CameraImpl.lua#L48-L54) (in radians).
- The pitch of the `orientationHPR` parameter of [MoveTo] (https://github.com/FAForever/fa/blob/Fix/buffer-overflow-01/engine/User/CameraImpl.lua#L48-L54) (in radians).
This allows us to feed the [MoveTo](https://github.com/FAForever/fa/blob/Fix/buffer-overflow-01/engine/User/CameraImpl.lua#L48-L54) function with:
```lua
camera:MoveTo(origin, { heading, pitch, 0}, zoom, duration)
```
## Implementation details
We can determine the origin and target by using the same hotkey twice in succession. The first hit determines the `origin`, and the second determines the `target`. Once we have the target we can do the computations and start moving the camera.
## What is necessary
We need a function that given an origin + zoom level, and a target that we can compute the necessary heading and pitch to look at the target from the origin + zoom level.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.