Jump to content
  • Advertisement
Sign in to follow this  
alex_r

Object Selection in DX

This topic is 4885 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

Hi, I have a small quesion about DX, how I select a object? What I like to know is, how I get a 2D value (X and Y) from the mouse for example, an convert do 3D (X, Y and Z)? In OGL I use the gluPickMatrix, like NeHe lesson 32 (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=32). In DX, how can I do this? Thanks

Share this post


Link to post
Share on other sites
Advertisement
well its easy to do that in direct3d:

1) gets mouse position in 3D space "vRayPos":

vProjected = D3DXVECTOR3(MousePosX, MousePosY, 0.0f);
D3DXVec3Unproject(vRayPos, vProjected, Viewport, matProjection, matView, matWorld);

2) gets mouse direction in 3D space "vRayDirection":

vProjected = D3DXVECTOR3(MousePosX, MousePosY, 1.0f);
D3DXVec3Unproject(vRayDirection, vProjected, Viewport, matProjection, matView, matWorld);

3) do a mesh intersection from the Mesh class:

dig in that under C++ cause i have only did hte intersection in the C# MDX. its the same concept, but thats fairly it.
u will be using the vRayPos and vRayDirection in the intersection function.


once u do the intersection, it will return the necessary information, and u can take it from there.

Share this post


Link to post
Share on other sites
Hum... Is like gluUnproject...
You know how it work in a matrix?
I'm developing a lib independet framework, but I don't find how it work...


Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!