# Implementing a "Pan Hand."

I apologize in advance if this question is a bit muddled. I’m relatively new to advanced GL coding.

I’m using JOGL + the JOGL port of GLEEM to write an app. I want to implement a feature similar to the “Pan Hand” tool in Adobe Acrobat/Reader. I’ve defined a plane (right now it’s the X,Y axes, but I’d like to keep my solution general). When the user clicks, I’m casting a ray onto this plane and determining the (x,y,z) ModelView coordinate that corresponds to the (x,y) screen position. When the user moves the mouse, I want to update the x and y entries of the base ModelView matrix s.t. the ray through the new (x,y) screen position still maps to the original (x,y,z) point on the plane in scene space.

My naive intuition about how to achieve this is to retrieve the ModelView, Projection, and Viewport matrices, then solve for the transform-x and transform-y entries in the ModelView matrix, given the new screen(x,y) and fixed scene(x,y,z) coordinates. Is there a way to exploit the capabilities of the fixed-function pipeline to do this without a bunch of math on the CPU?

Yes that’s the idea. With the new (x,y) hand coordinates you can transform them back to object space then modelview space computing the inverse of the transformation: (Projection * Modelview). The function gluUnProject may help you.

I can see how to do this, except I don’t have the w component of the coordinates, needed to produce the “Perspective Division” portion of the projection (ref. Fig 3-2 in the redbook, at http://glprogramming.com/red/chapter03.html) …

Ideally it seems like I want to solve so that Modelview(4x4) = worldCoords(4x1)^-1 * screenCoords(2x1) * Viewport(2x2)^-1 * PerspectiveDivision(4x1)^-1 * Projection (4x4)^-1

but I want to fix all elements of Modelview except 1,4 and 2,4

Anyone have a code snippet, by any chance?