FAForever / FAForever/fa-casting-cinematics

Introduce `LookAt` behavior

Aperta
#3 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Lua
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## 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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.