LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: Multiplying mouse position vector by model view projection matrix  (Read 122 times)

squishybanana

  • Newbie
  • *
  • Offline Offline
  • Posts: 1

I've recently started working on a game engine for java using lwjgl. I created vector and matrix classes that I can multiply. I want to check if the mouse is within a certain range in world space even though glfw gives me the pixel it's on. The problem is that opengl uses 4 dimensions and the mouse is 2 dimensions. I know that the fourth dimension represents perspective but I don't know how I should multiply this.

How does the modelview projection matrix store information?
Logged

Kai

  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 900

What you want is called "unprojecting". You want to unproject window coordinates to world coordinates.
Google for "OpenGL unproject", and you'll find a lot of resources explaining this.
Logged