Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ... irrelevant code ...
- GL11.glPushMatrix()
- // Translate away from player
- GL11.glTranslated(x, y, z)
- // Translate into the center of the ship block for rotation
- GL11.glTranslated(0.5, 0.5, 0.5)
- // Note: Correction matrix is the exact same as the one used for my bounding box
- // Convert our correction matrix into a buffer to pass to LWJGL (and then to OpenGL)
- val rotationCorrectionBuffer = matrixToFloatBuffer(entity.correctionMatrix)
- // Note: Rotation matrix is the exact same as the one used for my bounding box
- // Convert our rotation matrix to a FloatBuffer to pass to LWJGL (and then to OpenGL)
- val rotationBuffer = matrixToFloatBuffer(entity.renderMatrix)
- // Multiply our transformation matrix by the rotation correction
- GL11.glMultMatrix(rotationCorrectionBuffer)
- // Then multiply by the actual rotation
- GL11.glMultMatrix(rotationBuffer)
- // Translate out of the center for drawing the ship
- GL11.glTranslated(-0.5, -0.5, -0.5)
- // Basically takes a 4x4 matrix and converts it to a FloatBuffer
- def matrixToFloatBuffer(m: Matrix4f): FloatBuffer = {
- val fb = BufferUtils.createFloatBuffer(16)
- fb.put(m.m00)
- fb.put(m.m01)
- fb.put(m.m02)
- fb.put(m.m03)
- fb.put(m.m10)
- fb.put(m.m11)
- fb.put(m.m12)
- fb.put(m.m13)
- fb.put(m.m20)
- fb.put(m.m21)
- fb.put(m.m22)
- fb.put(m.m23)
- fb.put(m.m30)
- fb.put(m.m31)
- fb.put(m.m32)
- fb.put(m.m33)
- fb.flip()
- return fb;
- }
- ... irrelevant code ...
Advertisement
Add Comment
Please, Sign In to add comment