Sign in to follow this  
REspawn

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
just so you know helping people with thier school work is against the forum policies here, so that is why your not getting any answers. You should probably be ansking your professor/TA if you having that much trouble, that is what you are paying for btw.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

<sarcarm on>
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.
<sarcarm off>

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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Demus79

<sarcarm on>
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.
<sarcarm off>

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.

Share this post


Link to post
Share on other sites
- 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.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this