1 package cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.UUID;
6 import java.util.Map.Entry;
7 import java.util.concurrent.Future;
8 import java.util.concurrent.TimeUnit;
9 import java.util.logging.Level;
10 import java.util.logging.Logger;
11
12 import javax.vecmath.Vector3d;
13
14 import cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule;
15 import cz.cuni.amis.pogamut.base.communication.exception.CommunicationException;
16 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult;
17 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdatedEvent;
18 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
19 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.WorldObjectUpdateResult;
20 import cz.cuni.amis.pogamut.base.communication.worldview.object.IWorldObject;
21 import cz.cuni.amis.pogamut.base.communication.worldview.object.WorldObjectFuture;
22 import cz.cuni.amis.pogamut.base.communication.worldview.object.WorldObjectId;
23 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
24 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
25 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.AddRay;
26 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.RemoveRay;
27 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AutoTraceRay;
28 import cz.cuni.amis.utils.flag.Flag;
29
30
31
32
33
34
35
36
37
38 public class Raycasting extends SensomotoricModule<UT2004Bot> {
39
40 RaycastingUT2004 rayUT2004;
41 RaycastingBSP rayBSP;
42
43 public Flag<Boolean> getAllRaysInitialized() {
44 return rayUT2004.allRaysInitialized;
45 }
46
47 public Raycasting(UT2004Bot bot) {
48 this(bot, null);
49
50 rayUT2004 = new RaycastingUT2004(bot);
51 rayBSP = new RaycastingBSP(bot);
52 }
53
54 public Raycasting(UT2004Bot bot, Logger log) {
55 super(bot, log);
56
57 rayUT2004 = new RaycastingUT2004(bot, log);
58 rayBSP = new RaycastingBSP(bot, log);
59
60 cleanUp();
61 }
62
63 @Override
64 protected void cleanUp() {
65 super.cleanUp();
66 }
67
68
69
70
71
72 public void clear() throws CommunicationException {
73 rayBSP.clear();
74 rayUT2004.clear();
75 }
76
77
78
79
80
81 public void endRayInitSequence() {
82 rayUT2004.endRayInitSequence();
83 }
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 public Future<AutoTraceRay> createRay(String Id, Vector3d Direction, int Length, boolean FastTrace, boolean FloorCorrection, boolean TraceActors) throws CommunicationException {
114 if (!TraceActors && rayBSP.isUsable()) {
115 return rayBSP.createRay(Id, Direction, Length, FloorCorrection);
116 } else {
117 return rayUT2004.createRay(Id, Direction, Length, FastTrace, FloorCorrection, TraceActors);
118 }
119 }
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 public Future<AutoTraceRay> createRay(Vector3d Direction, int Length, boolean FastTrace, boolean FloorCorrection, boolean TraceActors) throws CommunicationException {
150 if (!TraceActors && rayBSP.isUsable()) {
151 return rayBSP.createRay(Direction, Length, FloorCorrection);
152 } else {
153 return rayUT2004.createRay(Direction, Length, FastTrace, FloorCorrection, TraceActors);
154 }
155 }
156
157
158
159
160
161
162
163
164
165
166
167 public AutoTraceRay getRay(String rayID) {
168 AutoTraceRay r1 = rayUT2004.getRay(rayID);
169 if(r1 != null) return r1;
170 else return rayBSP.getRay(rayID);
171 }
172
173
174
175
176 protected void checkIfAllInited() {
177 rayUT2004.checkIfAllInited();
178 }
179
180 }
181