001: /*
002: * $RCSfile: PickPoint.java,v $
003: *
004: * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.7 $
028: * $Date: 2008/02/28 20:17:28 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import javax.vecmath.*;
035:
036: /**
037: * PickPoint is a pick shape defined as a single point. It can
038: * be used as an argument to the picking methods in BranchGroup and Locale.
039: *
040: * @see BranchGroup#pickAll
041: * @see Locale#pickAll
042: * @see PickBounds
043: *
044: * @deprecated As of Java 3D version 1.4, use PickBounds with a
045: * BoundingSphere that has a small radius.
046: */
047: public final class PickPoint extends PickShape {
048:
049: Point3d location;
050:
051: /**
052: * Constructs a PickPoint using a default point.
053: * The point is initialized to (0,0,0).
054: */
055: public PickPoint() {
056: location = new Point3d();
057: }
058:
059: /**
060: * Constructs a PickPoint from the specified parameter.
061: * @param location the pick point.
062: */
063: public PickPoint(Point3d location) {
064: this .location = new Point3d(location);
065: }
066:
067: /**
068: * Sets the position of this PickPoint to the specified value.
069: * @param location the new pick point.
070: */
071: public void set(Point3d location) {
072: this .location.x = location.x;
073: this .location.y = location.y;
074: this .location.z = location.z;
075: }
076:
077: /**
078: * Gets the position of this PickPoint.
079: * @param location returns the current pick point.
080: */
081: public void get(Point3d location) {
082: location.x = this .location.x;
083: location.y = this .location.y;
084: location.z = this .location.z;
085: }
086:
087: /**
088: * Return true if shape intersect with bounds.
089: * The point of intersection is stored in pickPos.
090: */
091: final boolean intersect(Bounds bounds, Point4d pickPos) {
092: return bounds.intersect(location, pickPos);
093: }
094:
095: // Only use within J3D.
096: // Return a new PickPoint that is the transformed (t3d) of this pickPoint.
097: PickShape transform(Transform3D t3d) {
098:
099: PickPoint newPPt = new PickPoint();
100:
101: newPPt.location.x = location.x;
102: newPPt.location.y = location.y;
103: newPPt.location.z = location.z;
104:
105: t3d.transform(newPPt.location);
106:
107: return newPPt;
108: }
109:
110: Point3d getStartPoint() {
111: return location;
112: }
113:
114: int getPickType() {
115: return PICKPOINT;
116: }
117: }
|