next

Introduction to the Picker


Meet the Picker

The Picker is one of the most important tools in the Shout3D API (Application Programming Interface). It's also one of the most challenging for new users - not because it's especially complex or tricky, but rather because inherently requires an understanding of some "under-the-hood" principles of 3D computer graphics. In this tutorial, we will explore some of these principles as we learn about the Picker.

The Picker implements ray intersection. Ray intersection is a process in which an application determines which, if any, pieces of geometry are intersected by a ray passing through the space of the scene. If this ray begins at the position of the camera (the Viewpoint), ray intersection can be used to determine what objects in the scene lie beneath the current cursor location on the user's screen. You can therefore use ray intersection to allow users to "pick" 3D objects with their cursor – a process that everyone who uses a 3D modeling or animation package is already familiar with. This is why ray intersection is often called "pick intersection" and why the tool in Shout3D is called a Picker.

But the Picker need not be used for picking with the cursor. It can be used to measure the distance between the origin of the ray and the surface of any intersected geometry. The standard Shout3D WalkApplet uses Pickers to implement collision detection and terrain following. A ray from the Viewpoint determines whether the user has approached a wall, and if the distance to the wall is less than a certain minimum, the Viewpoint will not be allowed to move further in that direction. In similar fashion, a ray pointing downward is used to measure the distance to the ground. The vertical position of the Viewpoint is adjusted, as necessary, to remain at a constant height above the surface immediately beneath it. Thus the user can walk up and down steps, and generally follow terrain. You can study the use of the Picker in this context in the source code to the WalkPanel class (WalkPanel.java).

In fact, the Picker ray need not originate from the Viewpoint at all. It can begin anywhere in the scene and extend in any direction. It can therefore be used to measure distances between objects to implement object-object (as opposed to Viewpoint-object) collision detection.

In this tutorial, we will only consider the use of the Picker for true pick intersection using the cursor. But much of what we will be learning will apply to all uses of the Picker.

Next>


Copyright© 1999-2001, Shout3D LLC.