2 * Copyright (c) 2003-2009 jMonkeyEngine
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 package com.jme.intersection;
35 import java.util.ArrayList;
37 import com.jme.math.Ray;
38 import com.jme.scene.Geometry;
39 import com.jme.scene.TriMesh;
42 * TrianglePickResults creates a PickResults object that calculates picking to
43 * the triangle accuracy. PickData objects are added to the pick list as they
44 * happen, these data objects refer to the two meshes, as well as their triangle
45 * lists. While TrianglePickResults defines a processPick method, it is empty
46 * and should be further defined by the user if so desired.
48 * NOTE: Only TriMesh objects may obtain triangle accuracy, all others will
49 * result in Bounding accuracy.
52 * @version $Id: TrianglePickResults.java,v 1.2 2004/10/14 01:23:12 mojomonkey
55 public class TrianglePickResults extends PickResults {
58 * <code>addPick</code> adds a Geometry object to the pick list. If the
59 * Geometry object is not a TriMesh, the process stops here. However, if the
60 * Geometry is a TriMesh, further processing occurs to obtain the triangle
61 * lists that the ray passes through.
64 * the ray that is doing the picking.
66 * the Geometry to add to the pick list.
67 * @see com.jme.intersection.PickResults#addPick(Ray, Geometry)
69 public void addPick(Ray ray, Geometry g) {
70 //find the triangle that is being hit.
71 //add this node and the triangle to the CollisionResults
73 if (!(g instanceof TriMesh)) {
74 PickData data = new PickData(ray, g, willCheckDistance());
77 ArrayList<Integer> a = new ArrayList<Integer>();
78 ((TriMesh) g).findTrianglePick(ray, a);
79 PickData data = new TrianglePickData(ray, ((TriMesh) g), a, willCheckDistance());
85 * <code>processPick</code> will handle processing of the pick list. This
86 * is very application specific and therefore left as an empty method.
87 * Applications wanting an automated picking system should extend
88 * TrianglePickResults and override this method.
90 * @see com.jme.intersection.PickResults#processPick()
92 public void processPick() {