Archived

This topic is now archived and is closed to further replies.

Finding where I clicked in 3d versus where I clicked in 2d

This topic is 5149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In VB, I''m making a small game similar to red alert. I''ve got the rendering working properly, but I need to figure out where I clicked in the 3d image versus where I clicked on the form. Like in Red Alert or Warcraft, you click on a person or an object, i want to know what coordinates i clicked on in the 3d world. Also note, i want to know where I clicked on a plane in space which is flat. If you need more details just ask. Thanks.

Share this post


Link to post
Share on other sites
Thats called picking, and I think theres an example of it in the documentation. Basically, it is ray tracing from screen coords to world coords.

Source: (SDK root)\Samples\Multimedia\Direct3D\Pick
Executable: (SDK root)\Samples\Multimedia\Direct3D\Bin

Share this post


Link to post
Share on other sites
I saw a tutorial about this on gametutorials.com... let me find it...

http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg3.htm

Down the page...
It's openGL and C++ but the maths behind it should be the same as in D3D and VB

[edited by - structural on November 9, 2003 7:08:27 AM]

Share this post


Link to post
Share on other sites
The way I did it was to translate the 3D coords to 2D then find the closest 2D point to the mouse.

Mark
---------------------------------------------------------------
In some great dawn, a palisade,
eight pillars stand of stone and dust
surrounded by a lifeless sea
of roaming sand and closing dusk.

Share this post


Link to post
Share on other sites
Ok, these are helpful, but I was thinking there might be an equation to find it.

(im on a right-handed 3d coordinate system)

Lets say im looking from 45 points back and 30 points up from the point im looking at.

And the point im looking at should in theory be at the center of my form.

Is there an equation to find where i clicked based on where i am and what point im looking at? It''s most likely a proportion of some sort.

Share this post


Link to post
Share on other sites