Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Getting relative coords of a mouse click
Old
Silver Fox
Guest
 
Status:
Posts: n/a
Default 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?
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 12-19-2007, 09:40 PM

Quote:
Originally Posted by Silver Fox View Post
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.
   
Reply With Quote
Old
Silver Fox
Guest
 
Status:
Posts: n/a
Default 12-20-2007, 12:59 PM

Quote:
Originally Posted by DrJim View Post
<snip>

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....
   
Reply With Quote
Reply

Thread Tools
Display Modes

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 Jump



Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.