2
$\begingroup$

A spherical camera is pretty easy to define.

We have an anchor point C the camera always looks at and a relative position P where the camera is, which can be expressed in spherical coordinates, centered around the point C.

In this type of camera the the up direction is always the up vector of the world.

The implementation isn't terribly complex. given the parameters, we will calucate the position of the camera by doing:

rotation around the x axis by phi, rotation around the y axis by theta, multiply by the radius then translation.

And then we calculate the orientation of the camera with lookAt, centering the view at the anchor point.

The trackball camera is different however, it allows for orientations of the view in which the camera up isn't necessarily 0,1,0.

Also, in a spherical camera, the deltas around the x axis are mapped to one angle and the deltas around the y axis to the other. I am not 100% sure on how to represent nor map mouse movement to camera orientation in the case of a trackball.

$\endgroup$
1
  • 2
    $\begingroup$ Those seem to be arbitrary terms, but I got what you mean. Use $view = (T_cR_xR_yT_d)^{-1}$. Where $R_x$ is a rotation matrix around the $x$ axis, and $R_y$ is a rotation matrix around the $y$ axis, $T_d$ is the offset translation of the camera from point $C$, and $T_c$ is the translation matrix produced from the position of $C$. You may notice that in general you have $TRS$, in this case we do not have scaling, and we have added an extra translation (we do hierarchical transformations). You can think of it as parenting the camera to a pivot $C$ and rotating the pivot. $\endgroup$
    – lightxbulb
    Sep 27, 2019 at 16:54

1 Answer 1

0
$\begingroup$

This is a trackball camera:

https://www.khronos.org/opengl/wiki/Object_Mouse_Trackball

Vulkan users beware, the coordinate system flips and so some of the signs in your computations should eb different.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.