Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

DirectX 10, Collision detection with mouse question.

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 Kevn   Members   

166
Like
0Likes
Like

Posted 02 January 2013 - 06:47 PM

I'm trying to make it so I can drag objects, like a box, around with my mouse in a DirectX 10/Windows application. So far I only have a plane for the floor, a few boxes, and my mouse coordinates displayed to the screen. What would be the best technique to detect when my mouse is over an object? Do I need to figure out where the box edges are in terms of screen coordinates and then do a compare with my mouse coordinates? If so, how do I determine the location of an object in terms of screen coordinates instead of my world coordinate system?



#2 kidman171   Members   

498
Like
1Likes
Like

Posted 02 January 2013 - 07:08 PM

Google 3d picking

#3 Kevn   Members   

166
Like
0Likes
Like

Posted 02 January 2013 - 07:17 PM

Thank you :)



#4 0r0d   Members   

1873
Like
0Likes
Like

Posted 02 January 2013 - 07:49 PM

I'm trying to make it so I can drag objects, like a box, around with my mouse in a DirectX 10/Windows application. So far I only have a plane for the floor, a few boxes, and my mouse coordinates displayed to the screen. What would be the best technique to detect when my mouse is over an object? Do I need to figure out where the box edges are in terms of screen coordinates and then do a compare with my mouse coordinates? If so, how do I determine the location of an object in terms of screen coordinates instead of my world coordinate system?

 

1. Get the projection-space point of your screen click position (Pos_Proj)

2. Combine your world-to-view, and view-to-projection matrices into a single world-to-projection matrix

3. Do an inverse matrix multiply with Pos_Proj, this will give you the world-space point (Pos_World)

4. Get the world-space direction vector (Dir = Pos_World - Pos_Camera)

5. Now you can do an intersection test between the position and direction vectors and whatever geometry you have






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.