OSDN Git Service

Set optimal mime types and executable settings.
[mikumikustudio/MikuMikuStudio.git] / src / com / jme / intersection / CollisionResults.java
1 /*
2  * Copyright (c) 2003-2009 jMonkeyEngine
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
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.
15  *
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.
19  *
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.
31  */
32
33 package com.jme.intersection;
34
35 import java.util.ArrayList;
36
37 import com.jme.scene.Geometry;
38
39 /**
40  * <code>CollisionResults</code> stores the results of a collision test by
41  * storing an ArrayList of CollisionData.
42  * 
43  * @author Mark Powell
44  * @version $Id: CollisionResults.java,v 1.12 2006/06/21 20:33:02 nca Exp $
45  */
46 public abstract class CollisionResults {
47
48         private ArrayList<CollisionData> nodeList;
49
50         /**
51          * Constructor instantiates a new <code>PickResults</code> object.
52          */
53         public CollisionResults() {
54                 nodeList = new ArrayList<CollisionData>();
55         }
56
57         /**
58          * <code>addCollisionData</code> places a new <code>CollisionData</code>
59          * object into the results list.
60          * 
61          * @param col
62          *            The collision data to be placed in the results list.
63          */
64         public void addCollisionData(CollisionData col) {
65                 nodeList.add(col);
66         }
67
68         /**
69          * <code>getNumber</code> retrieves the number of collisions that have
70          * been placed in the results.
71          * 
72          * @return the number of collisions in the list.
73          */
74         public int getNumber() {
75                 return nodeList.size();
76         }
77
78         /**
79          * <code>getCollisionData</code> retrieves a CollisionData from a specific
80          * index.
81          * 
82          * @param i
83          *            the index requested.
84          * @return the CollisionData at the specified index.
85          */
86         public CollisionData getCollisionData(int i) {
87                 return nodeList.get(i);
88         }
89
90         /**
91          * <code>clear</code> clears the list of all CollisionData.
92          */
93         public void clear() {
94                 nodeList.clear();
95         }
96         
97         /**
98          * 
99          * <code>addCollision</code> is an abstract method whose intent is the 
100          * subclass determines what to do when two Geometry object's bounding
101          * volumes are determined to intersect.
102          * 
103          * @param s the first Geometry that intersects.
104          * @param t the second Geometry that intersects.
105          */
106         public abstract void addCollision(Geometry s, Geometry t);
107         
108         /**
109          * 
110          * <code>processCollisions</code> is an abstract method whose intent is
111          * the subclass defines how to process the collision data that has been
112          * collected since the last clear.
113          *
114          *
115          */
116         public abstract void processCollisions();
117
118 }