-
-
Notifications
You must be signed in to change notification settings - Fork 102
Picking
Simon (darkside) Jackson edited this page Aug 21, 2020
·
6 revisions
Area | Submitted | Type |
---|---|---|
Games: 3D Graphics, Games: Collision, Games: Graphics, Games: Physics | 5/24/2007 | Code Sample |
This sample shows how to determine whether a player's cursor is over an object, and how to find out where on the screen an object is.
There are several situations in which it can be useful to know the 3D equivalent of a point on the screen, and vice versa: for example, checking to see whether a player has clicked on an object, or drawing text above a player's head. This can be accomplished by using the Project and Unproject methods on the Viewport class. This sample demonstrates the use of these methods.
In the sample, there's a table with several objects on it. If the user moves the cursor over an object, the object's name is drawn.
All content and source code downloaded from this page are bound to the Microsoft Permissive License (Ms-PL).
Download | Size | Description |
---|---|---|
PickingSample_4_0 | 3.95MB | Source code and assets for the Picking Sample (XNA Game Studio 4.0). |
PickingSample_4_0.zip | 3.95MB | Source code and assets for the Picking Sample (XNA Game Studio 4.0). |