Solved

Calculating window and mouse position (OpenGL)

Posted on 2004-04-04
5
2,669 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
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now