Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] Mouse intersect plane (Full source available)

Started by REspawn Mar 26, 2006 at 2:33 PM 4 replies 1.8k views
Original Post
REspawn
REspawn
Hi, this has been driving me nuts for weeks now, im trying to get the point where the mouse intersects a plane. I have to have this project for college done for thur and i im just stuck. If anyone can help it would be excellent, i have created a simple test project to show what im doing, Download (118kb) Thanks for any help, -Dave
REspawn
REspawn
Sorry i didnt know, but its not for a 3d programming course, its a general software development course and for our project we have to create an application, it can be anything we want, so i chose to make a simple 3d app.
Demus79
Demus79


A mouse intersecting a plane ... What do you even mean by saying mouse intersecting a plane. My mouse for example is on the table and never intersects any plane. Real World Physics Engine (TM) keeps it that way.


When you are able to ask the question in the correct form / define the problem exactly, I bet that you'll find your answer in the google very easily.
REspawn
REspawn
Quote:
Original post by Demus79


A mouse intersecting a plane ... What do you even mean by saying mouse intersecting a plane. My mouse for example is on the table and never intersects any plane. Real World Physics Engine (TM) keeps it that way.


When you are able to ask the question in the correct form / define the problem exactly, I bet that you'll find your answer in the google very easily.


If i could find it in google i wouldnt be posting here.
What i am trying to get is the x,y,z coords where a mouse ray intersects a plane.
Bob Janova
Bob Janova
- Generate a line from the mouse pointer. This depends on (a) the observer position (which is usually on the line) and (b) how you want the selection to work. You'd typically take the middle of the screen as the observer's view direction (which will be stored somewhere) and the X and Y directions to be angles from that.
- Using the 3D maths you (should) have learned, it is easy to calculate the point of intersection of a line and a plane.
- For each surface you do this for, you need to check if the intersection point is actually on the surface, since a surface isn't an infinite plane. For convex polygonal surfaces this is quite easy (although I can't actually think how to do it instantly).

Alternatively, if you're using OpenGL, there are functions that let you pick polys that a ray intersects. I've never used it but any GL tutorial would tell you how to do it. Go post in the OpenGL forums if you want specific info about that.

I don't want to just post code examples (even if I had them), since this is for project work. It will be much better for you to go off and understand the problem, read up on the appropriate 3D maths if necessary and write the code yourself. (The code is trivial, anyway; understanding what you need to do is the hard bit.)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.