1 package SteeringProperties;
2
3 import SteeringStuff.SteeringType;
4 import XMLSteeringProperties.XMLPathFollowingProperties;
5 import cz.cuni.amis.pogamut.base.agent.navigation.IPathFuture;
6 import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
7 import cz.cuni.amis.pogamut.base3d.worldview.object.Location;
8 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint;
9
10
11
12
13
14 public class PathFollowingProperties extends SteeringProperties {
15
16
17
18 private int repulsiveForce;
19
20
21 private int distance;
22
23
24 transient IPathFuture<ILocated> path;
25
26
27 private Location targetLocation;
28
29
30 private double regulatingForce;
31
32
33 private int projection;
34
35 public PathFollowingProperties() {
36 super(SteeringType.PATH_FOLLOWING);
37 this.repulsiveForce = 200;
38 this.distance = 400;
39 this.targetLocation = new Location(9440,-9500,-3446.65);
40 this.path = null;
41 this.regulatingForce = 50;
42 this.projection = 5;
43 }
44
45 public PathFollowingProperties(BehaviorType behaviorType) {
46 super(SteeringType.PATH_FOLLOWING, behaviorType);
47 this.repulsiveForce = 200;
48 this.distance = 400;
49 this.targetLocation = new Location(9440,-9500,-3446.65);
50 this.path = null;
51 this.regulatingForce = 50;
52 this.projection = 5;
53 setNewBehaviorType(behaviorType);
54 }
55
56 public PathFollowingProperties(XMLPathFollowingProperties xml) {
57 super(SteeringType.PATH_FOLLOWING, xml.active, xml.weight, xml.behavior);
58 this.repulsiveForce = xml.repulsiveForce;
59 this.distance = xml.distance;
60 this.targetLocation = new Location(xml.xTargetLocation,xml.yTargetLocation,xml.zTargetLocation);
61 this.path = null;
62 this.regulatingForce = xml.regulatingForce;
63 this.projection = xml.projection;
64 }
65
66
67
68
69
70
71
72
73
74
75
76 public PathFollowingProperties(IPathFuture<? extends ILocated> path) {
77 super(SteeringType.PATH_FOLLOWING);
78 this.repulsiveForce = 200;
79 this.distance = 400;
80 this.targetLocation = path.getPathTo().getLocation();
81 this.path = (IPathFuture) path;
82 this.regulatingForce = 50;
83 this.projection = 5;
84 }
85
86 public PathFollowingProperties(int repulsiveForce, int distanceFromThePath, IPathFuture<ILocated> path, Location targetLocation, double regulatingForce, int projection) {
87 super(SteeringType.PATH_FOLLOWING);
88 this.repulsiveForce = repulsiveForce;
89 this.distance = distanceFromThePath;
90 this.path = path;
91 this.targetLocation = targetLocation;
92 this.regulatingForce = regulatingForce;
93 this.projection = projection;
94 }
95
96 protected void setNewBehaviorType(BehaviorType behaviorType) {
97 if (behaviorType.equals(BehaviorType.BASIC)) {
98 regulatingForce = 0;
99 projection = 5;
100 } else if (behaviorType.equals(BehaviorType.ADVANCED)) {
101 regulatingForce = 50;
102 projection = 5;
103 }
104 }
105
106
107 public int getRepulsiveForce() {
108 return repulsiveForce;
109 }
110
111 public void setRepulsiveForce(int orderOfTheForce) {
112 this.repulsiveForce = orderOfTheForce;
113 }
114
115
116 public int getDistanceFromThePath() {
117 return distance;
118 }
119
120 public void setDistanceFromThePath(int distanceFromThePath) {
121 this.distance = distanceFromThePath;
122 }
123
124 public IPathFuture<ILocated> getPath() {
125 return path;
126 }
127
128 public void setPath(IPathFuture<ILocated> path) {
129 this.path = path;
130 }
131
132 public Location getTargetLocation() {
133 return targetLocation;
134 }
135
136 public void setTargetLocation(Location targetLocation) {
137 this.targetLocation = targetLocation;
138 }
139
140 public double getRegulatingForce() {
141 return regulatingForce;
142 }
143
144 public void setRegulatingForce(double regulatingForce) {
145 this.regulatingForce = regulatingForce;
146 }
147
148 public int getProjection() {
149 return projection;
150 }
151
152 public void setProjection(int projection) {
153 this.projection = projection;
154 }
155
156 @Override
157 public String getSpecialText() {
158 String text = "";
159 text += " * Repulsive Force: " + repulsiveForce + "\n";
160 text += " * Target Location: " + targetLocation.toString() + "\n";
161 text += " * Distance: " + distance + "\n";
162 text += " * Regulation: " + regulatingForce + "\n";
163 text += " * Projection: " + projection + "\n";
164 return text;
165 }
166
167 @Override
168 public void setProperties(SteeringProperties newProperties) {
169 this.repulsiveForce = ((PathFollowingProperties)newProperties).getRepulsiveForce();
170 this.distance = ((PathFollowingProperties)newProperties).getDistanceFromThePath();
171 this.targetLocation = ((PathFollowingProperties)newProperties).getTargetLocation();
172 this.path = ((PathFollowingProperties)newProperties).getPath();
173 this.regulatingForce = ((PathFollowingProperties)newProperties).getRegulatingForce();
174 this.projection = ((PathFollowingProperties)newProperties).getProjection();
175 }
176
177 public XMLPathFollowingProperties getXMLProperties() {
178 XMLPathFollowingProperties xmlProp = new XMLPathFollowingProperties();
179 xmlProp.repulsiveForce = repulsiveForce;
180 xmlProp.distance = distance;
181 xmlProp.xTargetLocation = (int) targetLocation.x;
182 xmlProp.yTargetLocation = (int) targetLocation.y;
183 xmlProp.zTargetLocation = (int) targetLocation.z;
184 xmlProp.regulatingForce = regulatingForce;
185 xmlProp.projection = projection;
186 xmlProp.active = active;
187 xmlProp.weight = weight;
188 xmlProp.behavior = behaviorType;
189 return xmlProp;
190 }
191 }