Solved

Calculating window and mouse position (OpenGL)

Posted on 2004-04-04
5
2,679 Views
Last Modified: 2013-12-26
Aright, here's a good one, and I'll probably have to do ray casting (help), but I'm looking for something easier.

Here's the setup: I have a window (QUAD object) inside an OpenGL window. When I rotate the Window about the y-axis, I remap the mouse so that it projects down to the window, no matter which angle it is at (or am I making things to difficult?)  
0
Comment
Question by:rossryan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Expert Comment

by:Jas001
ID: 10781121
Ok, I hope I understand you...
You're designing some sort of window system and the windows have some kind of animation or movement when they gain focus right? Like laying down to facing the camera?  

Why does the mouse have to be in the window?  Is there something in there they need to click on?  Can you clarify what you're trying to do?
0
 

Author Comment

by:rossryan
ID: 10865843
Hmm. They do not lay face down. Take a look at Project Looking Glass. It's something comparable to that. They may be at an angle, and I think I need the normal to convert back to the angled windows real coordinates.
0
 
LVL 2

Accepted Solution

by:
enkimute earned 500 total points
ID: 10947782
Thats not so difficult.

Lets define some stuff :

Mw = Model View matrix used to transform your 'quad' from object space to world space. (you can get this from gl with glGetFloatfv)
P    = Projection matrix in your openGL setup. (same stuff .. glGetFloatfv)
Mpw = Mw * P = Modelview projection matrix, or the matrix you have to multiply the object space quad with to end up in screenspace. ( a simple matrix multiply )

IMpw = (Mpw)^ -1 = The inverse of the modelview projection matrix. If the original matrix is orthonormal, you can use a cheap matrix invert .. (thats true most of the time).

So multiplying a vertex with IMpw will transform it from screen space back to the object space of your original quad. So if you multiply the position of the mouse cursor
with the IMPw, you get a resulting position that you can correctly compare with the vertex positions of your 'quad'

Hope that clears it up for you !
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get correct installed directX version? 3 810
How to make 2D games with custom graphics? 3 307
Unity 3D Lighting 1 96
triangle challenge 4 207
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question