Panning the Camera

Started by
5 comments, last by CpMan 22 years, 3 months ago
How do I translate a camera matrix up/down, left/right so that the translations are always parrallel to the screen, regardless of any other rotations and the like in the world. Like panning in a 3D Modeler Thanks Matt
VSEDebug Visual Studio.NET Add-In. Enhances debugging in ways never thought possible.
Advertisement
there is a bunch of matrix functions included in the dxsdk. There''s a bunch of d3dxmatrix* functions. When you go to set up the camera matrix, change the values depending on where you want the scene to be located.
I have that part down. This is the problem. Say I have a tradition viewpoint, like 0,0,0 looking at 0,0,-10. panning then is simple, simply add whatever the magnituse of the pan is to each vector, then recreate the camera matrix using one of D3DX''s functions. but say I rotate the camera around 0,0,-10, so that instead of the camera position being a simple 0,0,0, it is now 1,1,1, or something thatmakes the D3D x and y axes parrallel to the screen. Then, when trying to do a pan, adding the values to the x and y axes, the sideways pan might not be the logical sideways because the axes in world space are not situated logically in camera space. The pan may go inwards or up, or any other direction based on what other rotations have been made. So I need to be able to pan in the directions that are logical to the user. In other words, I need a set of temporary axes that correspond to the current view, not to the world, on which to pan. Get it?

VSEDebug Visual Studio.NET Add-In. Enhances debugging in ways never thought possible.
yup i get it, try saving the rotation angle in radians in a matrix and also keep the pan relevant to the rotation, xpan, ypan, in a matrix and the current position in doubles or floats. First move the original matrix to the current position. Then, I''m just guesing on it, but create a new matrix. Multiply the rotation matrix and the x/y pan matrix into the new matrix. Then multiply the original matrix with the new matrix and hopefully it might work.

i''m a terrible writer, hope you understand it...
Translate x by the sin(RotationAngle) * the horizontal movement you want

Translate Y by the actual vertical movement wanted

Translate Z by the cos(RotationAngle) * the horizontal movement you want

Of course this is only for Rotation around the Y axis!
Turring Machines are better than C++ any day ^_~
Have you thought of using orthonormalised bases ?

Reg''ds,
sTeVe

If it isn't working, take a bath, have a think and try again...

I was being relatively stupid. I already had a previous camera look-at matrix; all I had to do was extract the axes from it and step along those.
VSEDebug Visual Studio.NET Add-In. Enhances debugging in ways never thought possible.

This topic is closed to new replies.

Advertisement