1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package cz.cuni.amis.pogamut.ut2004.agent.navigation.navmesh;
18
19 import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
20 import java.util.ArrayList;
21 import java.util.List;
22
23
24
25
26
27 public class NavMeshPolygon implements INavMeshAtom {
28 private int pId;
29
30 NavMeshPolygon(int pId) {
31 this.pId = pId;
32 }
33
34 public int getPolygonId() {
35 return pId;
36 }
37
38 @Override
39 public List<INavMeshAtom> getNeighbours(NavMesh mesh) {
40 List<INavMeshAtom> neighbours = new ArrayList<INavMeshAtom>();
41
42
43 List<Integer> pn = mesh.getNeighbourIdsToPolygon(pId);
44 for(Integer i : pn) {
45 neighbours.add(new NavMeshPolygon(i));
46 }
47
48
49 List<OffMeshPoint> ops = mesh.getOffMeshPointsOnPolygon(pId);
50 for(OffMeshPoint op : ops) {
51 neighbours.add(op);
52 }
53
54 return neighbours;
55 }
56
57
58
59
60
61
62
63 public boolean equals(INavMeshAtom atom) {
64 if(atom.getClass() == NavMeshPolygon.class) {
65 NavMeshPolygon p = (NavMeshPolygon) atom;
66 return (p.getPolygonId()==pId);
67 }
68 else return false;
69 }
70 }