Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Finding mouse 3d coordinates

Author
Message
pictionaryjr
16
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 16th May 2009 07:02 Edited at: 16th May 2009 07:03
How do I find the 3d coordinates that the mouse is pointing at.

What I mean is,
Say I want to find the location the mouse is pointing at. So my answer to the equation would be the x and z value of the place the mouse is pointing at. The y value of the place would be 0, but that's what causes my problem.

The problem I'm having is that if the y value changes, then my maths get all messed up and my values become incorrect.

Please post what you don't understand about the question, and I'll try to restate it a better way.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 16th May 2009 08:42
The problem is that you're creating a third dimension from thin air.
Where ever the mouse is on the screen there's a line of 3D coords that would be correct for that 2D position. What you've got to do is find the line and trace along it until you find a position you'd like to stop at, i.e. collides with an object.
I haven't done this so its just theory.

Riddle: The more you take, the more you leave behind. What are they? Answer
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 16th May 2009 12:09
I did it once where I took a plain that is the screen size (640x480) and placed it away from the camera until it took up the whole screen exactly. I then used that distance as the value for the distance that the mouse is (lets call it the z value). X and Y remained the same as MouseX and MouseY (as I recall there was a bit of trouble with that and it required some tweeking) and the Z was constant.

Then I created a box that is 1x1xREALLY BIG, positioned it at the camera and rotated it such that the it would pass as a line from the camera coords to the mouse coords and check for collision.

I will try to get some code up tomorrow, but no promises. I lost my old stuff due to corruped hard drive, but I did have it working.

Make sense?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose

Login to post a reply

Server time is: 2025-05-16 16:31:20
Your offset time is: 2025-05-16 16:31:20