Archived

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

griffenjam

using the mouse in 2D

Recommended Posts

I am having some serious problems using the mouse in 2D. All I want is to know where the cursor is when Z=0. I need constant position updates because I want something on screen to point to the mouse, I also want to draw a cursor. Any ideas or places to look? Jason Mickela ICQ : 873518 E-Mail: jmickela@sbcglobal.net ------------------------------ "Evil attacks from all sides but the greatest evil attacks from within." Me ------------------------------

Share this post


Link to post
Share on other sites
No, just the win32 API.
So if Win32 says 0,0 it''s talking about the upper left corner of the window, not the center.



Jason Mickela
ICQ : 873518
E-Mail: jmickela@sbcglobal.net
------------------------------
"Evil attacks from all sides
but the greatest evil attacks
from within." Me
------------------------------

Share this post


Link to post
Share on other sites
Well at Z = near your X will be (MouseX - Half_Screen_Width) and your Y will be (Half_Screen_Height - MouseY). (Y is inverted because in OpenGL up is +Y while for the mouse up is -Y.)

To convert this to Z=0 will be a bit trickier and I''m not very sure how to do it. It has to do with perspective projection.

Share this post


Link to post
Share on other sites
Hi there,

look at my post here

http://www.gamedev.net/community/forums/topic.asp?topic_id=64553

and just change the plane equation to be

{0,0,1,0} = Z = 0

Hope it helps

Mark

Share this post


Link to post
Share on other sites
Well - this might be wrong but - if your projection is like this.
screenX = X / Z
then Z should be 1 for onscreen values ? - right -

Maybe this is not the way you calculate things and maybe this will be diffrent with vector math ? ... ?

Share this post


Link to post
Share on other sites