Archived

This topic is now archived and is closed to further replies.

TomCat

Mouselook and the matrix

Recommended Posts

TomCat    122
Hi, my Problem is the mouselook. I have a camera matrix and I want the vision to be rotated with the mouse movement. If it''s only X-movement it will rotate around the y-axis and if it''s only the y-movement it will rotate around the x-axis. Now my problem: I first tried to rotate both axis one behind the other with the last mousedata I recieved (from DInput). Now when I am moving my mouse its seems to work fine, but when I try to get to the initial state the whole scene is a bit rotated (around the Z axis). Ok, my next trial: I constructed an arbitrary axis to rotate around (multiplied with the current matrix - http://www.gamedev.net/reference/articles/article1199.asp). it againg seemed to work fine. But again the same problem, i cannot restore the initial scene (ok, after 10s of mousemovement the whole scene is rotated again to the origin - again the Z-axis). any Suggestions ? should I try to store the complete rotation-data anywhere and each time create a new translation matrix and then rotate it with this data or something like that ?

Share this post


Link to post
Share on other sites
Enselic    829
One technique that I used was to store the right, up and forward vector and then build up my own d3d-veiwmatrix. If you want to rotate the camera you make a rotation matrix and multiply the right, up, and forward vector with that rotation matrix.


I am a signature virus. Please add me to your signature so that I may multiply.

Share this post


Link to post
Share on other sites
LilBudyWizer    491
You have to reverse the order of the rotations. Look north then look up. Now look east and look up. Do you tilt your head the same direction in both cases? The axis you are rotating about is the objects forward, right and up, not the world's.

Oh, perhaps worth mentioning. You can do y, x, -y, -x rather than y, x, -x, -y, but you have to find the right axis to rotate about. You have to run (0,1,0) through the yx rotation to find the axis for the -y rotation. That lines your x axis back up with the world so you can just use -x directly. At least I think you can.

[edited by - LilBudyWizer on March 18, 2003 11:17:00 AM]

Share this post


Link to post
Share on other sites
grhodes_at_work    1385
One of our applications (not a game) has an "orbital" camera view, which is similar to the examine view in some 3D model viewing applications. The way we recover the initial view is to simply replace the view matrix with one of a set of standard view matrices directly. We simply load a saved "front" view matrix or "back" view matrix. If the user happens to move the mouse in the right way so that the view is restored via mouse, that''s wonderful. But we just don''t do anything special to make it easy to do that. (It is possible to learn a certain pattern of mouse movements that will recover the view.) This is more of a computer-aided-design view, and the camera simply snaps immediately back into the initial view. You''d have to interpolate from the current view to the initial view if you wanted the camera to move smoothly to the initial view.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
TomCat    122
ok, another solution is to rotate Y-mousemovement within the cameras x-axis (local) and x-mousemovement around a world''s y-axis (global).

This is no 100% free 3D movement, but I think it will do the job. However there is no confusion when moving the mouse a while - you can get back to the original (unrotated) scene.

(i.e. when looking parallel to the world''s y-axis and moving the mouse to the left/right it will "roll" the vision)

and thx for your help

Share this post


Link to post
Share on other sites