157. Picking



Description:

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.


Sample Overview

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.


Downloads



No comments:

Post a Comment