Alice Community Getting relative coords of a mouse click
 User Name Remember Me? Password

 Thread Tools Display Modes
 Getting relative coords of a mouse click
 Silver Fox Guest   Status: Posts: n/a Getting relative coords of a mouse click - 12-19-2007, 08:14 PM I'm looking for a simple way to map a mouse click to the relative coordinates in the object where the click occurred. As a simple example, suppose that I want to move something (a ball, a penguin, whatever) to the location on the ground that corresponds to a mouse click. Of course, I know that I can get the (x, y) screen coordinates of a mouse click and I know that I could map that to the zero-elevation (x', y') coordinates on the ground, but I also know that doing the mapping would represent a heck of a lot of work on my part. What frustrates me is that Alice presumably does something like this when it decides whether the user has clicked on a particular object. Is there a quick solution I've missed, or do I just bite the bullet and do the transformation scutwork myself?
DrJim
Guest

Status:
Posts: n/a
12-19-2007, 09:40 PM

Quote:
 Originally Posted by Silver Fox Is there a quick solution I've missed, or do I just bite the bullet and do the transformation scutwork myself?
I'm not totally sure there is a good general solution at all - the problem (in addition to the relatively limited math functions provided by Alice) is that there is not a 1:1 mapping between 2D screen coordinates and 3D world coordinates.

What this means is you need to map from the screen to a surface - the ground is a nice choice, as you note - but then what happens if the ground isn't in the current display area?

Good luck - a solution would be nice. Please post it if you come up with one.

Silver Fox
Guest

Status:
Posts: n/a
12-20-2007, 12:59 PM

Quote:
 Originally Posted by DrJim Good luck - a solution would be nice. Please post it if you come up with one.
Heh. That might not happen, at least not in the immediate future. I know how I should do it, but now that I look more deeply into the problem I realize (1) it'll take longer than I want to spend, giving the holiday season, and (2) it'll be completely unusable for my upcoming Alice courses, since there's no way I'm going to mention things like quaternion multiplication (for the rotations) to a class of complete novices. Oh well....

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops     Alice Player and VR General Discussion     Questions and Comments     The Lounge