Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val scaledMousePos = mousePos * GuiUtils.scaledResolution.getScaleFactor
- val eyeZInverse = 1F / eyeZ
- ZBuffer.rewind()
- GL11.glReadPixels(scaledMousePos.x, mc.displayHeight - scaledMousePos.y, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, ZBuffer)
- val mouseZ = ZBuffer.get()
- val m33 = -(1 - zFar / eyeZInverse) / (zNear - zFar)
- val viewZ = (mouseZ + m33 * zNear) / (mouseZ * eyeZInverse + m33)
- val hWidth = viewport.width / 2 * GuiUtils.scaledResolution.getScaleFactor
- val hHeight = viewport.width / 2 * GuiUtils.scaledResolution.getScaleFactor
- val pixelToViewRatio = hWidth * 2 / mc.displayWidth
- val viewX = scaledMousePos.x * pixelToViewRatio - hWidth
- val viewY = -(scaledMousePos.y * pixelToViewRatio - hHeight)
- val viewXProjected = viewX - viewX * viewZ * eyeZInverse
- val viewYProjected = viewY - viewX * viewZ * eyeZInverse
- Vector3(viewXProjected, viewYProjected, viewZ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement