OK, i'm following Middleditch solution and this should be good, but I think i've missed something. So, after reading all this, I just want to know: To obtain a correct first person camera rotate, I must need to use Quaternios to make the rotations, but how to rotate around world axis? Where this is a Matrix4f view matrix and cameraRotate is a Vector3f that just handle the angles to rotate obtained from mouse move. This.multiplicate(qYaw.toMatrix4f().toArray()) This.multiplicate(qPitch.toMatrix4f().toArray()) Quaternion qYaw = Quaternion.createFromAxis(cameraRotate.y, 0.0f, 1.0f, 0.0f) This is a little piece of code that i'm using to make the rotation: Quaternion qPitch = Quaternion.createFromAxis(cameraRotate.x, 1.0f, 0.0f, 0.0f) Individually, each 'GL11.glRotatef (etc,etc,etc,etc) and GL11.glRotatef (etc -1.0f, etc,etc,etc)' works fine, but when they are all together, strange rotations happen. The array 'rot' holds the x, y, and z rotations, and is updated through these 3 methods in the cube class. But even using Quaternions, this doesnt work and no matter how much I read about Euler Angles, everybody says to me dont touch on it! This should reset the rotation of each axis. I need a camera to rotate arround world Axis and not about its own axis. The move (translation) is working fine but the rotation isnt working like I need. I have made my own math libary (Java) to use on my game (LWJGL). After 2 weeks of reading many math formulas and such I know what is a Quaternion, an Axis Angles and Matrices.
0 Comments
Leave a Reply. |