Advertisement
PaleoCrafter

Untitled

Jan 4th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.87 KB | None | 0 0
  1. val scaledMousePos = mousePos * GuiUtils.scaledResolution.getScaleFactor
  2. val eyeZInverse = 1F / eyeZ
  3. ZBuffer.rewind()
  4. GL11.glReadPixels(scaledMousePos.x, mc.displayHeight - scaledMousePos.y, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, ZBuffer)
  5. val mouseZ = ZBuffer.get()
  6. val m33 = -(1 - zFar / eyeZInverse) / (zNear - zFar)
  7. val viewZ = (mouseZ + m33 * zNear) / (mouseZ * eyeZInverse + m33)
  8. val hWidth = viewport.width / 2 * GuiUtils.scaledResolution.getScaleFactor
  9. val hHeight = viewport.width / 2 * GuiUtils.scaledResolution.getScaleFactor
  10. val pixelToViewRatio = hWidth * 2 / mc.displayWidth
  11.  
  12. val viewX = scaledMousePos.x * pixelToViewRatio - hWidth
  13. val viewY = -(scaledMousePos.y * pixelToViewRatio - hHeight)
  14.  
  15. val viewXProjected = viewX - viewX * viewZ * eyeZInverse
  16. val viewYProjected = viewY - viewX * viewZ * eyeZInverse
  17.  
  18. Vector3(viewXProjected, viewYProjected, viewZ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement