# kpalko

Member

5

114 Neutral

• Rank
Newbie
1. ## Quaternions for FPS Camera?

I've decided to continue my Udacity course in the hopes that he'll go over this. I'm sure being exposed to it twice (once here, and once during the course) will help me understand it. Thanks for everyone's help.

3. ## Quaternions for FPS Camera?

So, I'm trying to write it in layman's terms... Here is what I have so far, but it doesn't seem to be working: (function() { var rotationRadians = THREE.Math.degToRad(90); var viewVector = new THREE.Vector3( 0, 0, 0 ); var viewQuat = new THREE.Quaternion( viewVector.x, viewVector.y, viewVector.z, 0 ); var viewRotationVector = new THREE.Quaternion( 0, 0, 0 ); var viewRotationQuat = new THREE.Quaternion( viewRotationVector.x * Math.sin(rotationRadians/2), viewRotationVector.y * Math.sin(rotationRadians/2), viewRotationVector.z * Math.sin(rotationRadians/2), Math.cos(rotationRadians/2) ); var rotatedQuat = viewRotationQuat.multiply(viewQuat); var conjugate = viewRotationQuat.conjugate(); rotatedQuat.multiply(conjugate); viewVector.x = rotatedQuat.x; viewVector.y = rotatedQuat.y; viewVector.z = rotatedQuat.z; console.log(viewVector); })(); Also, if my camera is placed at 0,0,0, should be view vector also be placed there (as well as the rotation)? I'm using this GameDev article to try and figure it out... I feel like I'm getting closer but I'm missing some very important details...   http://www.gamedev.net/page/resources/_/technical/math-and-physics/a-simple-quaternion-based-camera-r1997
4. ## Quaternions for FPS Camera?

You all are awesome! Thanks for the replies.     Right now I'm just playing with the camera. I've added it to the scene at 0, 0, 0. I've gotten it to rotate using camera.rotation.x/y. From what I've seen, other people seem to implement a vector that the camera "looks at" (using the .lookAt function). Really I just want to create a camera that allows me to look around in the scene. I put a cube at 0, 0, 5 and just want to be able to move the camera around and look at the cube from different angles. For the development I'm using Threejs (threejs.org).       I'm at work now, but I'll check this out when I get home. So just so I'm understanding the basics correctly...   Orientation returns a Matrix (x,y,z,w), which is two Quaternions multiplied together. I'm guessing the * has been overloaded to support multiplying Quaternions? The second part is a little difficult to understand. I can't find a resource to define what the translate method takes in and returns. Would mTranslation be the vector my camera was currently located at?
5. ## Quaternions for FPS Camera?

I've been studying for 4 days straight trying to figure out how to make a camera that behaves like one does in FPS games. I've been lead to believe I need Quaternions for this, but I also see a lot of talk about Euler angles and Yaw/Pitch/Roll.   If it is Quaternion angles, can someone give me a very basic example of how you would make a camera look up 45 degrees using a Quaternion?   I prefer to leave the mouse calculations out because they just seem to make it more difficult to understand.   Any help would be greatly appreciated as I'm getting close to giving up :(   Thanks