mouse location a plane

BlitzMax Forums/OpenGL Module/mouse location a plane

kfprimm(Posted 2006) [#1]
Say I was writing my own Maplet, how could find the X and Z coordinates of my mouse at a the Y location of my reference plane? Sorry if it sounds confusing, it's the only way I can think to explain my question...I have a feeling I can use glUnProject but I don't know where to start. I've already looked at the NeHe Tutorial 13 but that didn't help me.


Damien Sturdy(Posted 2006) [#2]
I converted some b3D code to max that does ray>Plane at Mouse coords. It relies on SOW at the moment so it might not be usable straight off in OGL.

If nobody answers when I get back home I will try to fish out a usable version of it. As I said, it uses SOW right now, It needs to use OGL instead for it to be of use to you.

That GlUnproject function might come in handy!

[EDIT]

You're not the only one :)

http://www.blitzbasic.com/Community/posts.php?topic=62400


kfprimm(Posted 2006) [#3]
Alright, Cygnus. Thanks. BTW take your time, I can wait. :-)


Damien Sturdy(Posted 2006) [#4]
I had a look, Forgot to post:

I can provide you with code minus a "screenvector" function which is required, so it's not much use as is.

what we need to figure out in OGL is a vector from the camera to the mouse, I've no idea how to explain but perhaps you will understand anyway! This Screenvector function returns the direction from the camera to the mouse position, so that a ray from the camera in this direction passes through the mouse position.

the code is standard "ray to plane", using the "camera to mouse vector" to create the ray. This is the function we need to recreate :)

(I'm afraid im no expert in OGL so I've no idea how to go about this, but If it helps I will provide the rest of the code when i get home- 9-9.5 hours from now.)


kfprimm(Posted 2006) [#5]
unfortunatly, I no clue as well...

Go ahead and post the code. At least that way I can play with it and possibly figure it out. I do believe, however, glUnProject would do what we need. I shall investigate!