]> gitweb.fperrin.net Git - GpsPrune.git/blob - src/tim/prune/threedee/TerrainDefinition.java
d6cf3854f9525dc2fbf1c6754ad3dfa20ea488c1
[GpsPrune.git] / src / tim / prune / threedee / TerrainDefinition.java
1 package tim.prune.threedee;
2
3 /**
4  * Holds the definition of the terrain to use
5  * (whether or not to use a terrain, and the resolution)
6  */
7 public class TerrainDefinition
8 {
9         private boolean _useTerrain = false;
10         private int     _gridSize   = 0;
11
12         /**
13          * Empty constructor specifying no terrain
14          */
15         public TerrainDefinition()
16         {
17                 this(false, 0);
18         }
19
20         /**
21          * Constructor
22          * @param inUse true to use a terrain
23          * @param inGridSize size of grid
24          */
25         public TerrainDefinition(boolean inUse, int inGridSize)
26         {
27                 setUseTerrain(inUse, inGridSize);
28         }
29
30         /**
31          * Set the parameters
32          * @param inUse true to use a terrain
33          * @param inGridSize size of grid
34          */
35         public void setUseTerrain(boolean inUse, int inGridSize)
36         {
37                 _useTerrain = inUse;
38                 _gridSize   = inGridSize;
39         }
40
41         /**
42          * @return true if terrain should be used, false otherwise
43          */
44         public boolean getUseTerrain() {
45                 return _useTerrain && _gridSize > 2;
46         }
47
48         /**
49          * @return grid size
50          */
51         public int getGridSize() {
52                 return _gridSize;
53         }
54
55         @Override
56         /**
57          * Compare two TerrainDefinitions to see if they're equal
58          */
59         public boolean equals(Object obj)
60         {
61                 if (obj == null || !(obj instanceof TerrainDefinition)) {
62                         return false;
63                 }
64                 TerrainDefinition other = (TerrainDefinition) obj;
65                 return _useTerrain == other._useTerrain
66                         && _gridSize == other._gridSize;
67         }
68 }