-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce LookAt
behavior
#3
Comments
We can also have an alternative to re-use the current camera position (the origin), and just switch up the target. This allows you to 'look around' without translating the camera. Great for large battles where a lot is going on. |
I don't quite understand it. Origin is the position of the camera and target is the position of the object to be looked at right? But is |
Zoom would technically be the Y coordinate of the |
ok, so even though it's a separate value for this function we don't need to calculate it separately. |
I think you're right, but it would be nice if someone could help me with it 😃 . There will be more math-related suggestions in the (near, as in - March) future. This issue is a nice step into that direction. |
I think something like |
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 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 they
coordinate of the origin.With that we need to make the camera look at the
target
position. We can do that by computing:orientationHPR
parameter of MoveTo (in radians).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 function with:
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 thetarget
. 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.
The text was updated successfully, but these errors were encountered: