What are the necessary maths to achieve the camera panning effect used in 3ds max?
First, here's a couple of demos of the 3ds max camera panning behaviour:


As you can see, the distance between the cursor and the mesh will always remain the same throughout the entire movement (mouse_down+mouse_motion+mouse_up).
My naive and failed attempt has been trying to move the camera on the plane XY by using dt (frame time) multiplied by some hardcoded constant and the result is really ugly and uintuitive.
So, could you explain how the maths of camera panning in 3dsmax work so I'll be able to implement it in my own engine?
PS: You can assume I know how to unproject from screen coordinates to world space if that's required to achieve the desired effect.
Thanks in advance.
EDIT:
I've tried using the method described here and the results are not similar to what I want to achieve, here's the code I've used:
def glut_mouse(self, button, state, x, y):
self.last_mouse_pos = vec2(x, y)
self.mouse_down_pos = vec2(x, y)
def glut_motion(self, x, y):
pos = vec2(x, y)
move = self.last_mouse_pos - pos
self.last_mouse_pos = pos
self.pan(move)
def pan(self, delta):
forward = vec3.normalize(self.target - self.eye)
right = vec3.normalize(vec3.cross(forward, self.up))
up = vec3.normalize(vec3.cross(forward, right))
if delta.x:
right = right*delta.x
if delta.y:
up = up*delta.y
self.eye+=(right+up)
self.target+=(right+up)
And here's a little example of the behaviour:

from How to implement camera pan like in 3dsMax?
No comments:
Post a Comment