(Computer graphic) Getting mouse coordinate after translate and rotate the world matrix

208 Views Asked by At

Hi is there any way to get the X,Y,Z of mouse in direct3d after I translate and rotate the world matrix?

2

There are 2 best solutions below

0
legalize On BEST ANSWER

The mouse doesn't have a Z coordinate because it's not a three-dimensional pointing device.

The best you can do is project the mouse's (x,y) coordinate on the screen through the viewing frustum to determine which portion of the viewing frustum correlates to the pixel position under the mouse cursor.

0
Ivan Aksamentov - Drop On

DirectX is completely unaware of mouse and any other input devices. It just is not what it cares about.

To get x and y coordinates you call Win32 API functions (this depends on framework you are using)

To get a z coordinate, you must implement Ray Picking. There is no uniform way, as this depends on how picked objects are implemented. Here are some tutorials on XNA Picking.