1
$\begingroup$

I asked this in regular SO but I think people are not understanding the question so i will try here:

So, for anyone familiar with Google Maps, when you zoom, it does it around the cursor.

That is to say, the matrix transformation for such a zoom is as simple as:

TST^{-1}*x

Where T is the translation matrix representing the point of focus, S the scale matrix and x is any arbitrary point on the plane.

Now, I want to produce a similar effect with a spherical camera, think sketchfab.

When you zoom in and out, the camera needs to be translated so as to give a similar effect as the 2D zooming in Maps. To be more precise, given a fully composed MVP matrix, there exists a set of parallel planes that are parallel to the camera plane. Among those there exists a unique plane P that also contains the center of the current spherical camera.

Given that plane, there exists a point x, that is the unprojection of the current cursor position onto the camera plane.

If the center of the spherical camera is c then the direction from c to x is d = x - c.

And here's where my challenge comes. Zooming is implemented as just offsetting the camera radially from the center, given a change in zoom Delta, I need to find the translation vector u, colinear with d, that moves the center of the camera towards x, such that I get a similar visual effect as zooming in google maps.

Since I know this is a bit hard to parse I tried to make a diagram: enter image description here

TL;DR

I want to offset a spherical camera towards the cursor when I zoom, how do i pick my translation vector?

$\endgroup$
12
  • $\begingroup$ Isnt this a standard pole vector problem? Z is vector from center of circle. X is Z cross up (vector from center to north pole) , Y is Z cross X and the translate is R $\endgroup$
    – joojaa
    Dec 11 '19 at 18:46
  • $\begingroup$ I am not sure I am understanding your question, this isn;t a kinematic issue $\endgroup$
    – Makogan
    Dec 11 '19 at 18:50
  • $\begingroup$ You understand affine matrices? $\endgroup$
    – joojaa
    Dec 11 '19 at 18:54
  • $\begingroup$ I want to say yes, it's a transformation that remains the same regardless of the position of the input. e.g trnaslation is affine, scaling isn;t $\endgroup$
    – Makogan
    Dec 11 '19 at 18:56
  • 2
    $\begingroup$ The goal seems a bit strange since the entire point of an orbiting camera is to keep the target point at the center. I would recommend doing what Blender does, and having the target point change only when the user pans. Doing what google maps does in 3D doesn't make much sense because there are infinitely many positions along Z that match the mouse coordinates, and even zooming changes which of those points are visible (assuming perspective projection). $\endgroup$
    – Dan
    Dec 21 '19 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.