Capturing active 2d sprite
-
Hi! I am new in DirectX programming and have some difficulties with getting mouse position and active sprite on Device screen. Maybe I don`t understand completely principles of IDirectInputDevice8. I am creating some LPD3DXSPRITE and LPDIRECT3DTEXTURE9 on screen and using LPDIRECTINPUTDEVICE8 to capture mouse. But I can`t completely get texture or sprite under mouse. Is there some simple principles to get elements above mouse cursor? Maybe sample or something? :confused: :mad: :wtf:
-
Hi! I am new in DirectX programming and have some difficulties with getting mouse position and active sprite on Device screen. Maybe I don`t understand completely principles of IDirectInputDevice8. I am creating some LPD3DXSPRITE and LPDIRECT3DTEXTURE9 on screen and using LPDIRECTINPUTDEVICE8 to capture mouse. But I can`t completely get texture or sprite under mouse. Is there some simple principles to get elements above mouse cursor? Maybe sample or something? :confused: :mad: :wtf:
Even though you're trying to capture a 2D sprite, you're using Direct3D, right? So in reality, you're trying to click on a section of a plane in 3D space. This presents additional computation, since you have to convert the mouse position on the screen into a Ray in 3D space. It's not as simple as the 2D case, I'm afraid :( It takes a bit of explanation, and I'm in the process of compiling an article on the subject, but there really isn't room to describe the process here. You may want to poke around the internet for some keywords like "3D hit testing" "ray picking" and the like. Bob Ciora