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.agent.module.sensor.NavigationGraphHelper;
9
10
11
12
13
14 public class StickToPathProperties extends SteeringProperties {
15
16
17
18
19 private static final long serialVersionUID = 7084968068794870946L;
20
21
22
23 private int repulsiveForce;
24
25
26 private int distance;
27
28
29 transient IPathFuture<ILocated> path;
30
31
32 private Location targetLocation;
33
34
35 private double regulatingForce;
36
37
38 private int projection;
39
40 public StickToPathProperties() {
41 super(SteeringType.STICK_TO_PATH);
42 this.repulsiveForce = 200;
43 this.distance = 400;
44 this.targetLocation = new Location(9440,-9500,-3446.65);
45 this.path = null;
46 this.regulatingForce = 50;
47 this.projection = 5;
48 }
49
50 public StickToPathProperties(StickToPathProperties values) {
51 this();
52 this.repulsiveForce = values.repulsiveForce;
53 this.distance = values.distance;
54 this.targetLocation = values.targetLocation;
55 this.path = values.path;
56 this.regulatingForce = values.regulatingForce;
57 this.projection = values.projection;
58 }
59
60 protected void setNewBehaviorType(BehaviorType behaviorType) {
61 if (behaviorType.equals(BehaviorType.BASIC)) {
62 regulatingForce = 0;
63 projection = 5;
64 } else if (behaviorType.equals(BehaviorType.ADVANCED)) {
65 regulatingForce = 50;
66 projection = 5;
67 }
68 }
69
70 public int getRepulsiveForce() {
71 return repulsiveForce;
72 }
73
74 public void setRepulsiveForce(int orderOfTheForce) {
75 this.repulsiveForce = orderOfTheForce;
76 }
77
78
79 public int getDistanceFromThePath() {
80 return distance;
81 }
82
83 public void setDistanceFromThePath(int distanceFromThePath) {
84 this.distance = distanceFromThePath;
85 }
86
87 public IPathFuture<ILocated> getPath() {
88 return path;
89 }
90
91 public void setPath(IPathFuture<ILocated> path) {
92 this.path = path;
93 }
94
95 public Location getTargetLocation() {
96 return targetLocation;
97 }
98
99 public void setTargetLocation(Location targetLocation) {
100 this.targetLocation = targetLocation;
101 }
102
103 public double getRegulatingForce() {
104 return regulatingForce;
105 }
106
107 public void setRegulatingForce(double regulatingForce) {
108 this.regulatingForce = regulatingForce;
109 }
110
111 public int getProjection() {
112 return projection;
113 }
114
115 public void setProjection(int projection) {
116 this.projection = projection;
117 }
118
119 @Override
120 public String getSpecialText() {
121 String text = "";
122 text += " * Repulsive Force: " + repulsiveForce + "\n";
123 text += " * Target Location: " + targetLocation.toString() + "\n";
124 text += " * Distance: " + distance + "\n";
125 text += " * Regulation: " + regulatingForce + "\n";
126 text += " * Projection: " + projection + "\n";
127 return text;
128 }
129
130 @Override
131 public void setProperties(SteeringProperties newProperties) {
132 this.repulsiveForce = ((StickToPathProperties)newProperties).getRepulsiveForce();
133 this.distance = ((StickToPathProperties)newProperties).getDistanceFromThePath();
134 this.targetLocation = ((StickToPathProperties)newProperties).getTargetLocation();
135 this.path = ((StickToPathProperties)newProperties).getPath();
136 this.regulatingForce = ((StickToPathProperties)newProperties).getRegulatingForce();
137 this.projection = ((StickToPathProperties)newProperties).getProjection();
138 }
139
140 public XMLPathFollowingProperties getXMLProperties() {
141 XMLPathFollowingProperties xmlProp = new XMLPathFollowingProperties();
142 xmlProp.repulsiveForce = repulsiveForce;
143 xmlProp.distance = distance;
144 xmlProp.xTargetLocation = (int) targetLocation.x;
145 xmlProp.yTargetLocation = (int) targetLocation.y;
146 xmlProp.zTargetLocation = (int) targetLocation.z;
147 xmlProp.regulatingForce = regulatingForce;
148 xmlProp.projection = projection;
149 xmlProp.active = active;
150 xmlProp.weight = weight;
151 xmlProp.behavior = behaviorType;
152 return xmlProp;
153 }
154 }