![java lwjgl camera class java lwjgl camera class](https://i.stack.imgur.com/bGRAN.jpg)
Quaternion temp = Quaternion.mul(bearing, pitch, null) ītFromAxisAngle(new Vector4f(0f, 1f, 0f, bearingAngle * PI_OVER_180)) Matrix4f pitchMatrix = convertQuaternionToMatrix4f(pitch) Quaternion.mul(pitch, bearing, rotation) quaternion multiply is non-commutative (very important).
![java lwjgl camera class java lwjgl camera class](https://i.stack.imgur.com/QndhQ.png)
* This should be called whenever pitch, bearing, or roll is changed Public Camera(float initialBearing, float initialPitch) * Constructor with initial direction values Private FloatBuffer viewMatrixBuffer = BufferUtils.createFloatBuffer(4*4) Private Vector3f direction = new Vector3f() Private Vector3f position = new Vector3f() * Need to add roll(), lookAt(), and maybe SLERP So my question is, is there a more efficient way of doing this? I suppose I could reuse the Quaternion objects, rather than creating them again each time, but I only really halfway understand the maths, so I can't think what else to do to clean it up. Now this all works fine, but it seems like a really inefficient way of doing things. Then in my render() loop, I translate the view based on the vector 'direction'. Private static Matrix4f convertQuaternionToMatrix4f(Quaternion q) Matrix = convertQuaternionToMatrix4f(temp) ĭirection = new Vector3f(matrix.m20, j, matrix.m22)
![java lwjgl camera class java lwjgl camera class](https://examples.javacodegeeks.com/wp-content/uploads/2016/01/07-Results.png)
Quaternion temp = Quaternion.mul(headingQuaternion, pitchQuaternion, null) Matrix4f pitchMatrix = convertQuaternionToMatrix4f(pitchQuaternion) Matrix4f matrix = convertQuaternionToMatrix4f(rotation) įloatBuffer matrixBuffer = BufferUtils.createFloatBuffer(4*4) Quaternion rotation = Quaternion.mul(pitchQuaternion, headingQuaternion, null) tFromAxisAngle(new Vector4f(0f, 1f, 0f, heading * PI_OVER_180)) Quaternion headingQuaternion = new Quaternion() tFromAxisAngle(new Vector4f(1f, 0f, 0f, pitch * PI_OVER_180)) Quaternion pitchQuaternion = new Quaternion()