Note that there are some explanatory texts on larger screens.

plurals
  1. POCan someone explain how I can use Quanternions to use the mouse to look around like a FPS?
    text
    copied!<p>Yesterday I asked: <a href="https://stackoverflow.com/questions/784445/how-could-simply-calling-pitch-and-yaw-cause-the-camera-to-eventually-roll">How could simply calling Pitch and Yaw cause the camera to roll?</a></p> <p>Basically, I found out because of "Gimbal Lock" that if you pitch + yaw you will inevitably produce a rolling effect. For more information you can read that question.</p> <p>I'm trying to stop this from happening. When you look around in a normal FPS shooter you don't have your camera rolling all over the place!</p> <p>Here is my current passive mouse func:</p> <pre><code>int windowWidth = 640; int windowHeight = 480; int oldMouseX = -1; int oldMouseY = -1; void mousePassiveHandler(int x, int y) { int snapThreshold = 50; if (oldMouseX != -1 &amp;&amp; oldMouseY != -1) { cam.yaw((x - oldMouseX)/10.0); cam.pitch((y - oldMouseY)/10.0); oldMouseX = x; oldMouseY = y; if ((fabs(x - (windowWidth / 2)) &gt; snapThreshold) || (fabs(y - (windowHeight / 2)) &gt; snapThreshold)) { oldMouseX = windowWidth / 2; oldMouseY = windowHeight / 2; glutWarpPointer(windowWidth / 2, windowHeight / 2); } } else { oldMouseX = windowWidth / 2; oldMouseY = windowHeight / 2; glutWarpPointer(windowWidth / 2, windowHeight / 2); } glutPostRedisplay(); } </code></pre> <p>Which causes the camera to pitch/yaw based on the mouse movement (while keeping the cursor in the center). I've also posted my original camera class <a href="http://pastebin.com/m20d2b01e" rel="nofollow noreferrer">here</a>.</p> <p>Someone in that thread suggested I use Quaternions to prevent this effect from happening but after reading the <a href="http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation" rel="nofollow noreferrer">wikipedia page</a> on them I simply don't grok them.</p> <p>How could I create a Quaternions in my OpenGL/Glut app so I can properly make my "Camera" look around without unwanted roll?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload