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.ILocated;
20 import java.util.ArrayList;
21 import java.util.List;
22
23
24
25
26
27 public class AStarNode {
28 private INavMeshAtom atom;
29 private AStarNode from;
30 private List<AStarNode> followers;
31 private double distanceFromStart;
32 private double estimatedDistanceToTarget;
33 private double estimatedTotalDistance;
34
35 public AStarNode(AStarNode from, INavMeshAtom atom, NavMesh mesh, INavMeshAtom start, INavMeshAtom target) {
36
37 this.from = from;
38 this.atom = atom;
39 followers = new ArrayList<AStarNode>();
40
41
42 if(from == null) {
43 distanceFromStart = 0;
44 }
45 else {
46 distanceFromStart = from.getDistanceFromStart() + mesh.getDistance(from.atom, atom);
47 }
48
49
50 estimatedDistanceToTarget = mesh.getDistance(atom, target);
51
52
53 estimatedTotalDistance = distanceFromStart + estimatedDistanceToTarget;
54 }
55
56 public double getDistanceFromStart() {
57 return distanceFromStart;
58 }
59 public double getEstimatedDistanceToTarget() {
60 return estimatedDistanceToTarget;
61 }
62 public double getEstimatedTotalDistance() {
63 return estimatedTotalDistance;
64 }
65 public INavMeshAtom getAtom() {
66 return atom;
67 }
68 public AStarNode getFrom() {
69 return from;
70 }
71 public List<AStarNode> getFollowers() {
72 return followers;
73 }
74 }