19.4.2 QuasiWrmDragPlugin class
True WRM, as defined by the WrmPlugin class, can be expensive because it requires
continuous picking. There are also situations where a less general and more constrained
form of WRM might even be desirable. The solution to both of these problems
is a picking plane.
Picking plane
A picking plane offers a cheap alternative to full blown object picking if all you are
interested in is a hit point. The picking plane is positioned to approximate the drag
surface on a picked object. Then, during a drag, the source space hit point is computed
by intersecting the same picking ray used for normal picking with the picking
plane, which is significantly less demanding on the system than real picking. For situations
that require it, this also constrains the source drag to a plane instead of the
arbitrary surface of the source object. Instead of a picking plane, other shapes could
be used that are easy to intersect with the picking ray, such as a sphere.
The framework provides utilities for handling picking planes in the Mapper class.
The buildPickPlane utility builds a pick plane, given a hit point and a hit node
defining the plane's reference space. The buildPickRay utility builds a pick ray (origin
point and direction vector), given a display canvas and a pick cursor position in it. This
is the same utility used by PickEngine for picking. The hitPickPlane utility inter-sects
a pick ray with a pick plane and returns the 3D hit point.
Quasi-WRM
The QuasiWrmPlugin subclass of WrmPlugin offers a variation of WRM based on use
of a picking plane. It uses discrete picking to select the source node at the start of a
drag, the same as for general WRM, but during the drag it uses a picking plane. The
discrete pick defines a source object and the initial hit point. The picking plane is
placed such that it passes through the hit point and is perpendicular to the reference
source space Z axis. Depending on the plug-in constructor used, the source reference
space will be defined dynamically by the discretely picked source object, or statically
by the source node specified in the constructor.
19.4.3 PseudoWrmDragPlugin class
Yet another variation on WRM is pseudo-WRM. As its name implies, it is not real
WRM in that no source node picking is involved, but it does work a lot like quasi-WRM.
Instead of placing a picking plane relative to the picked source node, however,
it is instead placed relative to a picked target node, such as the target of the manipulation
itself, the actuation target object. Because no source node picking is involved, the
source space reference node must be specified statically, in the constructor. Thus, the
picking plane is positioned relative to the target, through its hit point, but it is oriented
according to the source node's reference space, as it is in quasi-WRM.
One of the pleasant side effects of pseudo-WRM is that the dragged target object
will appear to be stuck to the drag cursor, no matter where the target is dragged or how
the scene is viewed. This might seem a fortunate coincidence, but it is no coincidence.
Pseudo-WRM is in essence true WRM, but with a single planar source node that always
passes through the initial hit point on the target object. Thus, the projection from the
hit point to the reference source object, which is what was needed for real WRM sticky
cursor, is zero. With zero offset, the source point under the drag cursor is the same as
the hit point on the object, and thus the target appears stuck to the cursor.
A variation of pseudo-WRM, provided by one of the constructors, is to specify the
target node statically instead of using a picker. In this case, a drag operation will always
use the specified target node's origin as the initial hit point, with the picking plane
passing through it. In this particular form of pseudo-WRM, the target object will not
always appear to be stuck to the drag cursor because of the possible offset between the
cursor hit position on the object and the position of the object's origin.
19.4.4 Example: WrmMapping
This example demonstrates WRM of control inputs.
See
The virtual world contains three target objects (red, green, blue) inside a corner space
formed by three orthogonal planes (a floor and two walls). A screen shot is provided
in figure 19. 7.
Do
- Drag the mouse (left button with SHIFT)
in the display or use the ARROW
keys (with SHIFT) to orbit the view in
heading and elevation about the world
origin.
- Drag the mouse (left button) on the
left (red) target to translate it along
any plane beneath the mouse cursor.
- Drag the mouse (right button) on the
left (red) target to roll it relative to any
plane beneath the mouse cursor.
- Drag the mouse (left button) on the
middle (green) target to translate it
along the plane beneath where the
mouse cursor started.
- Drag the mouse (right button) on the
middle (green) target to roll it relative to the plane beneath where the mouse cursor
started.
- Drag the mouse (left button) on the bottom (blue) target to translate it along the
bottom X-Z plane.
- Drag the mouse (right button) on the bottom (blue) target to roll it relative to
the bottom X-Z plane.
- Repeat the drag operations from different view directions.
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.
|