advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Reviews : Java Books : 3D User Interfaces with Java 3D :


Title: 3D User Interfaces with Java 3D
ISBN: 1884777902
US Price: $49.95
© Manning Publications Co.

Control intuition

19.1 Object picking
19.2 Intuitive mapping
19.3 Display-relative mapping
19.4 World-relative mapping
19.5 Summary

As you saw in the previous chapter, trying to control a target object with static control mapping can produce reasonable results, but only if you, the designer, carefully control the position of the user's view in the world. For some applications this might be acceptable, but for many it is not. When static control mapping is combined with general forms of navigation, situations often arise where the controls seem wrong or backward. Another practical aspect of trying to control objects in the scene is designating which object is the target. In the previous examples this was handled by assigning a different mouse button, or button and modifier key combination, to each object in the scene. Such an approach obviously won't work for more than a few objects, and even then it is impractical for the user to have to remember which but-ton- modifier goes with which object. Object picking is the technique needed to handle this problem.

The previous chapters described how the framework handles the fundamental aspects of the control chain, including device input and enabling, input filtering and mapping, and target actuation. This chapter will explore those aspects of the control chain needed to achieve more intuitive control of the situation, including control enabling based on picking, and dynamic forms of coordinate mapping, specifically DRM and WRM.

19.1 OBJECT PICKING


Figure 19. 1 Relationship of classes and interfaces related to object picking and enabling

Object picking is the workhorse of a 3D UI. For the most part, nothing happens of an intuitive nature in a 3D scene without object picking. Although the framework sup-ports picking in its various forms— discrete and continuous, bounds and geometric— the emphasis is on continuous geometric picking. Picking can be employed in a number of ways in a UI. This section introduces a general-purpose picking engine, and then describes how it can be used for target control enabling. Later chapters will describe how to use picking for other UI needs, such as for feedback and selection.

With a few minor exceptions, the classes used in picking and picking-based control enabling are found in the package j3dui.control.mappers. Table 19. 1 summarizes the classes and event interfaces related to picking and enabling, and figure 19.1 illustrates how they cooperate.

Table 19.1 Classes and interfaces related to object picking and enabling
Class/Interface Description Input Events Output Events
ObjectPickTarget Event interface for reporting pick tar-get changes  
ObjectPickSplitter Object pick event splitter ObjectPickTarget ObjectPickTarget
PickEngine Consolidates core picking functionality into a single class. Based on tar-get list picking.  
ObjectPickMapper Maps input movement and drags into object picks using a pick engine EnableTarget InputMoveTarget InputDragTarget ObjectPickTarget
OverEnableMapper Maps object picks into target enables ObjectPickTarget EnableTarget (list) EnableTarget (any) EnableTarget (none)

19.1.1 PickEngine class

The complete Java 3D picking model was described in detail in chapter 13. As you may recall, the Java 3D picking process is complex and decentralized. To achieve a degree of flexibility and generality in what can be a target object for picking, the framework uses an approach where the candidate pick objects are specified explicitly in a target list. Only objects, or more specifically scene graph Node objects, that are in the list can be picked, and then only if the objects and their descendants have been properly configured, with which the framework also assists.

The heart of the framework's picking capability is the PickEngine class. The constructor requires a root BranchGroup object in the scene graph under which the pick search will be performed, and a list of pick target objects that will be sought. A pick operation is performed when the method pickTarget is called, which requires specification of the source display and the pick cursor position in that display. The method returns the index of the target in the target list that was hit, if any, and optionally the 3D hit position on the target object. The method getPickTarget can be used to convert the pick index result into its equivalent pick object reference. After construction, the pick root and target list can be changed with the setRoot and setTargets methods, respectively.

Target pickability

For a target node to be pickable, it must lie under the pick root in the scene graph, its pick reporting capability must be set, its leaf shape nodes must be set pickable, and the capability to intersect the leaf shape geometry must be set. By default, Java 3D enables leaf nodes for picking, but pick reporting and geometry intersection must be explicitly enabled. As a convenience, objects in the target list are automatically con-figured for pick reporting, but not for leaf node picking. For explicit control of leaf node picking, you can use the utilities in the PickUtils class found in the j3dui.utils package. Also, many of the framework shape objects include the ability to set full leaf pickablity.

Engine configuration

By default, a pick engine performs geometry picking, and quits searching after the first pickable object is hit, whether or not it is in the target list. Bounds-only picking can be specified with the setUseBounds method, and hit testing of all objects under the pick cursor can be requested with the setHitAll method. Because picking performance is crucial to good UI design, the pick engine also includes provisions for assessing picking performance. A cheat mode, enabled with the setUseCheat method, allows side-by-side comparison of in-scene picking performance with and without Java 3D picking. This way, any difference in performance is due to the picking process itself, not the application overhead of handling input events and actuating targets.

Target order

The order of targets in the target list can be significant. If a parent and a descendant object, such as a desk and a drawer in the desk, are both targets in the target list, pick reporting will be enabled for both nodes. If a pick occurs on the descendant, both the parent and the descendant will be included in the hit's scene graph path. For each hit, the pick engine searches the scene graph path for each target in the target list, starting with the first target, which defines the order of pick precedence. When a hit on a list target is found, the search quits. Thus, for the descendant (the drawer) to be picked instead of its parent (the desk) in this situation, the descendant must be in the target list before the parent.

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 34
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

IBM Brings Developers Into the Cloud
Apache at 10: You Can't Buy Us
Microsoft's CodePlex Foundation Moving Forward
Apple Claims 100,000 Apps, Google Analyzes Them
Nokia Latest to Play Opera Mobile 10 Browser
PayPal Opens Up Payment Platform to Devs
Ubuntu Linux 9.10 'Karmic Koala' Starts Its Climb
IBM Links Rational Developer Tools, Tivoli Apps
Libraries Give Vista Apps a Windows 7 Look
Ubuntu: The 'Default Alternative' to Windows?

Delivering Web-based Embedded Fonts in CSS 3
Adobe Helps PHP Developers Create Rich Internet Applications
Java Developers Finding a Home at Adobe Flex
Virtualization Delivers a Dynamic Infrastructure
Consuming XML Web Services in iPhone Applications
Build a More Agile Business with IBM
POJO-Based Solutions for LDAP Access: One Good, One Better
IBM Offers Enhanced Measurement and Management for Energy Usage
IBM Helps Transformation to an Information-Based Enterprise
Top Five Touch UI-Related Design Guidelines

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs