001: /*
002: * $RCSfile: PickCone.java,v $
003: *
004: * Copyright 1999-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.5 $
028: * $Date: 2008/02/28 20:17:27 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import javax.vecmath.*;
035:
036: /**
037: * PickCone is the abstract base class of all cone pick shapes.
038: *
039: * @since Java 3D 1.2
040: */
041: public abstract class PickCone extends PickShape {
042:
043: Point3d origin;
044: Vector3d direction;
045: double spreadAngle;
046:
047: /**
048: * Constructs an empty PickCone.
049: * The origin and direction of the cone are
050: * initialized to (0,0,0). The spread angle is initialized
051: * to <code>PI/64</code>.
052: */
053: public PickCone() {
054: this .origin = new Point3d();
055: this .direction = new Vector3d();
056: this .spreadAngle = Math.PI / 64.0;
057: }
058:
059: /**
060: * Gets the origin of this PickCone.
061: * @param origin the Point3d object into which the origin will be copied.
062: */
063: public void getOrigin(Point3d origin) {
064: origin.set(this .origin);
065: }
066:
067: /**
068: * Gets the direction of this PickCone.
069: * @param direction the Vector3d object into which the direction
070: * will be copied.
071: */
072: public void getDirection(Vector3d direction) {
073: direction.set(this .direction);
074: }
075:
076: /**
077: * Gets the spread angle of this PickCone.
078: * @return the spread angle.
079: */
080: public double getSpreadAngle() {
081: return spreadAngle;
082: }
083:
084: /**
085: * Gets the radius of this PickCone at the specified distance.
086: * @param distance the distance from the origin at which we want
087: * the radius of the cone
088: * @return the radius at the specified distance
089: */
090: double getRadius(double distance) {
091: return distance * Math.tan(spreadAngle);
092: }
093:
094: /**
095: * Return true if shape intersect with bounds.
096: * The point of intersection is stored in pickPos.
097: */
098: abstract boolean intersect(Bounds bounds, Point4d pickPos);
099:
100: Point3d getStartPoint() {
101: return origin;
102: }
103:
104: int getPickType() {
105: return PICKCONE;
106: }
107: }
|