This is topic Kind of Stupid 3D Graphics Question. in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=044075

Posted by ricree101 (Member # 7749) on :
 
Does anyone know how to translate a given point on the screen into the place on a plane where it intersects?

I'm trying to take the mouse position and figure out where it intersects with the Y=0 plane.

My understanding of things is that given a particular field of view angle, the screen would range from -angle/2 to +angle/2, and each point in the viewing area would progress linearly from those two extremes.

I would then use the angles formed by this to make a new vector which would be added to the vector in the direction the camera is pointed. Between this vector and the point the camera is located, it should be easy to find the intersection I want.

Is my understanding of this correct?
 
Posted by King of Men (Member # 6684) on :
 
In OpenGL there is a simple way to do this with the gluUnProject method. In DirectX I know nothing.

Your manual method would probably work too (why don't you just code it and see?) but beware of the general case; your camera might be parallel to the Y plane.
 
Posted by Nighthawk (Member # 4176) on :
 
Depends if you want to do it mathematically or geometrically.

Mathematically, there exists a "view transform" that transforms world objects in to screen coordinates. You can use this transformation against to either (1) transform a 3D point to the 2D screen to see if it's in the viewing frustrum, or (2) transform a screen coordinate in to a ray heading straight out in to the world down that specific screen pixel.

Geometrically, your assumption of linear progression is technically incorrect because that linear progression would take place following a curve. It's really hard to envision using geometry because all geometric representations assume that the starting viewpoint is a single point in space, not a rectangular viewing area like the screen. There's a way to do it, but I can't recall it right now.
 
Posted by ricree101 (Member # 7749) on :
 
First off, thanks for replying so soon.

KOM:
I tried coding it before I asked the question and it doesn't work. I'm trying to figure out whether or not I have the general idea correct before I spend a ton more time trying to get it to work. By the way, I'm using managed DirectX.


Nighthawk:
I know that it is from a single point. What I am trying to do is use the screen coordinates as an offset angle from the vector along which the camera is pointing. So when I say a linear progression, I mean a linear progression of angles, not actual coordinates on the plane.
 
Posted by Kwea (Member # 2199) on :
 
Ogg like food. Food good.
 
Posted by ricree101 (Member # 7749) on :
 
Indeed. Thanks for the bump, I suppose.
 
Posted by HollowEarth (Member # 2586) on :
 
da da da this sounds like a job for... the library.
 


Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2